Refactor service logic

This allows for more control over the nginx service.

Change-Id: I61984c35a5c45ad94d02a12d2fa6fa8a29c81d44
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2019-03-30 22:11:31 -04:00
parent 5fa2ca3e42
commit 65afd10447
3 changed files with 23 additions and 10 deletions

View File

@ -28,3 +28,9 @@ nginx_file_nginx_conf_dest: /etc/nginx/nginx.conf
nginx_file_nginx_conf_src: "" nginx_file_nginx_conf_src: ""
nginx_package_name: nginx 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

View File

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

View File

@ -14,8 +14,20 @@
--- ---
- name: Enable nginx service - name: Enable nginx service
become: true become: true
service: systemd:
enabled: yes daemon_reload: "{{ nginx_service_nginx_daemon_reload }}"
name: nginx enabled: "{{ nginx_service_nginx_enabled }}"
notify: name: "{{ nginx_service_nginx_name }}"
- Restart nginx 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']