Deploying to AWS with Ansible and Terraform


#1

Deploying to AWS with Ansible and Terraform

  1. Set up
    a. Install python and verify whether python is installed or not
    $sudo apt-get update
    $sudo apt-get install python3.6
    $python --version
    b. Install Python pip
    $apt install python-pip
    $pip install --upgrade pip
    c. Download Terraform
    $curl -o https://releases.hashicorp.com/terraform/0.12.4/terraform_0.12.4_linux_amd64.zip
    it will generate .zip file
    d.create a folder(/bin/terraform) and unzip the terraform.zip in that folder
    $mkdir /bin/terraform
    $unzip terraform.zip -d /bin/terraform
    set the terraform path
    $export PATH= $PATH:/bin/terraform
    e.verfify whether terraform is installed or not
    $terrafoem --version
    f.Install AWS CLI
    $pip install aws cli --upgrade
    $apt-get update
    g. Install software properties
    $apt-get install software-properties-common
    h. Add repository which will contain ansible
    $apt-add-repository ppa:ansible/ansible
    i.update the packages
    $apt-get update
    j.Install ansible
    $apt-get install ansible
    h.verify whether ansible is installed or not
    $ansible --version
    i.we need to generate the key to access the server for that
    $ssh-keygen
    j.Save the key in /root/.ssh/filename
    k.To access the ssh agent
    $ssh-agent bash
    $ssh-add ~/.ssh/filename
    l.To make sure the key is present
    $ssh-add -l
    m.Modify ansible configuration file
    $vim /etc/ansible/ansible.conf
    disable host_key_checking i.e host_key_checking= False
    n.Create a working directory
    $mkdir terransible
  2. IAM and DNS setup
    a. Go to IAM console Select IAM, Select Users, Add user i.e terransible
    b.Attach administer policy to the user
    c.Create User
    Make sure download the credentials
    d. Configure Route 53
    e. COnfigure aws
    $aws configure-profile superhero