Joshua Cruz

An Ansible Series

March 14, 2020

https://www.mindbowser.com/create-ec2-instances-using-ansible/

Introduction

This series goes heavily focuses on the provisioning of services through the use of Ansible. DigitalOcean is used to create droplets to spin up various virtual machines to get familiar with Ansible Playbooks.

This part of the series will be short because we’re just getting our hosts set up and ensuring they are live and functioning with the use ofansible.

Prerequisites

Creating our Droplets

DigitalOcean (DO) is a neat service that allows you to pay a flat fee per month to create virtual machine (droplet) on their infrastructure. The great thing is that it’s super simple and easy do.

Getting Started

Ubuntu server specs

SSH Key

Finalizing Droplets

Droplets live

Building our inventory

The way ansible works is that it manages multiple nodes (hosts) in your infrastructure. Listing all of our nodes is needed in order to communicate against them with Ansible. So, we need to edit Ansible’s hosts file (/etc/ansbile/hosts), with the IP addresses that DO assigned to the three droplets we created.

Ansible hosts

Here you can see I assigned each of the three droplets a simpler name (ubuntu-tor-0x) along with the user needed when SSH-ing into the server.

Verifying all hosts

Now that all edited our inventory, we can do a write a command to list all hosts in the inventory file in YAML formal

List hosts

There you go, we quickly verified that all hosts have a unique name, with their ip address, and python interpreter enabled.

Pinging all hosts

After successfully verfying the inventory file, we can use ansible to ping all hosts, instead of pinging each host indivindually.

List hosts

With a simple ansible command, we quickly verified that all hosts are pingable

Conclusion

This part of the series, we used DigialOcean to create droplets (virtual machines) where we utilized ansible simply manage multiple droplets at once. We configured inventory files with ip addresses, and verified they were all functioning correctly.