diff --git a/defaults/main.yaml b/defaults/main.yaml index ca4064b..0fc1faf 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. --- -nginx_file_include_dir_dest: /etc/nginx/conf.d -nginx_file_include_dir_group: "{{ ansible_user }}" -nginx_file_include_dir_mode: "0755" -nginx_file_include_dir_owner: "{{ ansible_user }}" +nginx_file_include_dir_dest: /etc/nginx/conf.d/ +nginx_file_include_dir_group: root +nginx_file_include_dir_mode: 0755 +nginx_file_include_dir_owner: root nginx_file_include_dir_src: "" nginx_file_nginx_conf_dest: /etc/nginx/nginx.conf diff --git a/tasks/config.yaml b/tasks/config.yaml index aa7b70e..6884a79 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -21,21 +21,12 @@ - Validate nginx - Restart nginx -- name: Create custom configuration directory. - become: yes - file: +- name: Copy nginx custom configuration. + copy: dest: "{{ nginx_file_include_dir_dest }}" group: "{{ nginx_file_include_dir_group }}" mode: "{{ nginx_file_include_dir_mode }}" owner: "{{ nginx_file_include_dir_owner }}" - state: directory - -- name: Rsync nginx configuration. - become: no - synchronize: - delete: yes - dest: "{{ nginx_file_include_dir_dest }}" - perms: yes src: "{{ nginx_file_include_dir_src }}" when: nginx_file_include_dir_src != "" notify: diff --git a/tests/test.yaml b/tests/test.yaml index 62d6636..9060b35 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -25,3 +25,18 @@ roles: - "{{ rolename }}" + + post_tasks: + - name: Register /etc/nginx/conf.d + stat: + path: /etc/nginx/conf.d + register: nginx_confd_stat + + - name: Assert nginx_confd_stat tests. + assert: + that: + - nginx_confd_stat.stat.exists + - nginx_confd_stat.stat.isdir + - nginx_confd_stat.stat.pw_name == 'root' + - nginx_confd_stat.stat.gr_name == 'root' + - nginx_confd_stat.stat.mode == '0755'