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%}
如何寫通知語句來實現我的目標任何線索?