I have an apache playbook which needs to run on centos 7 and centos 6. I want the handler triggered based on distribution major version. I have a handler called restart apache on 7
and another one restart apache on 6
.
My handlers/main.yml
looks like this
---
- name: restart apache on 7
systemd: name=httpd state=restarted
- name: restart apache on 6
service: name=httpd state=restarted
I have tried doing the following in my tasks/main.yml
but seem to be running into syntax issues pertaining to the notify script.
- name: Copy custom configs
copy:
dest: /etc/httpd/conf/
src: httpd.conf
owner: root
notify: {%if ansible_distribution_major_version >= '7.0' %}restart apache on 7 {%else%} restart apache on 6 {%endif%}
Any clues on how to write the notify statement to achieve my goal?