2015-06-25 49 views
1

我無法在簡單的`local.yml'劇本中訪問group_vars/all中定義的變量的值。Ansible本地模式不會從所有變量中獲取變量

目錄結構,我有:

內容 group_vars/all
/group_vars 
    /all 
local.yml 

內容的 local.yml

key_name: bar

- 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 

回答