我想运行一个剧本,它对存储在host_vars中的变量执行。这是溶液布局:Ansible的手册不拾取主机变量
- /host_vars/F5-测试
- /库存/主机
- /playbook.yml
这些文件的内容如下低点:
/库存/主机:
[f5-test]
localhost
/host_vars /主机
f5_user:user
f5_password:password
f5_server:server
/playbook.yml
- name: Playbook
hosts: f5-test
gather_facts: no
gather_subset: no
tasks:
- name: Taks_01
tags: "bigip-node"
bigip_node:
server: "{{f5_server}}"
user: "{{f5_user}}"
password: "{{f5_password}}"
state: "present"
partition: "Common"
host: "10.20.30.40"
name: "F5_Node"
session_state: "enabled"
description: "description"
delegate_to: localhost
ħ H但是,当我们执行以下命令:
须藤ansible-剧本playbook.yml -i库存/主机-vvvv
我得到以下错误:
task path: /home/dev/ansible/playbook.yml:9
fatal: [localhost]: FAILED! => {
"failed": true,
"msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'f5_server' is undefined\n\nThe error appears to have been in '/home/dev/ansible/playbook.yml': line 9, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: Task_01\n ^here\n"
}
知道为什么它没有被拾起?我用与F5完全相同的结构建立了我的项目,可以找到here。
谢谢!
请仔细阅读你的问题并修复明显的不一致。很难分辨出在编写问题时以及在设置文件时出现了哪些错误。 – techraf