New in version 2.4.
:modifiers
.[group_1]
are hosts, members of the group.=
.children
modifier indicates that the section contains groups.vars
modifier indicates that the section contains variables assigned to members of the group.key=value
syntax are interpreted differently depending on where they are declared within your inventory.key=value
parameters per line. Therefore they need a way to indicate that a space is part of a value rather than a separator.:vars
section, INI values are interpreted as strings. For example var=FALSE
would create a string equal to FALSE
. Unlike host lines, :vars
sections accept only a single entry per line, so everything after the =
must be the value for the entry.Note
example1: | # example cfg file [web] host1 host2 ansible_port=222 # defined inline, interpreted as an integer [web:vars] http_port=8080 # all members of 'web' will inherit these myvar=23 # defined in a :vars section, interpreted as a string [web:children] # child groups will automatically add their hosts to parent group apache nginx [apache] tomcat1 tomcat2 myvar=34 # host specific vars override group vars tomcat3 mysecret="'03#pa33w0rd'" # proper quoting to prevent value changes [nginx] jenkins1 [nginx:vars] has_java = True # vars in child groups override same in parent [all:vars] has_java = False # 'all' is 'top' parent example2: | # other example config host1 # this is 'ungrouped' # both hosts have same IP but diff ports, also 'ungrouped' host2 ansible_host=127.0.0.1 ansible_port=44 host3 ansible_host=127.0.0.1 ansible_port=45 [g1] host4 [g2] host4 # same host as above, but member of 2 groups, will inherit vars from both # inventory hostnames are unique
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/plugins/inventory/ini.html