Ansible Question and Ans Part1

Q1. What is Ansible ?

Answer: Anisble is configuration open source tool which is written in python Language. It is used to deploy or configure any software or tools or files on remote machines quickly using SSH Protocol.

Q2. What are advantages of Ansible.

Answer: Simple to manage, Agent less, Great Performance , Reliable.

Q3. What are the things which Ansible can do ?

Answer: Deployment of apps, configuration Management , Task automation , IT orchestration.

Q4. Is it possible to have Ansible control node on windows ?

Answer: No

Q5. What are requirements when the host is windows machine ?

Answer: Ansible needs Powershell 3.0 and atleast .NET 4.0 to be installed on windows Host. WinRM Listener should be cteayed and activated.

Q6. Where are different components of Ansible ?

Answer: API’s, Modules, Host , Playbook , Cloud, Networking and Inventories.

Q7.What are Ansible adhoc commands ?

Answer: These commands are used to take an action which is not repeatable and rarely used such as restart of machine.

ansible all -m ansible.builtin.service -a “name=apache2 state=started”

Q8. What is the ansible command to check uptime of all servers ?

Answer:

ansible all -a /usr/bin/uptime 

Q9. How to Install the Apache service using a ansible command ?

Answer:

ansible all -m apt -a  "name=apache2 state=latest" -b  
        # b is to become root and we are installation the Apache service 

Q10.What are the steps to install ansible on Ubuntu Machine ?

Answer:

  1. sudo apt update
  2. sudo apt install software-properties-common # This Package is used to work with PPA
  3. sudo apt-add-repository –yes –update ppa:ansible/ansible # PPA is Personal Package Archive ( NON Standard but used for TESTING by Organizations)
  4. sudo apt install ansible

Q11. What is fact in Ansible ?

Answer: facts are used to Fetch the information about the host and store . Ansible runs setup modules to generate this facts.

Q12. What are Ansible tasks ?

Answer: Ansible tasks are group of task which a playbook needs to perform such as copy , installing package , Edit config and restart VM etc.

Q13. What are Ansible Roles ?

Answer: Roles are basically a way to structurally maintain your playbooks ie. it lets you load the variables from files , variables , handlers , tasks from based on the structure . Similar to modules kind of thing , you can create different roles and reuse them as many times as you need.

Related : Ansible Roles

Q14. Command to create a user on remote machine using Ansible?

Answer: ansible all -m ansible.builtin.user -a “name=name password=password” -b

Q15. What is Ansible Tower ?

Answer: Ansible tower is web based solution that makes Ansible even more to easy to use for IT teams. Ansible tower can be used for upto 10 nodes. It captures all recent activities like status of host . It integrates with notification’s about all necessary updates. It also schedules Ansible Jobs very well.

Q16. How do you connect with other devices within Ansible?

Answer: After installing Ansible , configure your inventory with the list of hosts or grouping them accordingly and finally connecting them using SSH protocol. Before running your command you can test your connectivity by using ping Module.

Q17. Does Ansible support AWS?

Answer: Yes . There are lots of modules that are present in Ansible.

Q18. Which Module can copy files from remote machine to control machine ?

Answer: Fetch

Q19. Where you can find inventory by default ?

Answer: In /etc/ansible/hosts directory

Q20. How can you check Ansible version?

Answer: Looks like a very easy quesion , right but make sure you dont miss —

ansible –version