我是ansible的新手,最近在研究template和notify,但令我惊讶的是——看起来ansible插件——template——可能不支持notify-handler。
root@ansible0:/work/yml# cat test_notify.yml
- name: Playbook to test templates and notify
hosts: all
vars:
favourite_color: blue
age: 12
voting_center: ab456-g
fruits:
- banana
- apple
- mango
- pear
tasks:
- name: Template test
template:
src: templates/test_template.j2
dest: /tmp/test.conf
notify:
show output
handlers:
- name: show output
debug:
msg: "file created"
还有模板文件 --
root@ansible0:/work/yml# cat templates/test_template.j2
My favourite color is {{ favourite_color }}
{% if age > 18 %}
You are an adult, and you can vote in the voting center: {{ voting_center }}
{% else %}
Sorry, you are minor and you can’t vote yet.
{% endif %}
A list of fruits:
{% for fruit in fruits %}
- {{ fruit }}
{% endfor %}
但是“ansible-playbook test_notify.yml”的输出是--
root@ansible0:/work/yml# ansible-playbook test_notify.yml
PLAY [Playbook to test templates and notify] ******************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************
ok: [192.168.50.131]
ok: [192.168.50.132]
ok: [192.168.50.133]
TASK [Template test] ******************************************************************************************************************
fatal: [192.168.50.131]: FAILED! => {"changed": false, "checksum": "b262329443eaa717733cdedfa5f1ff152f7dda86", "msg": "Unsupported parameters for (ansible.legacy.copy) module: notify Supported parameters include: _original_basename, attributes, backup, checksum, content, dest, directory_mode, follow, force, group, local_follow, mode, owner, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"}
fatal: [192.168.50.132]: FAILED! => {"changed": false, "checksum": "b262329443eaa717733cdedfa5f1ff152f7dda86", "msg": "Unsupported parameters for (ansible.legacy.copy) module: notify Supported parameters include: _original_basename, attributes, backup, checksum, content, dest, directory_mode, follow, force, group, local_follow, mode, owner, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"}
fatal: [192.168.50.133]: FAILED! => {"changed": false, "checksum": "b262329443eaa717733cdedfa5f1ff152f7dda86", "msg": "Unsupported parameters for (ansible.legacy.copy) module: notify Supported parameters include: _original_basename, attributes, backup, checksum, content, dest, directory_mode, follow, force, group, local_follow, mode, owner, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"}
PLAY RECAP ****************************************************************************************************************************
192.168.50.131 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
192.168.50.132 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
192.168.50.133 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
我看不出错误在哪里,请帮忙。预先感谢
问候 艾森