--- - name: Include install tasks include_tasks: install.yml - name: Include enable tasks include_tasks: enable.yml - name: Include Alpine specific tasks include_tasks: alpine.yml when: ansible_facts['distribution'].lower() == "alpine" - name: Lock down and setup configuration directories file: path: '{{item}}' state: directory owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "{{nginx_conf_dir_mode}}" loop: - "{{nginx_conf_dir}}" - "{{nginx_conf_dir}}/conf.d" tags: - conf - name: Create Acme Challenge directory file: path: /var/lib/acme-challenge state: directory owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "0755" tags: - conf - name: Create Robots directory file: path: /var/lib/nginx-robots state: directory owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "0755" tags: - robots - conf - name: Create Robots sub directory file: path: '/var/lib/nginx-robots/{{item.name}}' state: directory owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "0755" loop: '{{nginx_robots}}' tags: - robots - conf - name: 'Install {{item.name}} robots' copy: dest: '/var/lib/nginx-robots/{{item.name}}/robots.txt' content: '{{item.robots_txt}}' owner: '{{nginx_conf_owner}}' loop: '{{nginx_robots}}' tags: - robots - conf - name: Install Robots includes copy: dest: "{{nginx_conf_dir}}/robots_{{item.name}}" content: | location /robots.txt { root /var/lib/nginx-robots/{{item.name}}; } owner: '{{nginx_conf_owner}}' loop: '{{nginx_robots}}' tags: - robots - conf - name: Install Main 'nginx.conf' template: src: nginx/nginx.conf dest: "{{nginx_conf_dir}}/nginx.conf" owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "{{nginx_conf_file_mode}}" when: not nginx_custom_template notify: - Restart Nginx tags: - conf - name: Install custom 'nginx.conf' template: src: "{{ansible_hostname}}/nginx/nginx.conf" dest: "{{nginx_conf_dir}}/nginx.conf" owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "{{nginx_conf_file_mode}}" when: nginx_custom_template notify: - Restart Nginx tags: - conf - name: Install Other Nginx templates template: src: "nginx/{{item}}" dest: "{{nginx_conf_dir}}/{{item}}" owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "{{nginx_conf_file_mode}}" loop: - acme-challenge - acl notify: - Restart Nginx tags: - conf - name: Install Htpasswd copy: src: '{{nginx_htpasswd}}' dest: /etc/htpasswd owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" when: nginx_htpasswd is defined tags: - conf - htpasswd