From 69eb712a78868c624ae7030e7ccde41c9719ac3d Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Fri, 13 Nov 2020 18:31:22 -0500 Subject: Change how the configuration is written to the servers --- tasks/main.yml | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'tasks') diff --git a/tasks/main.yml b/tasks/main.yml index 6f0d944..225662f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -18,15 +18,7 @@ - "{{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 @@ -69,44 +61,45 @@ tags: - robots - conf -- name: Install Main 'nginx.conf' - template: - src: nginx/nginx.conf + +- name: Install 'nginx.conf' + copy: + content: '{{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" + +- name: Install Nginx Snippets + copy: + content: '{{item.value}}' + dest: "{{nginx_conf_dir}}/{{item.key}}" owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "{{nginx_conf_file_mode}}" - when: nginx_custom_template - notify: - - Restart Nginx + loop: '{{nginx_includes | dict2items}}' + when: 'nginx_includes is defined' + notify: Restart Nginx tags: - conf -- name: Install Other Nginx templates - template: - src: "nginx/{{item}}" - dest: "{{nginx_conf_dir}}/{{item}}" + +- name: Install Nginx conf.d entires + copy: + content: '{{item.value}}' + dest: "{{nginx_conf_dir}}/conf.d/{{item.key}}" owner: "{{nginx_conf_owner}}" group: "{{nginx_conf_group}}" mode: "{{nginx_conf_file_mode}}" - loop: - - acme-challenge - - acl - notify: - - Restart Nginx + loop: '{{nginx_confd | dict2items}}' + when: 'nginx_confd is defined' + notify: Restart Nginx tags: - conf + - name: Install Htpasswd copy: src: '{{nginx_htpasswd}}' -- cgit v1.2.3