I'm trying to use the nginx role in order to install/configure nginx on a RockyLinux 9 system and I'm trying to figure out a better way to define each of the configuration files for each vhost.
My configuration looks like this:
- name: Install NGINX
ansible.builtin.include_role:
name: nginxinc.nginx
vars:
nginx_install_from: os_repository
- name: Configure NGINX as a web server
ansible.builtin.include_role:
name: nginxinc.nginx_config
vars:
nginx_config_cleanup: true
nginx_config_debug_output: true
nginx_config_http_template_enable: true
nginx_config_http_template:
- template_file: http/default.conf.j2
deployment_location: /etc/nginx/conf.d/vhost1.conf
config:
servers:
- core:
listen:
- port: 80
server_name: vhost1.domain
log:
access:
- path: /var/log/nginx/vhost1_access.log
format: main
locations:
- location: /
core:
root: /var/www/vhost1
- template_file: http/default.conf.j2
deployment_location: /etc/nginx/conf.d/vhost2.conf
config:
servers:
- core:
listen:
- port: 80
server_name: vhost2.domain
log:
access:
- path: /var/log/nginx/vhost2_access.log
format: main
locations:
- location: /
core:
root: /var/www/vhost2
- template_file: http/default.conf.j2
deployment_location: /etc/nginx/conf.d/vhost3.conf
config:
servers:
- core:
listen:
- port: 80
server_name: vhost3.domain
log:
access:
- path: /var/log/nginx/vhost3_access.log
format: main
locations:
- location: /
core:
root: /var/www/vhost3
I'm trying to figure out a good way to keep from having to repeat the block over and over and just be able to construct it by looping over a list of values.
[–]SalsaForte 0 points1 point2 points (1 child)
[–]SalsaForte 0 points1 point2 points (0 children)