Ansible Flashcards
What is Ansible and how it works?
Ansible is an open-source software platform for automating and configuring computer systems. It is designed to help administrators and developers automate system administration tasks, such as configuration management, application deployment, and provisioning.
What have you done with Ansible?
Installed ansible on control node.
Added host in inventory
Configured ansible.cfg (custom inventory and playbook)
Ran ad-hoc commands
Created ansible playbooks for automation
How would you convince you manager that provisioning with Ansible is beneficial for the company?
Free: ansible is an open source tool.
Very simple to set up and use: no special coding skills are necessary to use ansible’s playbooks.
Powerful: ansible lets you model even in highly complex IT workflows.
Fexible: you can orchestrate the entire application environment no matter where its deployed. You can also customize it based on your needs.
Agentless: you don’t need to install any other software or firewall ports on the client’s systems you want to automate. You also don’t have to set up a separate management structure.
Efficient because you do’t need to install any extra software. There’s more room for applications resources on your server.
How Ansible control node manages the manage nodes?
through ssh
How we can list all the hosts that ansible is managing?
ansible all - -list-host
Can you describe idempotancy?
Is the ability to execute an operation several times which provides same results. Meaning if its run once or multiple times.
Can you give me name of modules you worked with?
Package management , service, copy, debug, lineinfile, users.
How to manage your Ansible hosts?
Create an inventory with is by default /etc/ansible/hosts where we mention different group for managed nodes. We can create our customized inventory file anywhere and we call that inventory file. Ansible uses ssh to communicate with the mentioned inventory.
What is the path to the Ansible configuration file?
/etc/ansible/ansible.cfg
How to check Ansible version?
ansible - -version
How do you maintain Ansible inventory?
The inventory can be specified in a variety of formats, including a simple list of host names or IP addresses, a group of host names or IP addresses, or a more complex configuration that specifies multiple groups of hosts and their associated variables.
Static inventory or dynamic inventory
What is static inventory?
static inventory file is a plain text file containing a list of managed hosts or remote nodes whose numbers and IP addresses fairly constant.
What is dynamic inventory?
Dynamic host file is being updated right away in a shell script when the hosts are being decommissioned
Do you know difference between notify and register?
Notify tells the handlers that the tasks has been changed and the handlers will perform the task.
The register is a way to capture the output from the task execution and stores it into a variable.
What is the difference between job templates and projects in tower?
job templates are used to define and execute specific tasks, while projects are used to organize and manage the files and artifacts that are required to execute those tasks.
What are things you automated through Ansible?
configuration of systems, such as installing and configuring software, setting up users and groups, and modifying system settings.
What is dry run?
A dry run is when all of the tasks defined in the playbook will be checked against all of the hosts but none of them will actually ran
What is ansible galaxy?
Is a way to run a single ansible task quickly on all your managed notes.
You may want to run the ad-hoc command to edit some configuration files, stop/start service on your remote machines update particular package, shutdown set of hosts or to collect some info such as uptime on all your servers.
Can you define roles in ansible?
Roles are really just a way to split up your playbook into smaller reusable parts. It also simplifies playbooks since you only have to create minimal playbooks.
By default, Ansible looks for roles in the roles subdirectory relative to the playbook file or the system directory /etc/ansible/roles . You can also use the Ansible configuration roles_path to define alternative role locations. You can also include the role in the playbook using the module include_role.
Can you tell me how to use inventory file in Ansible?
-i
Ansible - I ansible all -m ping
What is Ad-hoc command why it is really needed?
Is a way to run a single ansible task quickly on all your managed notes.
You may want to run the ad-hoc command to edit some configuration files, stop/start service on your remote machines update particular package, shutdown set of hosts or to collect some info such as uptime on all your servers.
Why we don’t go with play book and we use Ad-hoc commands preferably?
Ad-hoc command is useful to perform quickly task but it has limited usage.
Have you heard about tags in environment?
Tags in playbooks allow you to selectively target certain tasks at run time. For example:
Tag:users it will run only that.
Can you go over little bit about Ansible tower?
Ansible by itself is a command line tool.
Ansible Tower is a framework for Ansible.
It is a web-based solution that provides a Graphical User Interface (GUI). It reduces the dependency on the command line prompt window.
It is easy to use and makes it easy for non developers to create the environment they want.
Tasks can now be performed in a single click instead of typing long commands.
Ansible Tower dashboard shows hosts, inventory, and projects.
What have you done with Ansible tower?
Managing credentials, managing job templates and job workflows. Simple task adding users, resetting users passwords.
Are you familiar with the concept of vars? How we use them?
Vars are variables, we define most of the time on the play level. we can use these variables later in our playbook. We call it in different tasks.
If you want to register the output of a task in your playbook. How do you do that?
Register is the way to capture the output of a task execution and store it in a variable.
Register: (register name)
If I want to push list of packages, which are not segregated and want to run on all machines as RHEL 6, RHEL 7 & RHEL 8 packages get install on respective machines?
Use WHEN module and use the following ansible_distribution= “” and ansible_distribution_major_version=”” variables defined in gather facts .
defined to reel 6, rhel7, rhel8