Setup Ansible Nodes on Linux (Ubuntu 14.04)

In my last post, you learnt about Ansible & how to install it. Now, lets take one step forward and setup the nodes that Ansible will manage. As we know, Ansible is agent-less hence it doesn’t need any client package to be installed on the nodes it will manage. So, we only need to define the nodes in its inventory file on Ansible server itself located at /etc/ansible/hosts

Backup this file & edit it with below contents.


You can see I have defined a group called web-servers that contains IP address of 2 nodes. You can also use FQDN if you have DNS setup or entries in /etc/hosts file

Save this file & issue below command to test if Ansible server is able to ping the nodes or not.

shashank@shashank-server:~$ ansible -m ping web --ask-pass
SSH password: | FAILED! => {
"failed": true,
"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."
} | SUCCESS => {
"changed": false,
"ping": "pong"

You can see, it results in an error for one node. Because Ansible server’s fingerprint was not in known_hosts file of that node. For this, you need to add that manually or by first trying to SSH into node. That way it will ask to save the fingerprint & above command will work.

shashank@shashank-server:~$ ansible -m ping web --ask-pass
SSH password: | SUCCESS => {
"changed": false,
"ping": "pong"
} | SUCCESS => {
"changed": false,
"ping": "pong"

So, you can see now that Ansbile is able to ping its nodes & hence it can manage these 🙂

One thing to note is that Ansible will SSH into the nodes using the user with which it was run. I ran Ansible using shashank user which is a user with root access. So, make sure you have enough privileges to run Ansible. You can get away with using --ask-pass if you use keys instead of password. You can follow this link to know how to setup password-less SSH

shashank@shashank-server:~$ ansible -m ping web | SUCCESS => {
"changed": false,
"ping": "pong"
} | SUCCESS => {
"changed": false,
"ping": "pong"

You can see above that, since I have password-less SSH setup, I don’t need to use --ask-pass option.

Install Ansible on Linux (Ubuntu 14.04)

Ansible is a really (radically, as they say) simple server orchestration/configuration manager/provisioning solution just like Chef, Puppet or Salt. While Chef, Puppet or Salt are extremely powerful & efficient, they are quite difficult to learn or manage and that’s what makes admin afraid of them 😀

Ansible, on the other hand, is pretty simple to use. Its commands are executed via CLI or terminal & it uses SSH connection (Ansible is agent-less) as compared to Chef, Puppet or Salt that are agent-based. In this tutorial we will see how to install Ansible on an Ubuntu 14.04 server 🙂

Issue below commands to add Ansible repository & install it.

root@shashank-server:/home/shashank#  apt-add-repository -y ppa:ansible/ansible
root@shashank-server:/home/shashank#  apt-get update
root@shashank-server:/home/shashank#  apt-get install -y ansible

This will install Ansible on your machine. Now, in my next post(s) I will demonstrate how we can define the hosts for it. Stay tuned till then 😉

Bootstrapping Chef Node To Manage Under Chef Server

So, the last post discussed about setting up Chef clients. Now its time to finish the overall setup by bootstrapping the Chef nodes from Chef Workstation.

Bootstrapping means we are syncing the Chef clients with the Chef workstation so that we can create & execute cookbooks from the workstation. Remember that is the IP of Chef client/node. Replace the IP for all the nodes you want to manage & repeat this step. --node-name is the name you want to give to your node. Its NOT necessarily the actual hostname. I used sudo because it didn’t connect without it. Replace shashank with your username.

root@chef-workstation:/home/shashank/chef-repo# knife bootstrap -x shashank --sudo --node-name node1
Doing old-style registration with the validation key at /home/shashank/chef-repo/.chef/chef-validator.pem...
Delete your validation key in order to use your user credentials instead

Connecting to
shashank@'s password: knife sudo password:
Enter your password: -----> Existing Chef installation detected Starting the first Chef Client run... Starting Chef Client, version 12.6.0 Creating a new client identity for node1 using the validator key. resolving cookbooks for run list: [] Synchronizing Cookbooks: Compiling Cookbooks... [2016-05-21T09:28:51+05:30] WARN: Node node1 has an empty run list. Converging 0 resources Running handlers: Running handlers complete Chef Client finished, 0/0 resources updated in 01 seconds

You can see the list of all managed/bootstrapped nodes by issuing below command.

root@chef-workstation:/home/shashank/chef-repo# knife node list

Below is the screenshot from my setup 🙂

Chef Nodes Bootstrapped

In future posts, I will explain how we can manage Chef nodes & how to create cookbooks. Till then, bye 🙂

Setup Chef Node(s) on Linux (Ubuntu)

In my last 2 posts, I had explained how to install Chef Server & how to setup Chef Workstation. Hope that was easy & informative for you 🙂

In this post, we will learn how to setup the nodes that we want to be managed by Chef. Read on!

There are only 2 steps here. Downloading the client package & installing it. Repeat these steps on all the nodes that you want Chef to manage.

Download Chef Client package from

Install it as below.

root@node1:/home/shashank# dpkg -i /media/sf_Chef_Downloads/chef_12.6.0-1_amd64.deb
Selecting previously unselected package chef.
(Reading database ... 166222 files and directories currently installed.)
Preparing to unpack .../chef_12.6.0-1_amd64.deb ...
Unpacking chef (12.6.0-1) ...
Setting up chef (12.6.0-1) ...
Thank you for installing Chef!

This will setup your Chef client. To manage it using Chef, it has to be bootstrapped. How to do it? I will leave it for the next post 😉 Stay tuned 🙂