Skip to main content

Do You Know How to Install Ansible on 64-bit Ubuntu 14.04 server

You just need to follow below steps:

Step 1: Install the software-properties-common package

$ sudo apt-get update && sudo apt-get install software-properties-common

 

Step 2: Add the Ansible repository to your system

$ sudo apt-add-repository ppa:ansible/ansible

Step 3: Install Ansible

$ sudo apt-get update && sudo apt-get install ansible


Configuring Ansible Hosts

Ansible keeps track of all of the servers that it knows about through a “hosts” file. We need to set up this file first before we can begin to communicate with our other computers.

Open the file with root privileges like this:


  • sudo nano /etc/ansible/hosts
 

You will see a file that has a lot of example configurations, none of which will actually work for us since these hosts are made up. So to start, let’s comment out all of the lines in this file by adding a “#” before each line.

We will keep these examples in the file to help us with configuration if we want to implement more complex scenarios in the future.

Once all of the lines are commented out, we can begin adding our actual hosts.

The hosts file is fairly flexible and can be configured in a few different ways. The syntax we are going to use though looks something like this:

Example hosts file
[group_name]
alias ansible_ssh_host=your_server_ip
 


The group_name is an organizational tag that lets you refer to any servers listed under it with one word. The alias is just a name to refer to that server.

So in our scenario, we are imagining that we have three servers we are going to control with Ansible. These servers are accessible from the Ansible droplet by typing:

  • ssh root@your_server_ip
 
You should not be prompted for a password if you have set this up correctly. We will assume that our droplets’ IP addresses are 172.0.12.1, 172.0.12.2, and 172.0.12.3. We will set this up so that we can refer to these individually as host1, host2, and host3, or as a group as droplets.

This is the block that we should add to our hosts file to accomplish this:
[droplets]
host1 ansible_ssh_host=172.0.12.1
host2 ansible_ssh_host=172.0.12.2
host3 ansible_ssh_host=172.0.10.3

Hosts can be in multiple groups and groups can configure parameters for all of their members. Let’s try this out now.

With our current settings, if we tried to connect to any of these hosts with Ansible, the command would fail (assuming you are not operating as the root user). This is because your SSH key is embedded for the root user on the remote systems and Ansible will by default try to connect as your current user. A connection attempt will get this error:

Ansible connection error
host1 | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
 


On my Ansible computer, I’m using a user called demo. Ansible will try to connect to each host with ssh demo@server. This will not work if the demo user is not on the remote system.

We can create a file that tells all of the servers in the “droplets” group to connect using the root user.

To do this, we will create a directory in the Ansible configuration structure called group_vars. Within this folder, we can create YAML-formatted files for each group we want to configure:

  • sudo mkdir /etc/ansible/group_vars
  • sudo nano /etc/ansible/group_vars/droplets
 


We can put our configuration in here. YAML files start with “—”, so make sure you don’t forget that part.

/etc/ansible/group_vars/droplets
---
ansible_ssh_user: root
 

Save and close this file when you are finished.

If you want to specify configuration details for every server, regardless of group association, you can put those details in a file at /etc/ansible/group_vars/all. Individual hosts can be configured by creating files under a directory at /etc/ansible/host_vars.



















Comments

  1. Thanks for the information.
    https://www.igrowsoft.com/sap-grc-training-in-hyderabad.php

    ReplyDelete

Post a Comment

Popular posts from this blog

What is STP? - Explain Advantages and Disadvantages

The Spanning Tree Protocol is a network protocol that builds a loop-free logical topology for Ethernet networks. The basic function of STP is to prevent bridge loops and the broadcast radiation that results from them. STP is a protocol. It actively monitors all links of the network. To finds a redundant link, it uses an algorithm, known as the STA (spanning-tree algorithm). The STA algorithm first creates a topology database then it finds and disables the redundant links. Once redundant links are disabled, only the STP-chosen links remain active. If a new link is added or an existing link is removed, the STP re-runs the STA algorithm and re-adjusts all links to reflect the change. STP (Spanning Tree Protocol) automatically removes layer 2 switching loops by shutting down the redundant links. A redundant link is an additional link between two switches. A redundant link is usually created for backup purposes. Just like every coin has two sides, a redundant link, along with...

How to Reset Steam Password? – Recover Your Steam Password

Are you suffering with Reset Steam Password? This blog will help you. What is Steam? Steam is the online website for getting the best games for paid. If you are a true game lover then you should have an active account on Steam. Many of people lost their password during the  PC clean-up  or any other circumstances. At that time they have to reset Password of all accounts. Then if you facing issues with the password, you forced to Steam reset password to access the Steam account. We are going to share the guide that how to recover your forgotten Steam Password and make your existing account ready. First of all, you should have enough knowledge about what is Steam and why Steam Account required? Why Steam Account Requires? Before jump into password recovery and Login details, let me clear about why Steam Account required? There are several benefits of this Steam Account from where you can easily download PC games as well as software. Though it will be p...