SathiyarajPeriyannan.aws

ansible-role-aws

This is an Ansible role that helps you create EC2 instances and security groups in the AWS cloud. It also updates the public DNS names of the EC2 instances in an inventory file, so you can use them in other roles or playbooks later.

This role can also delete, stop, and start EC2 instances, in addition to creating them.

Requirements

To use this role, you need the following:

  • A Python package version 2.6 or higher installed on the Ansible machine.
  • The boto package installed on the Ansible machine.
  • AWS access key environment variables must be set: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  • An AWS key pair must be created to connect to the instances.

Role Variables

You can set the following variables for the instances in the default/main.yml file or individually in the inventory file:

  • The AWS region where the EC2 instance will be created:

    • aws_region: ap-south-1
  • The instance type that defines the CPU and memory:

    • instance_type: t2.micro
  • The AWS image ID that identifies the OS for the instance:

    • image_id: ami-ac1e68c3
  • The AWS security group for the instances. If it doesn't exist, a new group will be created with limited access:

    • security_group_name: "security123"
  • The name of the AWS key pair for connecting to the instance. Create this manually:

    • sshkeypair_name: my_key
  • The size of the AWS EBS storage disk in GB:

    • disk: 10

Dependencies

None

Example Playbook

  1. Creating EC2 instances in AWS cloud:

    - hosts: instances
      connection: local
      vars:
        operation: createhosts
    
      roles:
        - SathiyarajPeriyannan.aws
    
  2. Starting EC2 instances in AWS cloud:

    - hosts: instances
      connection: local
      vars:
        operation: starthosts
    
      roles:
        - SathiyarajPeriyannan.aws
    
  3. Stopping EC2 instances in AWS cloud:

    - hosts: instances
      connection: local
      vars:
        operation: stophosts
    
      roles:
        - SathiyarajPeriyannan.aws
    
  4. Deleting EC2 instances in AWS cloud:

    - hosts: instances
      connection: local
      vars:
        operation: deletehosts
    
      roles:
        - SathiyarajPeriyannan.aws
    

License

BSD

Author Information

This role was created in 2018 by Sathiyaraj Periyannan.

Informazioni sul progetto

EC2 instance create, delete, stop and start in AWS Cloud

Installa
ansible-galaxy install SathiyarajPeriyannan.aws
Licenza
mit
Download
83
Proprietario
HCL ERS DevOps COE - Solutions Architect (DevOps, Docker, Kubernetes,Consulting) at ERS, HCL Technologies.