From eaa11bff680ebf92ae1dc7239c69b8ae8436cc06 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Tue, 16 Feb 2016 14:35:28 -0500 Subject: [PATCH] Add rsync support Allow the user to use rsync for conf.d files. Change-Id: Ibb7ae3c01aeb803d5652a64a55106c0bcd92e016 Signed-off-by: Paul Belanger --- defaults/main.yaml | 6 +++++- tasks/config.yaml | 34 ++++++++++++++++++++++++---------- tox.ini | 7 +++++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/defaults/main.yaml b/defaults/main.yaml index bdd1b63..b2ba697 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -12,7 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. --- -nginx_config_include_files: [] +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_src: "" nginx_file_nginx_conf_dest: /etc/nginx/nginx.conf nginx_file_nginx_conf_src: etc/nginx/nginx.conf diff --git a/tasks/config.yaml b/tasks/config.yaml index 29e349e..47f97ef 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -12,17 +12,31 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Copy nginx custom configuration files. - copy: - dest: "{{ nginx_config_include_dir }}" - force: true - src: "{{ nginx_config_include_files }}" - notify: - - Restart nginx - - Validate nginx - - name: Copy nginx configuration file. copy: dest: "{{ nginx_file_nginx_conf_dest }}" src: "{{ nginx_file_nginx_conf_src }}" - notify: Restart nginx + notify: + - Validate nginx + - Restart nginx + +- name: Create custom configuration directory. + become: yes + file: + 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: + - Validate nginx + - Restart nginx diff --git a/tox.ini b/tox.ini index c3add41..a340d4a 100644 --- a/tox.ini +++ b/tox.ini @@ -12,8 +12,11 @@ commands = python setup.py build_sphinx [testenv:functional] commands = - ansible-playbook -i tests/inventory tests/test.yaml -passenv = HOME + # NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI. + ansible-playbook -i tests/inventory tests/test.yaml -e ansible_user={env:USER} +passenv = + HOME + USER setenv = ANSIBLE_CONFIG = {toxinidir}/tests/ansible.cfg PYTHONUNBUFFERED = 1