# http://docs.ansible.com/ansible/intro_inventory.html
[all:vars] #host_key_checking=false ansible_ssh_common_args='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' #information_environment=dev #information_product=prod1 #ansible_ssh_user=ubuntu #ansible_ssh_pass=pass1234 #ansible_user=root [example.com] www.example.com db.example.com [all:children] local example.com [local:children] phy.local vm.local [phy:children] phy.local phy.example.com [phy.local] www.local db.local backup.local lxc.local ansible_host=192.168.1.11
Order hosts in playbook
https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#hosts-and-users
inventory: The default. The order is ‘as provided’ by the inventory
reverse_inventory: As the name implies, this reverses the order ‘as provided’ by the inventory
sorted: Hosts are alphabetically sorted by name
reverse_sorted: Hosts are sorted by name in reverse alphabetical order
shuffle: Hosts are randomly ordered each run
# Ansible 2.2 - hosts: "{{ ansible_play_hosts | sort() }}" # Ansible >2.4 - hosts: all order: sorted tasks: - debug: var: inventory_hostname
Links
https://docs.ansible.com/ansible/2.4/intro_configuration.html#inventory