Inventory Flashcards
Define inventory
The collection of hosts that Ansible manages
Simplest inventory content
ontartio.example.com
pei.example.com
nova-scotia.example.com
One host is always part of your inventory. Which one?
localhost
What is the difference between connecting to locahost and any other machine?
Ansible uses SSH for other hosts. For locahost it does not go through SSH. It uses local connection instead.
List Ansible behavioral inventory parameters
1) ansible_host
2) ansible_port
3) ansible_user
4) ansible_password
5) ansible_connection
6) ansible_private_key_file
7) ansible_shell_type
8) ansible_python_interpreter
9) ansible_*_interpreter
What are behavioral inventory paramaters?
behavioral invetory paramaters are variables that can be used to refine the definition of a host and how ansible should connect to it.
what is the name of the the default group?
all also named *
Ansible command to get dates on all managed nodes
ansible all - a “date”
What is the format of an inventory file?
ini file format
Define a group web with hosts toronto.example.com and vancouver.example.com
[web]
toronto. example.com
vancouver. example.com
I have 3 hosts running on the same 127.0.0.1 IP but different ports. My goal is to configure them. Explain why the following group configuration will not work?
And how to you resolve it?
[myservers]
- 0.0.1: 2000
- 0.0.1: 2001
- 0.0.1: 2002
Ansible inventory can associate only a single host with 127.0.0.1.
To resolve it use aliases
[myservers]
server1 ansible_host=127.0.0.1 ansible_port=2000
server2 ansible_host=127.0.0.1 ansible_port=2001
server3 ansible_host=127.0.0.1 ansible_port=2002
Define a group staging that contains two other groups: web and lb.
[staging:children]
lb
web
Define a group web that includes all servers web1.example.com to web20.example.com
[web]
web[1:20].example.com
Define two variables user and password for a group web
[web:vars]
user=macabo
password=eboubolo
What are possible types of a ansible variable?
Booleans, strings, dictionaries, lists