Latest Developments in Cloud Technology | OneGlobe Blogs

Automating Infrastructure Deployments in AWS Cloud with Ease

Written by Bhuvaneswari Duraisamy | Feb 29, 2024 5:45:19 AM

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:

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