From cf0192b629dfd57b39287780b2356206906c9808 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 10 Nov 2015 12:40:28 +0000 Subject: lighttpd: Create handler for restarting services Change-Id: I193216280797e5453ab1606d6a8f83e27bd0a28e --- ansible/roles/trove-setup/handlers/main.yml | 9 +++++++++ ansible/roles/trove-setup/tasks/lighttpd.yml | 29 ++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 ansible/roles/trove-setup/handlers/main.yml diff --git a/ansible/roles/trove-setup/handlers/main.yml b/ansible/roles/trove-setup/handlers/main.yml new file mode 100644 index 0000000..758efcc --- /dev/null +++ b/ansible/roles/trove-setup/handlers/main.yml @@ -0,0 +1,9 @@ +- name: Restart lighttpd-git service + service: + name: lighttpd-git + state: restarted + +- name: Restart lighttpd-morph-cache service + service: + name: lighttpd-morph-cache + state: restarted diff --git a/ansible/roles/trove-setup/tasks/lighttpd.yml b/ansible/roles/trove-setup/tasks/lighttpd.yml index 710203c..64dd033 100644 --- a/ansible/roles/trove-setup/tasks/lighttpd.yml +++ b/ansible/roles/trove-setup/tasks/lighttpd.yml @@ -11,6 +11,7 @@ args: creates: /etc/lighttpd/certs/lighttpd.pem when: TROVE_SSL_PEMFILE is not defined + notify: Restart lighttpd-git service - name: Copy pemfile certificate for lighttpd if provided copy: @@ -18,6 +19,7 @@ dest: /etc/lighttpd/certs/lighttpd.pem mode: 0400 when: TROVE_SSL_PEMFILE is defined + notify: Restart lighttpd-git service - name: Copy ca-certs certificate for lighttpd if provided copy: @@ -25,6 +27,7 @@ dest: /etc/lighttpd/certs/ca-certs.pem mode: 0400 when: TROVE_SSL_CA_FILE is defined + notify: Restart lighttpd-git service - name: Create /var/run/lighttpd for cache user file: @@ -37,37 +40,25 @@ template: src: lighttpd/git-httpd.conf dest: /etc/lighttpd/git-httpd.conf + notify: Restart lighttpd-git service # Now that the lighttpd certificates, configuration files and /var/run/lighttpd -# exist, we can enable the lighttpd-git service +# exist, we can enable and start lighttpd services - name: Enable lighttpd-git service service: name: lighttpd-git.service enabled: yes - register: lighttpd_git_service + notify: Restart lighttpd-git service -# Now we can start the service without rebooting the system -- name: Restart the lighttpd-git service - service: - name: lighttpd-git - state: restarted - when: lighttpd_git_service|changed - -# Once the service lighttpd-git is running it's possible to do the same -# with the following services: -# - lighttpd-morph-cache -# - lighttpd-lorry-controller-webapp - name: Enable lighttpd-morph-cache service service: name: lighttpd-morph-cache.service enabled: yes - register: lighttpd_morph_cache_service -- name: Restart the lighttpd-morph-cache service - service: - name: lighttpd-morph-cache - state: restarted - when: lighttpd_morph_cache_service|changed + notify: Restart lighttpd-morph-cache service +# The service lighttpd-lorry-controller-webapp has to start here and +# can't be done in a handler, given that the lorry-controller-minion +# service will fail to start if this one is not running. - name: Enable the lighttpd-lorry-controller-webapp service service: name: lighttpd-lorry-controller-webapp.service -- cgit v1.2.1