Introduction Flashcards
In what file do you specify information about servers that have to be managed by Ansible?
inventory file
What is the command for running playbooks?
ansible-playbook
What is ansible command for ad-hoc execution of commands?
ansible -i hosts -m ping
In what order does ansible look for config file?
1) ANSIBLE_CONFIG env variable
2) ./ansible.cfg (current directory)
3) ~/.ansible.cfg (home folder)
4) /etc/ansible/ansible.cfg (Installation directory)
(ECHI)
What is the prefered location for ansible config file?
current directory alongside playbooks
Why put ansible config files alonside playbooks?
So they can be version controlled
Example of variables that can be defined in ansible config file
1) Location of inventory file
2) User to SSH
3) SSH private keys
What is the default location of ansible config?
/etc/ansible/ansible.cfg
Command module for check uptime on testserver
ansible testserver -m command -a uptime
Explain: ansible testserver -a uptime
Execute the command module to check uptime of remote server: testserver. -m command is ommitted because the command module is very often used.
When running the command module what is the -b flag used for?
become root and run the command in priviledged mode
What is a playbook?
An ansible configuration management script
What is the very first line of a playbook?
three dash: —
Strings in YAML?
1) “This is a string”
2) This is also a string
Comments in YAML
This is a comment
Booleans in YAML
true, True, TRUE, yes, Yes, YES, on, On, ON, y, Y
false, False, FALSE, no, No, NO, off, Off, OFF, n, N
List in Ansible
- One
- Two
- Three
or
[One, Two, Three]
Dictrionary or Mapping in Ansible
address: 742 Evergreen Terrace
city: Vancouver
state: North Dakota