1. What is Ansible?

Ans:Ansible is an IT automation tool.

2. What is the use of Ansible?

Ans: Configure System, deploy software and orchestrate more advanced IT
tasks.

3. What is the goal of the Ansible?

Ans: Simplicity, Security, and Ease of use.

4. How to install the the ansible on Ubuntu ?

Ans: Step 1: Update the System
Command: sudo apt-get update
Step 2: Install software-properties-common
Command: sudo apt-get install software-properties-common
Step 3: Add repository
Command: sudo apt-add-repository ppa:ansible/ansible
Step 4: Update the system
Command: sudo apt-get update
Step 5: Install Ansible
Command: sudo apt-get install ansible

5. What is the filename where we store all the hosts ip ?

Ans: /etc/ansible/hosts

6. In which folder of the remote hosts we need to store the public key of
the controlling machine ?

Ans: authorized_keys

7. How to check the connectivity of all the nodes ?

Ans: Command: ansible all -m ping

8. How to disable the host_key_checking ?

Ans: Step1: Open the configuration file /etc/ansible/ansible.cfg and edit as
below : [defaults]
host_key_checking = False

9. What ansible tower provides ?

Ans: Provides a robust data logging feature.

10. In Ansible, Is it possible to use multiple inventory files at the same
time ?

Ans: Yes

 

11. How to specify host with port number ?

Ans: Edit /etc/ansible/hosts with below details :
hostnameorIP-details:5606

12. How to specify the host using variables ?

Ans: Edit /etc/ansible/hosts with below details:
jumper ansible_port=5555 ansible_host=192.0.2.51

13. Suppose if we are adding lots of host with similar pattern, then how
you specify in the configuration file /etc/ansible/hosts ?

Ans: Edit /etc/ansible/hosts with below details :
www[01:50].example.com

14. How to specify the connection type and username along with the
hostname ?

Ans: Edit /etc/ansible/hosts with below details :
host-name ansible_connection=ssh ansible_user=mohan

15. How to specify the variables to entire group ?

Ans: Edit the /etc/ansible/hosts with below details :
[atlanta:vars]
ntp_server=hostname or IP
proxy=hostname or IP

16. How many types of SSH protocol exist in the ansible_connection?
Which one is a default ?

Ans: SSH protocol types are :
1. smart
2. ssh
3. paramiko
The default is ssh.

17. What is the name of the connector which is used to deploy the
playbook to the control machine itself?

Ans: local

18. what is the name of the connector which is used to deploys the
playbook directly into docker containers using the local docker client?
What are the parameters are processed by this container?

Ans: docker
Parameters list are as follows :
1. ansible_host: The name of the docker container to connect to.
2. ansible_user: The username to operate within the container.
3. ansible_become: if set to true the become_user will be used to operate
within the container. 4. ansible_docker_extra_args: mainly used to configure
a remote docker daemon to use.

19. What is the use of the patterns in ansible?

Ans: meaning of pattern in ansible is how we decide which hosts to manage.
Syntax: ansible <pattern_goes_here> -m <module_name> -a <arguments>

20. How to manage the individual host-names or IP and group using
wildcards?

Ans: Syntax: *.example.com , *.com

21. What is an ad-hoc command?

Ans: An ad-hoc command is something that you might type in to do
something really quick, but don’t want to save for later.

22. Why we use ad-hoc command instead of the playbook?

Ans: Suppose if you wanted to power off all your lab for New year vacation,
you could execute a quick one-liner in Ansible without writing a playbook.

23. How to setup SSH-agent so it can remember our credentials ?

Ans: Command: ssh-agent bash Command: ssh-add ~/.ssh/id_rsa

24. How to reboot all the system in a group ?

Ans: Command: ansible groupname -a “/sbin/reboot” -f 10

25. How to transfer a file to multiple servers ?

Ans: Command: ansible groupname -m copy -a “src=/etc/hosts
dest=/tmp/hosts”

26. Is it possible to assign the permission mode of the remote host?

Ans:
Command: ansible webservers -m file -a “dest=/srv/foo/filename.txt
mode=600”

27. How to create or delete directories in the multiple hosts ?

Ans:
1. Create
Command:
ansible groupname -m file -a “dest=/path/ owner=name group=name
state=directory”
2. Delete
Command:
ansible groupname -m file -a “dest=/path state=absent”

28. How to check whether package is installed or not ?

Ans:
Command: ansible groupname -m yum -a “name=acme state=present”

29.How to remove the user of the same name from the multiple hosts ?

Ans:
Command:
ansible all -m user -a “name=user-name state=absent”

30. How to check whether the service is started or not on all the
webservers ?

Ans:
Command:
ansible webservers -m service -a “name=httpd state=started”

31. How to setup the background operations and check the status of the
background job ?

