Browse Source

Refactor service logic

This allows for more control over the nginx service.

Change-Id: I61984c35a5c45ad94d02a12d2fa6fa8a29c81d44
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
changes/48/648848/1
Paul Belanger 3 years ago
parent
commit
65afd10447
  1. 6
      defaults/main.yaml
  2. 5
      handlers/main.yaml
  3. 22
      tasks/service.yaml

6
defaults/main.yaml

@ -28,3 +28,9 @@ nginx_file_nginx_conf_dest: /etc/nginx/nginx.conf
nginx_file_nginx_conf_src: ""
nginx_package_name: nginx
nginx_service_nginx_daemon_reload: true
nginx_service_nginx_enabled: true
nginx_service_nginx_manage: true
nginx_service_nginx_name: nginx
nginx_service_nginx_state: started

5
handlers/main.yaml

@ -12,8 +12,3 @@
# License for the specific language governing permissions and limitations
# under the License.
---
- name: Restart nginx
become: yes
service:
name: nginx
state: restarted

22
tasks/service.yaml

@ -14,8 +14,20 @@
---
- name: Enable nginx service
become: true
service:
enabled: yes
name: nginx
notify:
- Restart nginx
systemd:
daemon_reload: "{{ nginx_service_nginx_daemon_reload }}"
enabled: "{{ nginx_service_nginx_enabled }}"
name: "{{ nginx_service_nginx_name }}"
register: nginx_service_nginx
when: nginx_service_nginx_manage
- name: Set nginx service state
become: true
systemd:
daemon_reload: "{{ nginx_service_nginx_daemon_reload }}"
name: "{{ nginx_service_nginx_name }}"
state: "{{ nginx_service_nginx_state }}"
register: nginx_service_nginx_state_info
when:
- nginx_service_nginx_manage
- nginx_service_nginx_state in ['reloaded', 'restarted', 'started', 'stopped']

Loading…
Cancel
Save