Ansible

Ansible Interview Questions 4

Q40) Ansible has two types of servers. Select the appropriate answer from the given options.

  1. only node
  2. controlling machines and nodes

Answer: controlling machines and nodes

Q41) How to define the number of parallel processes while communicating to remote hosts?

  1. pipelining
  2. Forks
  3. become_method
  4. become

Answer: Forks

Q42) What is the default forks value in configuration file?

  1. 1
  2. 5
  3. 7
  4. depends upon hosts in the inventory

Answer: 5

Q43) How can you reduce the number of SSH connections required?

  1. accelerate port
  2. pipelining
  3. forks
  4. become_method

Answer: pipelining

Q44) Which configuration management is agentless

Ansible

Puppet

chef

CFEngine

Answer: Ansible

Q45) Ansible is generally referred to as what?

READ ALSO
Install VirtualBox

Infrastructure as code

Orchestration Engine

Configuration management

All the options

Answer: All the options

Q46) How would you write comments on Jinja2:

  1. {{}}
  2. {##}
  3. {%%}

Answer: {##}

Q47) What is the web-based interface used to access projects, inventories, job templates and jobs Ansible?

Answer: Ansible Tower Interface

Q48) How to Install Ansible in the Redhat Linux operating system?

Answer:

yum install ansible

Once the installation is completed, check the ansible version :

þÿ a n s i b l e v e r s i o n

If ansible package is not available in the default yum repositories, we need to manualy download.

Q49) How to set SSH-based access from Controller to Managed Nodes which is recommended by Ansible?

READ ALSO
Ansible Interview Questions 7

Answer: It provides passwordless auth to access the managed servers

In Control Server.

Step 1: Create user for ansible useradd -d /home/gangboard -m gangboard passwd gangboard

Step 2: Switch to ansible user

Step 3:þÿ s u g a n g b o a r d

Step 4: Generate ssh key ssh-keygen -t rsa

Step 5: /home/gangboard/.ssh/id_rsa.pub => Public Key is in this file which needs to be copied to nodes ~/.ssh/authorized_keys

Q50) Perform the following setps on all Managed nodes.

Answer:

Step 1: Create user for ansible useradd -d /home/tadmin -m tadmin passwd tadmin

Step 2:þÿ Switch to ansible users at admin

Step 3: Create .ssh directory mkdir .ssh

READ ALSO
SSH Keys for Amazon EC2 instances

Step 4: Change permission to 700 for .ssh chmod 700 .ssh/

Step 5: Change Ownership to tadmin for .ssh chown tadmin:tadmin .ssh/

Step 6: create an authorized_keys file under .ssh and paste the public key from controller and

save it

Step 7: cd .ssh/ , vi authorized_keys

 

Step 8: Copy & paste the public key from the Controller server to this file [/home/tadmin/.ssh/id_rsa.pub]

Now you able to access the server without a password.

Q51) What is inventory in Ansible and how to update it?

Answer:

The inventory files contain a host list of managed nodes, when ansible accessing the client it look into inventory.

READ ALSO
How to force users change password on first login Linux

The default inventory file for Ansible is located under /etc/ansible/hosts

This default inventory lookup can be overridden using -i option providingthe custom inventory file

Example: ansible -i cmdb.inv main.yml Update default Inventoryfile/etc/ansible/hosts (as rootuser) [clients]

node1

node2

Q52) How to run ansible command? Briefly explain?

Answer:

Running ansible command #ansible all -m ping

ansible => Ansible command

all => Specifies the target to run the command.The target could an individual node or group(mentionedininventoryfile)orall(allthenodesintheinventory file). In this case all is used, which means that the command will be executed on all the nodes.

-m is the option that indicates that a module needs to be executed on remote nodes

READ ALSO
Ansible Interview Questions 1

ping is the name of a module. This module checks the ping status of the remote node. It has no attribute parameter (-a)