Q40) Ansible has two types of servers. Select the appropriate answer from the given options.
- only node
- controlling machines and nodes
Answer: controlling machines and nodes
Q41) How to define the number of parallel processes while communicating to remote hosts?
Answer: Forks
Q42) What is the default forks value in configuration file?
- 1
- 5
- 7
- depends upon hosts in the inventory
Answer: 5
Q43) How can you reduce the number of SSH connections required?
- accelerate port
- pipelining
- forks
- become_method
Answer: pipelining
Q44) Which configuration management is agentless
Puppet
chef
CFEngine
Answer: Ansible
Q45) Ansible is generally referred to as what?
Infrastructure as code
Orchestration Engine
Configuration management
All the options
Answer: All the options
Q46) How would you write comments on Jinja2:
- {{}}
- {##}
- {%%}
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?
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
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.
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
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
ping is the name of a module. This module checks the ping status of the remote node. It has no attribute parameter (-a)