Ansible for an absolute beginner — part 2

vikas yadav
DevOps Dudes
Published in
2 min readMar 28, 2019

Making automation easy

Welcome to part 2 of this series!

If you haven't read part 1, I suggest you start there. I explain some key concepts like DevOps, Automation, etc and some common terms in Ansible.

Now, in this part, we will set up our lab environment, we need three virtual machines, the first will be our ansible controller and then two virtual machines that act as our managed systems. Here is an image of the lab we are trying to set up.

Once you have the lab ready, log in to the ansible master server and run the following piece of code to install ansible on the controller.

#The following code will add Ansible repository on the system
apt-add-repository ppa:ansible/ansible

#The following code will update system
apt update -y

#The following code will install ansible on the system
apt install ansible -y

#The following code will display the version of ansible installed
ansible --version

I have created a script which you can download and run on your controller.

Now, on the client machines, we will need to do three things

  1. Setup open-ssh
  2. Allow ssh through the firewall
  3. Install python as some modules require python to be installed on the remote machine
#The following code will install openssh-server on the client
apt install openssh-server -y

#The following code will allow firewall port 22
ufw allow ssh

#The following code will install python
apt install python -y

Here is the script you can run on the remote machines as well.

I hope you were able to set up your lab by following these instructions, you can also look at my youtube video for instructions. please feel free to have a look at it.

Click here to read part 3 of this story

To know more about YAML check my story Write your first YAML.

I have a youtube channel where I upload high-quality IT-related content for free. Please feel free to have a look at my other free courses and subscribe to my channel.

Here is a link to my free 3-hour Ansible masterclass on youtube.

If you wanna learn advanced concepts of Ansible such as different types of variables and how to use them, setting your own event handling system in Ansible, etc, here is a heavily discounted coupon for my course on Udemy “Ansible for an absolute beginner”.

--

--

vikas yadav
DevOps Dudes

IT engineer with 14 years of experience in IT with recent experience in Solution design, Big data, and log analytics.