patternMinor
Is it possible to consolidate notification handlers when they are very similar?
Viewed 0 times
handlersareconsolidatepossiblewhensimilartheyverynotification
Problem
I have an Ansible role which uses handlers to restart services via the
Is there a way so I could parameterize the three separate handlers into something like this?:
systemd module.- name: restart ntp
systemd:
name: ntp
enabled: yes
state: restarted
become: true
- name: restart web server
systemd:
name: nginx
enabled: yes
state: restarted
become: true
- name: restart grafana
systemd:
name: grafana
enabled: yes
state: restarted
become: trueIs there a way so I could parameterize the three separate handlers into something like this?:
- name: restart {{svcname}}
systemd:
name: '{{svcname}}'
enabled: yes
state: restarted
become: trueSolution
In ansible 2.7 and earlier versions, variables in handlers name are not populated.
This bug was reported and a correction was lately pushed to devel version.
You need to run ansible from devel, and hope they publish this fix in the next release.
This bug was reported and a correction was lately pushed to devel version.
You need to run ansible from devel, and hope they publish this fix in the next release.
Context
StackExchange DevOps Q#5543, answer score: 4
Revisions (0)
No revisions yet.