Ansible Flashcards
[Ansible]
What flag limits the (ansible) playbook?
-l
[Ansible]
How to run a YAML file on all host in stage inventory?
-l [specify inventory file]
[Ansible]
Whats the name of the term/condition that only allows you to do things when certain conditions are met?
When
[Ansible]
What is ansible?
& how do you use it?
It is a configuration management tool, that allows us to automate repetitive tasks & ensure consistency across servers.
[Ansible]
[Get clarity on the best way to answer this]
What’s the difference between an ansible playbook, role, and task?
playbook= a YAML file containing plays (a set of tasks) that define the automation steps
role= a structured way to organize playbooks into smaller, reusable & more manageable units (contains task, variables, templates, file and handlers)
task= a single action that can executed on a remote system (example: installing a package or starting a service)
[Ansible]
What flag runs the playbook but doesn’t apply it?
–check
[Ansible]
What flag limits the playbook to a specific host?
-l
[Ansible]
How to run a playbook on all host in stage inventory?
-l [specify host]
[Ansible]
What are the benefits of Ansible’s item potency?
Ansible checks the deltas & will only change things that need to be changed so that you can run it multiple times on the same system.
[Ansible] [Get clarity]
If installing a package & writing a task what Ansible module would you use?
YUM (RHEL7)
or
DNF (RHEL8)
[Ansible] [Need clarity]
What is the general design of a playbook?
Starts with — to indicate a YAML document.
- name: (of play)
host: (target machines or group [from inventory file])
become: (need to run play as root?)vars: (defines reusable names/values)
package_name: (ie: httpd)tasks:
- name: (name of task)
Defines reusable values.
Example:
yaml
Copy
Edit
vars:
package_name: httpd
Tasks (tasks)
The core of the playbook, executing actions using Ansible modules.
Example:
yaml
Copy
Edit
- name: Install Apache
yum:
name: httpd
state: present
Handlers (handlers)
Triggered by tasks (e.g., restart a service after configuration changes).
Example:
yaml
Copy
Edit
handlers:
- name: Restart Apache
systemd:
name: httpd
state: restarted
Roles (roles)
Organizes tasks, variables, templates, and handlers into reusable components.
Conditional Execution (when)
Runs tasks only if conditions are met.
[Ansible]
How does Ansible leverage Jinga2?
for template processing and enables the dynamic insertion of data into files based on variables and logic defined in your playbooks.
[Ansible]
Typically, where is the main playbook stored?
/default
[Ansible]
Where are the variables for /etc/chrony.conf stored?
in main.yaml
[Ansible]
Where are the templates stored?
in /etc/chrony.conf
[Ansible]
What file controls all the configurations?
/main.yaml
[Ansible]
What flag gives an in-depth breakdown of the play/processes being ran?
-v OR -vvv (verbose)
[Ansible]
Where is the Ansible config file located?
/etc/ansible/ansible.cfg