diff --git a/defaults/main.yaml b/defaults/main.yaml index 4ab6bc1..9748ed6 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -18,14 +18,10 @@ nginx_task_manager: - config - service -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 -nginx_file_nginx_conf_src: "" +nginx_file_nginx_config_group: root +nginx_file_nginx_config_mode: 0644 +nginx_file_nginx_config_owner: root +nginx_file_nginx_config: [] nginx_package_name: nginx diff --git a/handlers/main.yaml b/handlers/main.yaml index ca41d99..81cd218 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -12,3 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. --- +- name: Reload nginx + become: true + service: + name: nginx + state: reloaded + when: nginx_service_nginx_manage and + nginx_service_nginx_state == "started" and not + nginx_service_nginx.changed diff --git a/tasks/config.yaml b/tasks/config.yaml index dd4c947..8ddc9d4 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -12,23 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Copy nginx configuration file +- name: Install nginx configuration files become: true - copy: - dest: "{{ nginx_file_nginx_conf_dest }}" - src: "{{ nginx_file_nginx_conf_src }}" - when: nginx_file_nginx_conf_src - notify: - - Restart nginx - -- name: Copy nginx custom configuration - become: true - 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 }}" - src: "{{ nginx_file_include_dir_src }}" - when: nginx_file_include_dir_src - notify: - - Restart nginx + template: + dest: "{{ item.dest }}" + group: "{{ nginx_file_nginx_config_group }}" + mode: "{{ nginx_file_nginx_config_mode }}" + owner: "{{ nginx_file_nginx_config_owner }}" + src: "{{ item.src }}" + notify: Reload nginx + with_items: "{{ nginx_file_nginx_config }}"