Documentation

yaml - Uses a specifically YAML file as inventory source.

New in version 2.4.

Synopsis

  • YAML based inventory, starts with the ‘all’ group and has hosts/vars/children entries.
  • Host entries can have sub-entries defined, which will be treated as variables.
  • Vars entries are normal group vars.
  • Children are ‘child groups’, which can also have their own vars/hosts/children and so on.
  • File MUST have a valid extension, defined in configuration

Options

parameter
required
default
choices
configuration
comments
yaml_extensions
no
[u'.yaml', u'.yml', u'.json']
ini entries:

[defaults ]
yaml_valid_extensions = [u'.yaml', u'.yml', u'.json']

[inventory_plugin_yaml ]
yaml_valid_extensions = [u'.yaml', u'.yml', u'.json']

env:ANSIBLE_YAML_FILENAME_EXT
env:ANSIBLE_INVENTORY_PLUGIN_EXTS
list of 'valid' extensions for files containing YAML

Examples

all: # keys must be unique, i.e. only one 'hosts' per group
    hosts:
        test1:
        test2:
            var1: value1
    vars:
        group_var1: value2
    children:   # key order does not matter, indentation does
        other_group:
            children:
                group_x:
                    hosts:
                        test5
            vars:
                g2_var2: value3
            hosts:
                test4:
                    ansible_host: 127.0.0.1
        last_group:
            hosts:
                test1 # same host as above, additional group membership
            vars:
                last_var: MYVALUE

Notes

Note

  • It takes the place of the previously hardcoded YAML inventory.
  • To function it requires being whitelisted in configuration.

Author

  • UNKNOWN

If you want to help with development, please read Community Information & Contributing, Testing Ansible and Developing Plugins.