Created
June 27, 2014 21:31
-
-
Save 1stvamp/7d7018b4a832ed627557 to your computer and use it in GitHub Desktop.
Graceful or hard restart of service in ansible based on changed binary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
tasks: | |
- name: check for new payload | |
tags: config-changed | |
shell: if [ "$(md5sum {{ executable_path }})" != "$(cat {{ executable_md5_path }})" ]; then echo "changed"; fi | |
register: md5diff | |
changed_when: md5diff.stdout == "changed" | |
- name: store new payload md5 | |
tags: config-changed | |
shell: md5sum {{ executable_path }} > {{ executable_md5_path }} | |
when: md5diff.changed | |
- name: force reload on config changed | |
tags: config-changed | |
shell: echo "Forcing reload" | |
notify: Restart push http api service | |
when: not md5diff.changed | |
- name: force restart on config changed | |
tags: config-changed | |
shell: echo "Forcing restart" | |
notify: Hard restart push http api service | |
when: md5diff.changed | |
handlers: | |
- name: Reload supervisor | |
service: name=supervisor state=restarted | |
- name: Restart push http api service | |
shell: "supervisorctl pid push-http-api-server | xargs kill -s HUP" | |
- name: Hard restart push http api service | |
supervisorctl: name=push-http-api-server state=restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment