Ansible: Could not define "all" variables with a YAML inventory file

Created on 16 Jan 2017  路  1Comment  路  Source: ansible/ansible

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

YAML inventory

ANSIBLE VERSION
ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

We should be able to define all vars in yaml inventory, just like we can do it in ini ones, such as:

[all:vars]
foo=bar
STEPS TO REPRODUCE

Given the following hosts.yml

all:
  vars:
    foo: bar

test:
  hosts:
    localhost:

and the following command:

ansible -i hosts.yml all -m debug -a var=foo
EXPECTED RESULTS
localhost | SUCCESS => {
    "foo": "bar"
}
ACTUAL RESULTS
localhost | SUCCESS => {
    "foo": "VARIABLE IS NOT DEFINED!"
}
affects_2.2 bug feature

Most helpful comment

fixed via #22418
you should be able to do this now:

all:
  hosts:
     host1
  vars:
     myvar: myval
  children:
     group1: ....

>All comments

fixed via #22418
you should be able to do this now:

all:
  hosts:
     host1
  vars:
     myvar: myval
  children:
     group1: ....
Was this page helpful?
0 / 5 - 0 ratings