2020-06-02 14:52:24 +02:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- name: Create the nginx webroot if different from the default
|
2021-07-07 14:10:08 +02:00
|
|
|
file:
|
|
|
|
dest: '{{ nginx_webroot }}'
|
|
|
|
state: directory
|
|
|
|
mode: 0755
|
2020-06-02 14:52:24 +02:00
|
|
|
when: nginx_webroot != '/usr/share/nginx/html'
|
|
|
|
|
|
|
|
tags: [ 'nginx', 'virtualhost' ]
|
|
|
|
|
|
|
|
- name: Install and enable the nginx virtualhost files on Deb based systems
|
|
|
|
block:
|
|
|
|
- name: Install the nginx virtualhost files
|
2021-07-07 14:10:08 +02:00
|
|
|
template:
|
|
|
|
src: nginx-virthost.j2
|
|
|
|
dest: '/etc/nginx/sites-available/{{ item.virthost_name }}'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0444
|
|
|
|
loop: '{{ nginx_virthosts }}'
|
2020-06-02 14:52:24 +02:00
|
|
|
notify: Reload nginx
|
|
|
|
|
|
|
|
- name: Enable the nginx virtualhosts
|
2021-07-07 14:10:08 +02:00
|
|
|
file:
|
|
|
|
src: '/etc/nginx/sites-available/{{ item.virthost_name }}'
|
|
|
|
dest: '/etc/nginx/sites-enabled/{{ item.virthost_name }}'
|
|
|
|
state: link
|
|
|
|
loop: '{{ nginx_virthosts }}'
|
2020-06-02 14:52:24 +02:00
|
|
|
notify: Reload nginx
|
|
|
|
|
|
|
|
when: ansible_distribution_file_variety == "Debian"
|
|
|
|
tags: [ 'nginx', 'virtualhost' ]
|
|
|
|
|
|
|
|
- name: Install and enable the nginx virtualhost files on RH based systems
|
|
|
|
block:
|
2020-07-31 12:33:22 +02:00
|
|
|
- name: Install the nginx virtualhost files
|
2021-07-07 14:10:08 +02:00
|
|
|
template:
|
|
|
|
src: nginx-virthost.j2
|
|
|
|
dest: '/etc/nginx/conf.d/{{ item.virthost_name }}.conf'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0444
|
|
|
|
loop: '{{ nginx_virthosts }}'
|
2020-07-31 12:33:22 +02:00
|
|
|
notify: Reload nginx
|
|
|
|
|
|
|
|
- name: nginx must be able to network connect when used as a proxy
|
|
|
|
seboolean:
|
|
|
|
name: httpd_can_network_connect
|
|
|
|
state: yes
|
|
|
|
persistent: yes
|
2021-07-07 14:10:08 +02:00
|
|
|
loop: '{{ nginx_virthosts }}'
|
2020-07-31 12:33:22 +02:00
|
|
|
when: item.proxy_standard_setup is defined and item.proxy_standard_setup
|
2020-06-02 14:52:24 +02:00
|
|
|
|
|
|
|
when: ansible_distribution_file_variety == "RedHat"
|
|
|
|
tags: [ 'nginx', 'virtualhost' ]
|