--- - name: Install Nginx notify: nginx | Restart Nginx apt: name: - libnginx-mod-http-geoip - libnginx-mod-http-geoip2 - nginx - name: Create directories for Nginx configuration notify: nginx | Restart Nginx file: state: directory path: '{{ item }}' mode: 'u=rwx,go=rx' owner: root group: root with_items: - '{{ nginx__dir_etc }}' - '{{ nginx__confd_dir }}' - '{{ nginx__available_dir }}' - '{{ nginx__enabled_dir }}' - '{{ nginx__snippets_dir }}' - name: Create directories for Nginx HTML files notify: nginx | Restart Nginx file: state: directory path: '{{ item }}' mode: 'u=rwx,go=rx' owner: root group: root with_items: - '{{ nginx__dir_www }}' - '{{ nginx__dir_www_html }}' - name: Install Nginx config notify: nginx | Restart Nginx template: src: 'templates/nginx.conf' dest: '{{ nginx__dir_etc }}/nginx.conf' mode: 'u=rw,go=r' owner: root group: root - name: Install Nginx configs notify: nginx | Restart Nginx template: src: 'templates/conf.d/geoip.conf' dest: '{{ nginx__confd_dir }}/geoip.conf' mode: 'u=rw,go=r' owner: root group: root - name: Install Nginx stream config notify: nginx | Restart Nginx copy: content: "{{ nginx__stream }}\n" dest: '{{ nginx__dir_etc }}/stream.conf' mode: 'u=rw,go=r' owner: root group: root - name: Remove Nginx default site notify: nginx | Restart Nginx file: state: absent path: '{{ nginx__enabled_dir }}/default' when: nginx__remove_default|bool - name: Add Nginx upstreams notify: nginx | Restart Nginx template: src: 'templates/upstream.conf' dest: '{{ nginx__confd_dir }}/upstream-{{ item.name }}.conf' mode: 'u=rw,go=r' owner: root group: root with_items: '{{ nginx__upstreams }}' - name: Add Nginx sites notify: nginx | Restart Nginx template: src: 'templates/site.conf' dest: '{{ nginx__available_dir }}/{{ item.domain }}.conf' mode: 'u=rw,go=r' owner: root group: root with_items: '{{ nginx__sites }}' - name: Enable Nginx sites notify: nginx | Restart Nginx file: state: link src: '{{ nginx__available_dir }}/{{ item.domain }}.conf' dest: '{{ nginx__enabled_dir }}/{{ item.domain }}.conf' owner: root group: root with_items: '{{ nginx__sites }}' - name: Install additional files notify: nginx | Restart Nginx copy: src: 'files/{{ item }}' dest: '{{ nginx__dir_www_html }}/{{ item }}' mode: 'u=rw,go=r' owner: root group: root with_items: - 'maintenance.html' - 'maintenance.jpg' - name: Install additional snippets notify: nginx | Restart Nginx template: src: 'templates/snippets/{{ item }}.conf' dest: '{{ nginx__snippets_dir }}/{{ item }}.conf' mode: 'u=rw,go=r' owner: root group: root with_items: - 'maintenance'