Ans: Ansible is a software tool to deploy application using ssh without sny downtime.It is also used to manage and configure software applications. Ansible is developed by Python language.
Ans: Galaxy refers to bothe website and CLI tool used to the interact with the website where you can download and share roles with other members of the ansible communty.
Ans: Forks is a way to improve your ansible performance defining how many ansible processes will be created to communicate with remote hosts.
Ans: Pipelining allows Ansible to use stream commands over a single connection instead of opening connection for each ansible command.
Ans: This allows us to create a single master connection that can be reused subsequently for a given amount of time.
Ans: This allows us to run a task without waiting for completion. You simply run the task Async and set poll=0. Later in the playbook, use async_status to check the status of the job.
Ans: You can create a variable file under group_vars. For example, lets say we want to make a variable available too the webserver host group, you simple create group_vars/webservers and define the variable inside the file.
Ans: Ansible can be used in IT infrastructure to manage and deploy software applications to remote nodes. For example, let’s say you need to deploy a single software or multiple software to 100’s of nodes by a single command, here ansible comes into picture, with the help of Ansible you can deploy as many as applications to many nodes with one single command, but you must have a little programming knowledge for understanding the ansible scripts.
We’ve compiled a series on Ansible, title ‘Preparation for the Deployment of your IT Infrastructure with Ansible IT Automation Tool‘, through parts 1-4 and covers the following topics.
Ans: You can disable facts if it its not being used to save on memory used for storing the variables created during facts/
Ans: Ansible strategies are plugins that modifies the way ansible works. For example, the linear strategy executes task on the host in series waiting for all hosts to complete before moving to next task while free moves on to next task once it finish execution on a host. For debug strategy, it executes linear but triggers debugger on failure.
Ans: Setting environment variables can be done with the environment keyword. It can be used at the task or the play level:
environment:
PATH: ":/thingy/bin"
SOME: value
Note : starting in 2.0.1 the setup task from gather_facts also inherits the environment directive from the play, you might need to use the |default filter to avoid errors if setting this at play level.
Ans: A steadfast rule is ‘always use except when when:‘. Conditionals are always run through Jinja2 as to resolve the expression, so when: failed_when: and changed_when: are always templated and you should avoid adding .
In most other cases you should always use the brackets, even if previouslly you could use variables without specifying (like with_ clauses), as this made it hard to distinguish between an undefined variable and a string.
Another rule is ‘moustaches don’t stack’. We often see this:
}}
The above DOES NOT WORK, if you need to use a dynamic variable use the hostvars or vars dictionary as appropriate:
Ans: Setting inventory variables in the inventory file is the easiest way.
Ansible 2.0 has deprecated the “ssh” from ansible_ssh_user
, ansible_ssh_host
, and ansible_ssh_port
to become ansible_user
, ansible_host
, and ansible_port
.
If you are using a version of Ansible prior to 2.0, you should continue using the older style variables (ansible_ssh_*
). These shorter variables are ignored, without warning, in older versions of Ansible.
For instance, suppose these hosts have different usernames and ports:
[webservers]
asdf.example.com ansible_port=5000 ansible_user=alice
jkl.example.com ansible_port=5001 ansible_user=bob
You can also dictate the connection type to be used, if you want:
[testcluster]
localhost ansible_connection=local
/path/to/chroot1 ansible_connection=chroot
foo.example.com ansible_connection=paramiko
You may also wish to keep these in group variables instead, or file them in a group_vars/<groupname> file. See the rest of the documentation for more information about how to organize variables
Ans: The best way to get Ansible for Ubuntu is to add the project’s PPA (personal package archive) to your system.
To do this effectively, we need to install the software-properties-common package, which will give us the ability to work with PPAs easily. (This package was called python-software-properties on older versions of Ubuntu.)
Once the package is installed, we can add the Ansible PPA by typing the following command
sudo apt-add-repository ppa:ansible/ansible
Press ENTER to accept the PPA addition.
Next, we need to refresh our system’s package index so that it is aware of the packages available in the PPA. Afterwards, we can install the software:
Ans: If this utility is not installed on your system (e.g. you are using OS X) then you can still easily generate these passwords using Python. First, ensure that the Passlib password hashing library is installed.
pip install passlib
Once the library is ready, SHA512 password values can then be generated as follows:
python -c “from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())”
Use the integrated Hashing filters to generate a hashed version of a password. You shouldn’t put plaintext passwords in your playbook or host_vars; instead, use Vault to encrypt sensitive data.