Ansible Concepts Flashcards
what is the parameter ansible_host?
“ansible_host” is a inventory parameter, that is used to specify the host IP address or the FQDN
List all the ansible inventory parameters?
ansible_host - IP address of the host
ansible_connection - ssh/winrm/localhost
ansible_port - 29/5986
ansible_user - root/administrator
ansible_ssh_pass - Password
In what format are the ansible playbooks written in?
YAML. A playbook is a single YAML file containing a set of plays
What is a play in Ansible playbook?
Play defines a set of activities (tasks) to be performed on a hosts or group of hosts
What is a task (activity) in the definition of play in playbook?
Task is an action to be performed in a host or group of hosts. Eg.
Execute a command
Run a script
Install a package
Shutdown/restart
Can you give an example of a playbook.yaml file?
- name: play1
host: localhost
tasks:- name: Execute command ‘date’
command: date - name: Execute this script on the server
script: test_script.sh - name: Install httpd server
yum:
name: httpd
state: present - name: start web server
service:
name: httpd
state: started
- name: Execute command ‘date’
What is the relation between the inventory file and the playbook.yml file?
The host name entered in the inventory file must match the host key value in the playbook yaml file
How do you execute an ansible playbook?
ansible-playbook <playbook>
eg. ansible-playbook playbook.yaml</playbook>
what are the 4 importants ansible concepts?
Ansible Inventory
Ansible playbooks
Ansible module
Ansible variables
List some examples of Ansible Modules?
system
command
files
database
cloud
windows
what is command module used for?
Command module is used to execute scripts, and run commands
what is service module used for?
Maintaining the services in the system, like starting stopping
What are variables in ansible?
Variables are used to store information that varies with each host