Ansible Inventory的構建和使用

Inventory
What’s inventory?
a list of managed nodes, or hosts, that Ansible deploys and configures
Where’s inventory?
Option in config.cfg
Set file or directory name for option ‘inventory’
Environment Variable
ANSIBLE_INVENTORY
Option in command line
ansible all -m ping -i myInventory/prod.yml -i myInventory/test.yml
Target two inventory files
Inventory files must be in current directory, or use absolute path
How to build inventory?
Formats
INI
YAML
Groups
Default groups
all
ungrouped
Defined groups
Hosts in single defined group
Hosts in multiple defined groups
Parent/Children
Pattern for hosts
Add hosts as a range
numeric range
Specify a stride
alphabetic range
標簽: