【发布时间】:2017-04-02 14:25:09
【问题描述】:
我有一个需要在 centos 7 和 centos 6 上运行的 apache 剧本。我希望根据分发主要版本触发处理程序。我有一个名为restart apache on 7 的处理程序和另一个restart apache on 6。
我的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%}
关于如何编写通知语句以实现我的目标的任何线索?
【问题讨论】: