DEV Community

Cover image for Installing Ansible on AWS EC2 Instance

Installing Ansible on AWS EC2 Instance

Here in this blog post I will show you how to install Ansible on an AWS EC2 instance.

Bellow are the pre requisites

  1. Have an AWS account
  2. Spin and EC2 instance and connect to it via ssh or directly from your aws console .

For the purpose of this post I created an aws ubuntu instance.

After connecting to your instance run the commands bellow. This will make sure that your instance is up to get and that you got access to Ansible repos for install.



sudo apt update 
sudo apt-add-repository -y ppa:ansible/ansible



Enter fullscreen mode Exit fullscreen mode

Once the steps above are done, now you may get started with the real deal by installing Ansible with the command bellow



sudo apt-get -y install ansible


Enter fullscreen mode Exit fullscreen mode

After that, Ansible will be installed on your instance . You can now check the version with the command below



ansible --version


Enter fullscreen mode Exit fullscreen mode

You will get the version of ansible installed along with the path to the configuration file.

asksouleyAnsibleVerion

Since the main goal of using Ansible is to automate our resource provisioning process, we will need to have boto3 installed. To learn more about boto3 , check my other blog post here

To install boto 3, just make sure that your instance is up to date one more time and running the command bellow



sudo apt update
sudo apt install python3-boto3


Enter fullscreen mode Exit fullscreen mode

Just to make sure, you can also check that boto is installed by running the commands bellow



Method 1: pip show boto3
Method 2: pip list
Method 3: pip list boto | greb boto


Enter fullscreen mode Exit fullscreen mode

Let me know if you like it . I tried to make it as short as possible . Next will be how to automate the creation of EC2 instance using Ansible.

Like it?
Follow me on @asksouley

Top comments (0)