我是 ansible 角色的新手,这就是我正在做的事情。
更多网站.yml
---
- hosts: user1_checkserverlist
user: user1
roles:
- { role: speed_manager, DNAME: "/u" }
- hosts: oracle_checkserverlist
user: oracle
roles:
- { role: speed_manager, DNAME: "/tmp" }
更多 speed_manager/defaults/main.yml
DNAME: ""
更多 speed_manager/tasks/main.yml
---
- include: check.yml diskname={{DNAME}}
更多 speed_manager/tasks/check.yml
---
- name: ==== Reading Variable ====
ping:
vars:
dn: "{{ diskname }}"
- name: ====Sync to remote hosts ====
synchronize: src="/web/roles/speed_manager/files/" dest="/tmp/mohtt/"
- name: ====Execute shell=============
shell: /tmp/mohtt/fixwebserver.sh {{ dn }} chdir=/tmp/mohtt
这就是我执行角色的方式
ansible-playbook -vvv site.yml -i /web/hostfiles/myhost.txt
错误:
TASK [check_bk_speed_manager : ====Execute shell=============] ***************** task path: /web/roles/speed_manager/tasks/check.yml:25 fatal: [myserver.com]: FAILED! => {"failed": true, "msg": "'dn' is undefined"} fatal: [myserver.com]: FAILED! => {"failed": true, "msg": "'dn' is undefined"} to retry, use: --limit @check_bk_speed.retry
我期望 dn 的值是“/u”
你能指出我哪里出错了,如果这是一个错误?