Ans:
Command:
ansible all -B 3600 -P 0 -a “command”
-B: background timeout : 3600
Command:
ansible group-name -m aync_status -a “Jid=number”

32. How to gather ad-hoc information about your system ?

Ans: Command: ansible all -m setup

33. What is the role of action_plugins in ansible?

Ans: Actions are a piece of code in ansible that enables things like module
execution and templating.

34. Is it possible to configure the settings via environment variables?

Ans: True

35. What is the name of the configuration file of ansible?

Ans: /etc/ansible/ansible.cfg

36. How to control whether an ansible playbook should prompt for a
password or not?

Ans: Edit with below details in the /etc/ansible/ansible.cfg
ask_pass = True

37. How to control whether an ansible playbook should prompt for a
sudo password or not?

Ans: Edit with below details in the /etc/ansible/ansible.cfg
ask_sudo_pass = True

38. How to control whether an ansible playbook should prompt for the
vault password or not?

Ans: Edit with below details in the /etc/ansible/ansible.cfg
ask_vault_pass = True

39. What is the name of the plugins which is used to log activity from the
command line and send notifications?

Ans: bin_ansible_callbacks

40. How to disable the deprecating warnings?

Ans: Edit with below details in the /etc/ansible/ansible.cfg
deprecation_warnings = True

41. Using which option we can run parallel processes to spawn when
communicating with remote hosts?

Ans: Edit the /etc/ansible/ansible.cfg
fork = 5

42. How to configure fact caching and where to cache facts?

Ans: Edit the /etc/ansible/ansible.cfg
fact_caching = jsonfile
Edit the /etc/ansible/ansible.cfg
fact_caching_connection = localhost:6379:0

43. Suppose if you want to collect all the information of the remote host
then how to do?

Ans: Edit the /etc/ansible/ansible.cfg
gather_subset = !all

44. what would happen if we keep the value of internal_poll_interval
high?

Ans: CPU load increase

45. What is the default location where ansible looks for modules?

Ans: library = /usr/share/ansible

46. Where the ansible log exist?

Ans: /var/log/ansible.log

47. Is it true command module doesn’t support shell variables, pipes or
quotes?

Ans: True

48. What is the default location ansible looks to find module_utils?

Ans: module_utils = /usr/share/ansible/my_module_utils

49. How to set private_key_file option?

Ans: Edit the /etc/ansible/ansible.cfg
private_key_file=/path/to/file.pem

50. Is it possible to change the default port of the ssh of all the host?

Ans: Edit the /etc/ansible/ansible.cfg
remote_port = 22

51. How to disable the warnings related to the potential issues on the
system running ansible (controlled host)?

Ans: Edit the /etc/ansible/ansible.cfg
Syntax: system_warnings = True

52. What is the default ssh timeout to use on connection attempts?

Ans: Edit the /etc/ansible/ansible.cfg
Syntax: timeout = 10

53. Suppose if you wanted to test against a server with a self-signed
certificate?

Ans : Edit the /etc/ansible/ansible.cfg
Syntax: ignore_certs = true

54. Is it true most versions of the sshpass do not deal particularly well
with BSD login prompts? If yes, what is the solution to this problem?

Ans: True
Change the transport method to paramiko.
Edit the /etc/ansible/ansible.cfg with below details :
[freebsd]
mybsdhost1 ansible_connection=paramiko

55. What is the name of the package which is required for full
functionality of ansible in BSD?How to install on BSD remote machine?

Ans: python 2.7
Command: ansible -m raw -a “pkg install -y python27” mybsdhost1

56. Is it true binary location of python is different in BSD? If yes then
what is the location and how to edit it?

Ans: True
Edit /etc/ansible/ansible.cfg with below details
[freebsd:vars]
ansible_python_interpreter=/usr/local/bin/python2.7

57. What is provider argument in ansible?

Ans: It is a collection of arguments used to define the characteristics of how
to connect to the device.

58. What are the basic arguments required by core network module to
configure the transport?

Ans: 1. host information of the remote host
2. port information of the remote host
3. username defines the username to use to authenticate the connection
4. password defines the password to use to authenticate the connection
5. transport defines the type of connection transport to build
6. authorize enables privilege escalation for devices that require it
7. auth_pass defines the password #if needed for privilege escalation

59. What are the networking environment variables?

Ans: The networking environment variables are as follows :
1. username ANSIBLE_NET_USERNAME
2. password ANSIBLE_NET_PASSWORD
3. ssh_keyfile ANSIBLE_NET_SSH_KEYFILE
4. authorize ANSIBLE_NET_AUTHORIZE 5. auth_pass
ANSIBLE_NET_AUTH_PASS

60. How many types of conditionals exist in Networking modules?

Ans: 1. eq – Equal
2. neq – Not equal
3. gt – Greater than
4. lt- less than
5. le – less than or equal
6. contains – Object contains specified item