From d8335a1ff5c24a4ccb0246d43a82e12b5ac310de Mon Sep 17 00:00:00 2001 From: Wilfried OLLIVIER Date: Sat, 29 Jun 2019 21:27:44 +0200 Subject: [PATCH] Add exec tasks if service found --- src/ops/tools/ansible.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ops/tools/ansible.md b/src/ops/tools/ansible.md index 7e9fadd..3f8d771 100644 --- a/src/ops/tools/ansible.md +++ b/src/ops/tools/ansible.md @@ -49,4 +49,18 @@ import_tasks. ``` `ìnclude_tasks` will add all tasks to play run, even if the when condition is -false. \ No newline at end of file +false. + +## Exec task(s) if a specific service is found + +```yaml +- name: Is Docker running ? + service_facts: + +- name: Push Telegraf docker input config if needed + template: + src: inputs/input.docker.conf.j2 + dest: /etc/telegraf/telegraf.d/input.docker.conf + notify: reload telegraf + when: "'docker' in services" +``` \ No newline at end of file