Skip to content

Instantly share code, notes, and snippets.

@lanky
Created November 8, 2016 13:38
Show Gist options
  • Save lanky/562012e15a2b7f68fd5efe3760a830d2 to your computer and use it in GitHub Desktop.
Save lanky/562012e15a2b7f68fd5efe3760a830d2 to your computer and use it in GitHub Desktop.
---
# failed_when is off because you want the var to register even if there are no matching files in /etc/init.d
- name: Get startup file list
shell: grep -l kiwix-serve /etc/init.d/*
register: startup_file_list
failed_when: no
# basename gives the filename of the init script, the 'service' module will find it
- name: Stop running kiwix service
service:
name: "{{ item | basename }}"
state: stopped
with_items: "{{ startup_file_list.stdout_lines }|default(omit)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment