diff --git a/defaults/main.yaml b/defaults/main.yaml index 0fc1faf..6526ba1 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -12,6 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. --- +# tasks/main.yaml +nginx_task_manager: + - install + - config + - service + nginx_file_include_dir_dest: /etc/nginx/conf.d/ nginx_file_include_dir_group: root nginx_file_include_dir_mode: 0755 diff --git a/tasks/config.yaml b/tasks/config.yaml index dd95d50..f9d3492 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Copy nginx configuration file. +- name: Copy nginx configuration file + become: true copy: dest: "{{ nginx_file_nginx_conf_dest }}" src: "{{ nginx_file_nginx_conf_src }}" @@ -21,7 +22,8 @@ - Validate nginx - Restart nginx -- name: Copy nginx custom configuration. +- name: Copy nginx custom configuration + become: true copy: dest: "{{ nginx_file_include_dir_dest }}" group: "{{ nginx_file_include_dir_group }}" diff --git a/tasks/install.yaml b/tasks/install.yaml index ed224d4..d977587 100644 --- a/tasks/install.yaml +++ b/tasks/install.yaml @@ -13,6 +13,7 @@ # under the License. --- - name: Install nginx from package + become: true package: name: "{{ nginx_package_name }}" state: present diff --git a/tasks/install/redhat.yaml b/tasks/install/redhat.yaml deleted file mode 100644 index 7dcd548..0000000 --- a/tasks/install/redhat.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2015 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. ---- - diff --git a/tasks/main.yaml b/tasks/main.yaml index 404c9b1..ac03691 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -12,14 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Include OS-specific variables. +- name: Include OS-specific variables include_vars: "{{ ansible_os_family }}.yaml" -- include: install.yaml - become: yes - -- include: config.yaml - become: yes - -- include: service.yaml - become: yes +- include: "{{ nginx_task }}.yaml" + with_items: "{{ nginx_task_manager }}" + loop_control: + loop_var: nginx_task diff --git a/tasks/service.yaml b/tasks/service.yaml index 087616f..01a259b 100644 --- a/tasks/service.yaml +++ b/tasks/service.yaml @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Enable nginx service. +- name: Enable nginx service + become: true service: enabled: yes name: nginx