我有以下攻略example.yml:
- hosts: all
remote_user: administrator
become: yes
tasks:
- name: Put resolv.conf
template:
src: /home/user/resolv.conf.j2
dest: /etc/resolv.conf
backup: yes
mode: 0644
when: variable_name == "string"其目的是通过一个定制的resolv.conf来更新它。
为了执行它,我正在运行:
ansible-playbook example.yml -k -u administrator --become --ask-become-pass --limit server_name -e variable_name='string'然而,我得到了以下错误:
SSH password:
SUDO password[defaults to SSH password]:
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [server_name]
TASK [Put resolv.conf] *******************************************************
fatal: [server_name]: FAILED! => {"changed": true, "failed": true, "msg": "unsupported parameter for module: when"}
to retry, use: --limit @/home/user/playbooks/example.retry
PLAY RECAP *********************************************************************
server_name : ok=1 changed=0 unreachable=0 failed=1我尝试了不同的语法,将"()“应用到变量,在双逗号和单逗号之间切换,等等,但总是相同的错误。
如果我没有同时使用变量和when条件,那么任务就成功完成了。
问题出在哪里?
发布于 2017-02-08 17:49:01
注意填充物!
- hosts: all
remote_user: administrator
become: yes
tasks:
- name: Put resolv.conf
template:
src: /home/user/resolv.conf.j2
dest: /etc/resolv.conf
backup: yes
mode: 0644
when: variable_name == "string"when是一个任务属性,而不是template的参数。
https://stackoverflow.com/questions/42109317
复制相似问题