0
我有一个需要在centos 7和centos 6上运行的apache playbook。我希望基于分发主版本触发处理程序。我有一个名为restart apache on 7
的处理程序和另一个restart apache on 6
。使用if语句的Ansible处理程序
我handlers/main.yml
看起来像这样
---
- name: restart apache on 7
systemd: name=httpd state=restarted
- name: restart apache on 6
service: name=httpd state=restarted
我试图做我tasks/main.yml
以下,但似乎遇到了有关的通知脚本语法问题。
- 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%}
如何写通知语句来实现我的目标任何线索?