Skip to content
 

Automating Infrastructure Deployments (IAAS) in AWS Cloud with Ansible

Author: Kalapriya Kolappan, on Aug 13, 2019

Automating Infrastructure Deployments (IAAS) in AWS Cloud with Ansible

 

The world is moving towards automation and automation with Ansible makes organizational operations easier while managing company-wide infrastructure.

Ansible is a free-to-use open source automation language. Ansible can help us with various activities related to configuration management, application deployment and task automation. It can also do IT orchestration, where you have to run tasks in sequence and create a chain of events that must happen on several different servers or devices. So, in short, you can handle complex tasks with a tool, which is easy to use.

 

What is Ansible?

Ansible is a simple and powerful automation language. It helps to automate, accelerate, collaborate with and integrate technologies that we already use. Ansible is used to perform the same set of tasks across different servers from the centralized server where it is installed. One advantage of Ansible is that it is completely agentless. It implies no agent needs to be installed on client systems where you want the automation to be done. It merely requires SSH communication between the client and the server. All this automation will be easier when there are hundreds of instances in the specified region.

 

Why Ansible?

For the past few years, we have experienced many disruptions in business trends. This has led to building a constructive and non-disruptive way of transformation for megatrends associated with emerging technologies, and one such thing is 'AUTOMATION'. 

Automation can be achieved by Ansible’s efficient code, which replaces repetitive and routine day to day activities. To migrate dozens of workloads to AWS, with Ansible, you can use the same simple playbook language to manage your infrastructure and deploy your application. To make life easier you may need to have a solution in your local environment too. Setting up an infrastructure for all IT related activities can be automated as below.

 

Implementing Ansible solutions with cloud environment:

ansible

There are many different ways for provisioning an instance. To be precise,‘provisioning' means getting everything ready, by installing and configuring all required prerequisites in an automated manner. The basic requirements for a cloud instance are, having a network, storage and compute. When you meet those requirements, all the tasks can be easily automated with the help of Ansible playbooks. Following are some of the tasks that can be executed with the help of Ansible playbook.

  • Starting, Stopping, Deleting and Restarting an Instance in the Specified Region
  • Gathering Facts about an Instance in the Cloud
  • Creating Disk and Attaching the Disk to a Specific Instance
  • Creating network components like VPC, Subnet, Security group, etc.
  • Attaching storage
  • Listing the objects inside the bucket
  • Deleting buckets
  • Instance provisioning

 

Sample Playbook for provisioning an instance in AWS cloud:

 

- name: Provision an EC2 Instance

    hosts: localhost

    connection: local

gather_facts: False

    tags: provisioning

 

    vars:

instance_type: t2.micro

security_group: webservers

      image: ami-082b5a644766e0e6f

      region: us-west-2

      keypair: ansible_aws_ec2

      count: 1

 

    tasks:

      - name: Create New security group with below given name

local_action:

          module: ec2_group

name: ""

          description: Security Group for Newly Created EC2 Instance

region: ""

          rules:

            - proto: tcp

from_port: 22

to_port: 22

cidr_ip: 0.0.0.0/0

            - proto: tcp

from_port: 80

to_port: 80

cidr_ip: 0.0.0.0/0

rules_egress:

            - proto: all

cidr_ip: 0.0.0.0/0

      - name: Launch the new t2 micro EC2 Instance

local_action: ec2

group=

instance_type=

image=

                      wait=true

region=

keypair=

                      count=

        register: ec2

      - name: Wait for EC2 Instance to Spin-up and ready for SSH access

local_action: wait_for

host={{item.public_ip}}

                      port=22

                      state=started

with_items: ""

      - name: Adding Tags to Identify

local_action: ec2_tag resource={{item.id}} region= state=present

with_items: ""

...

To learn more about OneGlobe’s Cloud Migration Services

visit https://bit.ly/2LF19gA

 

Kalapriya_Kolappan
Written by Kalapriya Kolappan
img-team
HubSPot CMS

Build your company website using drag-and-drop.

Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Vivamus suscipit tortor eget felis porttitor volutpat.

Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Vivamus suscipit tortor eget felis porttitor volutpat.

  • Lorem ipsum dolor sit amet
  • Lorem ipsum dolor sit amet
  • Lorem ipsum dolor sit amet
HubSPot CMS

Manage your HubSpot website without a developer.

Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Vivamus suscipit tortor eget felis porttitor volutpat.

Stocksy_txp9db27673udw200_Large_2772906

Every business deserves to manage their website without code.

business documents on office table with smart phone and laptop computer and graph financial with social network diagram and three colleagues discussing data in the background
HubSPot CMS

A HubSpot website theme that's easy to use.

Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Vivamus suscipit tortor eget felis porttitor volutpat.

HubSPot CMS

Build your website on HubSpot without code.

Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Vivamus suscipit tortor eget felis porttitor volutpat.

agency support
From the blog

Recent Blog Posts

Show your most recent blog posts on any website page

Frequently Asked Questions

Accordions are great for answering frequently asked questions.

How do we accept payments on our HubSpot website?

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tempor arcu non commodo elementum.

How do I optimize my werbsite for conversions?

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tempor arcu non commodo elementum.

What template are included in this theme?

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tempor arcu non commodo elementum.

"This theme lets our marketers maintain our website without a developer."

A photo of Shaun Benson, Marketing Manager, Agriflora
Marie Benson

Marketing Manager, Agriflora Inc.