Ansible with AWS and EC2 - DZone DevOps

Ansible with AWS and EC2 - DZone DevOps

Let's get our hands dirty with Ansible and tasks using AWS EC2. We'll go over how to install and remove a package using Ansible.

A few months ago, I did some RnD tasks using ansible at VizuaMatix. After that I didn't use Ansible for anything useful, today I got a YouTube suggestion for ansible again. After watching it I thought, I should get my hands dirty again with Ansible. I decided to do some Ansible tasks using AWS EC2.

For this, I have used a master node and a worker node. Both running Ubuntu 18.04.4 And the task was very simple. Install the VLC media player in our worker node, and then removing it.

First thing first, we must have Ansible installed in master and worker/s. To install just use :

sudo apt install ansible

Then we need to share our master’s public-key to worker/s. We create a ssh key from the master node and share it with worker node/s.

ssh-keygen -t rsa -N “” -f /home/ubuntu/.ssh/id_rsa

Then cat and copy the content cat .ssh/

Go to worker/s terminal and vim ~/.ssh/authorized_keys paste the content at the bottom of this file, save and exit. This step was explained here.

and check the connectivity, from master node try :

If our key sharing is successful, then you should be able to login to the worker node without any password.

Then let's add our worker node/s to ansible. In master node, open /etc/ansible/hosts the file and add a group to it. Here I have named it as [workers] . Now onward, when you specify workers in your playbook, ansible knows what hosts to use when running the playbook.


Save and then let's try to ping our worker node/s : ansible workers -m ping

devops aws ansible

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Extend your DevOps Strategy For Success in the Cloud?

DevOps and Cloud computing are joined at the hip, now that fact is well appreciated by the organizations that engaged in SaaS cloud and developed applications in the Cloud. During the COVID crisis period, most of the organizations have started using cloud computing services and implementing a cloud-first strategy to establish their remote operations. Similarly, the extended DevOps strategy will make the development process more agile with automated test cases.

AWS DevOps: Introduction to DevOps on AWS

AWS DevOps: Introduction to DevOps on AWS

What Is DevOps and Is Enterprise DevOps Any Good?

What is DevOps? How are organizations transitioning to DevOps? Is it possible for organizations to shift to enterprise DevOps? Read more to find out!

DevOps with AWS Tutorial | AWS DevOps for Beginners

You will be understanding the various DevOps Tools and their deployment on AWS Cloud. Towards the end, we'll also be doing a hands-on to put all this knowledge into action!

DevOps Basics: What You Should Know

What is DevOps? What are the goals it helps achieves? What are its benefits? This article has answers!