Ansible本地模式不会从所有变量中获取变量

时间:2015-06-25 14:21:11

标签: ansible ansible-playbook

我无法在简单的`local.yml'中访问group_vars/all中定义的变量的值。剧本。

我有目录结构:

/group_vars
   /all
local.yml

group_vars/all的内容:

key_name: bar

local.yml的内容:

- name: Local example
  connection: local
  gather_facts: no
  tasks:
    - debug: msg="Key is {{ key_name }}"

这是我如何运行剧本:

ansible-playbook -i localhost, local.yml

错误消息:

PLAY: Local example *************************************************************

TASK [debug msg=Key is {{ key_name }}] ******************************************
fatal: [localhost]: FAILED! => {"msg": "ERROR! the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'key_name' is undefined", "failed": true}

NO MORE HOSTS LEFT **************************************************************

PLAY RECAP **********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1

1 个答案:

答案 0 :(得分:1)

这是主分支上的一个错误,它是不稳定的:

https://github.com/ansible/ansible/issues/11325