Skip to content

Er-rajsingh/provioning-instance-and-updating-inventory-dynamically

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

provioning-instance-and-updating-inventory-dynamically

This is useful when we need to provision ec2-instance and configure any thing into it without updating IP in inventory file.

Pre - instruction for this tasks --->

  1. Install the ansible using pip module
    #pip3 install ansible
  2. Install sshpass software using epel release repo
    #yum install sshpass
  3. Install boto3 library for using aws API
    #pip3 install boto3 --> for using aws_automate1.yml
    #pip3 install boto --> for using aws_automate.yml
  4. Create directory using command - #mkdir /etc/ansible
  5. Put the file "ansible.cfg" into /etc/ansible folder
    #mv ansible.cfg /etc/ansible --> clone the repo in root folder
  6. Change directory by #cd /aws
    i) Edit only "aws_var.yml" and put all informations there
    ii) After modifying the "aws_var.yml" file run any of the playbook i.e., aws_automate.yml or aws_automate1.yml

Now let start -->

Provisioning EC2-instance and configuring Web Server into it

Step 1 - Provisioning EC2-Instance on the aws

  • m ec2_instance:
       -a " Key_name: key_pair name
        instance_type: t2.micro
        image_id: image id which you want to launch as OS[ ami-xxxxx]
        name: "Your OS name"
        vpc_subnet_id: subnet-xxxxxx #your subnet id
        network:
           assign_public_ip: yes
        region: region name
        state: present
        security_group: sg-xxxxxxxxxxxx #your precreated security group
        aws_access_key: Your_access_keys #created from using IAM servive of aws
        aws_secret_key: your_secret_keys #created from using IAM servive of aws


Step 2 - Retrieving the IP and copying into the inventory file

   -m copy

Step 3 - Installing Webserver into this instance

   -m package

Step 4 - creating the webpage
   -m copy

Step 5 - Starting the httpd services
   -m service

About

This is useful when we need to provision ec2-instance and configure any thing into it without updating IP in inventory file.

Topics

Resources

Stars

Watchers

Forks