From ef5e3860c17d4f30669185258a3775f25fe2a9bb Mon Sep 17 00:00:00 2001 From: Mohsin Zaheer Date: Wed, 12 Feb 2020 17:22:03 +0000 Subject: [PATCH 1/3] eg-1002 ansible for aws terraform and role --- README.md | 17 +++- ansible_master/README.MD | 78 ++++++++++++++++ ansible_master/main.tf | 89 +++++++++++++++++++ ansible_master/output.tf | 3 + .../roles/ansible-master-setup/tasks/main.yml | 54 +++++++++++ .../ansible-master-setup/templates/config.j2 | 3 + .../templates/credentials.j2 | 3 + .../roles/ansible-master-setup/vars/var | 1 + .../roles/ansible-master-setup/vars/vault | 2 + ansible_master/playbook/run-setup.yml | 7 ++ ansible_master/script/setup.sh | 10 +++ ansible_master/terraform.tfvars | 8 ++ ansible_master/vars.tf | 31 +++++++ ansible_slave/README.MD | 58 ++++++++++++ ansible_slave/main.tf | 63 +++++++++++++ ansible_slave/output.tf | 3 + .../roles/ansible-slave-setup/tasks/main.yml | 20 +++++ .../roles/ansible-slave-setup/vars/main.yml | 5 ++ ansible_slave/playbook/run-setup.yml | 7 ++ ansible_slave/terraform.tfvars | 7 ++ ansible_slave/vars.tf | 27 ++++++ 21 files changed, 494 insertions(+), 2 deletions(-) create mode 100644 ansible_master/README.MD create mode 100644 ansible_master/main.tf create mode 100644 ansible_master/output.tf create mode 100644 ansible_master/playbook/roles/ansible-master-setup/tasks/main.yml create mode 100644 ansible_master/playbook/roles/ansible-master-setup/templates/config.j2 create mode 100644 ansible_master/playbook/roles/ansible-master-setup/templates/credentials.j2 create mode 100644 ansible_master/playbook/roles/ansible-master-setup/vars/var create mode 100644 ansible_master/playbook/roles/ansible-master-setup/vars/vault create mode 100644 ansible_master/playbook/run-setup.yml create mode 100644 ansible_master/script/setup.sh create mode 100644 ansible_master/terraform.tfvars create mode 100644 ansible_master/vars.tf create mode 100644 ansible_slave/README.MD create mode 100644 ansible_slave/main.tf create mode 100644 ansible_slave/output.tf create mode 100644 ansible_slave/playbook/roles/ansible-slave-setup/tasks/main.yml create mode 100644 ansible_slave/playbook/roles/ansible-slave-setup/vars/main.yml create mode 100644 ansible_slave/playbook/run-setup.yml create mode 100644 ansible_slave/terraform.tfvars create mode 100644 ansible_slave/vars.tf diff --git a/README.md b/README.md index 8da33dd..232ccfd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ -# ansible-for-aws -Ansible setup to maintain aws resources +# Ansible For AWS + +This project is to setup Ansible and manage AWS resources using Ansible. We are using Master and Slave concept for better understanding between Ansible and different resources. + +## Ansible Master + +This project is using Master terminology to give a feeling that this server will be running Ansible and maintaining resources using a dynamic inventory. Ansible Master folder has it's own README for more details. + +## Ansible Slave + +Ansible Slave folder is created to give an example how a EC2 instance can be created, setup and integrated with Ansible Master in automated fashion. There is no correct or bad way of doing it but this is one way to automated creating resources. Ansible Slave folder has it's own README for more details. + +## Author Information + +You can always open Pull request for contribution to the project or email to mohsinzaheer25@hotmail.com \ No newline at end of file diff --git a/ansible_master/README.MD b/ansible_master/README.MD new file mode 100644 index 0000000..e0513c1 --- /dev/null +++ b/ansible_master/README.MD @@ -0,0 +1,78 @@ +# Ansible Master + +Ansible Master is to create and setup Ansible with dynamic inventory to manage AWS resources. + +## How it works? + +It is using Terraform which is a **infrastructure as a code** tool to provision resources on AWS then using Shell script along with Playbook to setup it. + +## Things Need To Know + +Your machine from where you running this project need to install below things. + +1. Terraform +2. Ansible + +You need to create `IAM User` with Access Key and Secret with permission that can create resources on AWS. Also, you need to create a `SSH KEY` on AWS which you will be using to login into the server. + +`ansibleadmin` user will be created and will be use for ansible purpose. + +[Vault Variable] (playbook/roles/ansible-master-setup/vars/vault) is left unencrypted but in real after replace credentials it should be encrypted. You can use below command to do that + +``` +ansible-vault encrypt --vault-password-file=REPLACEWITHPASSWORDFIE playbook/roles/ansible-master-setup/vars/vault +``` + +## Variables + +Terrform has different variables and its values can be change in [Terraform Vars](terraform.tfvars) according to your need. + +| Variable Name | Description | +| --- | --- | +| access_key | Access Key ID of IAM User +| secret_key | Secret Key of IAM User +| name | Name of the instance +| type | Type i.e. Master +| environment | Enviroment of the instance. i.e. Dev, QA or Prod +| role | Role of the instance +| user | User to login to the created instance +| private_key_path | Path for Private Ke + +## Provisioning Ansible Master + +First, you need to replace the necessary variables in [Terraform Vars](terraform.tfvars) and then initiate terraform by using below command in order to get the appropriated plugin. + +``` +terraform init +``` + +You can check the changes Terraform is making using below command + +``` +terraform plan +``` + +Once everything looks good, you can provision the resource using below command + +``` +terraform apply +``` + +## Testing Dynamic Inventory + +`ansibleadmin` user will be created with necessary setup. From ansibleadmin home directory you can run below command to test dynamic inventory + +``` +ansible -i ec2.py -m ping tag_Name_Ansible_Slave +``` + +## References + +[AWS Dynamic Inventory] (https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/) + + +[Ansible Dynamic Inventory] (https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html) + +[Setup Terraform] (https://learn.hashicorp.com/terraform/getting-started/install.html) + +[Creating IAM User] (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console) diff --git a/ansible_master/main.tf b/ansible_master/main.tf new file mode 100644 index 0000000..a4f6632 --- /dev/null +++ b/ansible_master/main.tf @@ -0,0 +1,89 @@ +provider "aws" { + region = "us-east-1" + access_key = var.access_key + secret_key = var.secret_key +} + +data "aws_ami" "ubuntu" { + most_recent = true + + filter { + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + owners = ["099720109477"] +} + +resource "aws_security_group" "ansible_master_sg" { + name = "Ansible Master Security Group" + description = "Security Group Rules For Ansible Master" + + ingress { + from_port = 22 + protocol = "TCP" + to_port = 22 + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + protocol = "-1" + to_port = 0 + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_instance" "ansible_master" { + ami = data.aws_ami.ubuntu.id + instance_type = "t2.micro" + associate_public_ip_address = true + availability_zone = "us-east-1b" + tenancy = "default" + key_name = "demokey" + + tags = { + Name = var.name + "Type" = var.type + "Environment" = var.environment + "Role" = var.role + } + + vpc_security_group_ids = [ + aws_security_group.ansible_master_sg.id + ] + + provisioner "file" { + source = "script" + destination = "/tmp" + + connection { + type = "ssh" + user = var.user + host = self.public_ip + private_key = file(var.private_key_path) + } + } + + provisioner "remote-exec" { + inline = [ + "sudo chmod 0755 /tmp/script/setup.sh", + "sudo bash /tmp/script/setup.sh", + ] + connection { + type = "ssh" + user = var.user + host = self.public_ip + private_key = file(var.private_key_path) + } + } + + provisioner "local-exec" { + command = "sleep 60 && ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook playbook/run-setup.yml -i '${self.public_ip},' -e ansible_user=${var.user} --private-key '${var.private_key_path}'" + } +} diff --git a/ansible_master/output.tf b/ansible_master/output.tf new file mode 100644 index 0000000..e69c93b --- /dev/null +++ b/ansible_master/output.tf @@ -0,0 +1,3 @@ +output "ansible_master_ip" { + value = "${aws_instance.ansible_master.public_ip}" +} diff --git a/ansible_master/playbook/roles/ansible-master-setup/tasks/main.yml b/ansible_master/playbook/roles/ansible-master-setup/tasks/main.yml new file mode 100644 index 0000000..5955978 --- /dev/null +++ b/ansible_master/playbook/roles/ansible-master-setup/tasks/main.yml @@ -0,0 +1,54 @@ +--- + +- name: Include Variables + include_vars: + file: "{{ item }}" + with_items: + - var + - vault + +- name: Create Ansibleadmin User + user: + name: ansibleadmin + shell: /bin/bash + +- name: Generate SSH Key for Ansibleadmin + # shell: sudo -u ansibleadmin bash -c "printf '\n' | ssh-keygen -N ''" + shell: bash -c "printf '\n' | ssh-keygen -N ''" + become: true + become_user: ansibleadmin + ignore_errors: true + +- name: Create AWS Folder + file: + path: /home/ansibleadmin/.aws + state: directory + owner: ansibleadmin + group: ansibleadmin + +- name: Copy Config & Credentials + template: + src: "{{ item }}" + dest: /home/ansibleadmin/.aws/{{ item | basename | regex_replace('\.j2','') }} + owner: ansibleadmin + group: ansibleadmin + mode: 0600 + with_items: + - config.j2 + - credentials.j2 + +- name: Download Dynamic Inventory + get_url: + url: "{{ item }}" + dest: /home/ansibleadmin/ + with_items: + - 'https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py' + - 'https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini' + +- name: Change Permission Of Dynamic Inventory + file: + path: /home/ansibleadmin/ec2.py + mode: 0755 + + + \ No newline at end of file diff --git a/ansible_master/playbook/roles/ansible-master-setup/templates/config.j2 b/ansible_master/playbook/roles/ansible-master-setup/templates/config.j2 new file mode 100644 index 0000000..6364c78 --- /dev/null +++ b/ansible_master/playbook/roles/ansible-master-setup/templates/config.j2 @@ -0,0 +1,3 @@ +[default] +region = {{ var_region }} +output = json \ No newline at end of file diff --git a/ansible_master/playbook/roles/ansible-master-setup/templates/credentials.j2 b/ansible_master/playbook/roles/ansible-master-setup/templates/credentials.j2 new file mode 100644 index 0000000..73e65d4 --- /dev/null +++ b/ansible_master/playbook/roles/ansible-master-setup/templates/credentials.j2 @@ -0,0 +1,3 @@ +[default] +aws_access_key_id = {{ vault_aws_access_key_id }} +aws_secret_access_key = {{ vault_aws_secret_access_key }} diff --git a/ansible_master/playbook/roles/ansible-master-setup/vars/var b/ansible_master/playbook/roles/ansible-master-setup/vars/var new file mode 100644 index 0000000..ff4c8c8 --- /dev/null +++ b/ansible_master/playbook/roles/ansible-master-setup/vars/var @@ -0,0 +1 @@ +var_region: us-east-1 \ No newline at end of file diff --git a/ansible_master/playbook/roles/ansible-master-setup/vars/vault b/ansible_master/playbook/roles/ansible-master-setup/vars/vault new file mode 100644 index 0000000..bb1afe5 --- /dev/null +++ b/ansible_master/playbook/roles/ansible-master-setup/vars/vault @@ -0,0 +1,2 @@ +vault_aws_access_key_id: REPLACEMEWITHACCESSKEYID +vault_aws_secret_access_key: REPLACEMEWITHACCESSKEY \ No newline at end of file diff --git a/ansible_master/playbook/run-setup.yml b/ansible_master/playbook/run-setup.yml new file mode 100644 index 0000000..e82781a --- /dev/null +++ b/ansible_master/playbook/run-setup.yml @@ -0,0 +1,7 @@ +--- +- hosts: all + gather_facts: no + become: true + become_user: root + roles: + - ansible-master-setup \ No newline at end of file diff --git a/ansible_master/script/setup.sh b/ansible_master/script/setup.sh new file mode 100644 index 0000000..14b27e1 --- /dev/null +++ b/ansible_master/script/setup.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Installing Packages for Ansible Setup +sudo apt-get update -y +sudo apt-get install software-properties-common +sudo apt-get-add-repository --yes --update ppa:ansible/ansible +sudo apt-get install python python-pip awscli -y +sudo pip install --upgrade pip +sudo pip install boto ansible +sudo ln -s /usr/local/bin/ansible /usr/bin/ansible \ No newline at end of file diff --git a/ansible_master/terraform.tfvars b/ansible_master/terraform.tfvars new file mode 100644 index 0000000..586e5d2 --- /dev/null +++ b/ansible_master/terraform.tfvars @@ -0,0 +1,8 @@ +access_key = "REPLACEMEWITHACCESSKEY" +secret_key = "REPLACEMEWITHSECRET" +name = "Ansible Master" +type = "Ansible Master" +environment = "Operations" +role = "Maintenance" +user = "ubuntu" +private_key_path = "REPLACEMEWITHPRIVATEKEYPATH" diff --git a/ansible_master/vars.tf b/ansible_master/vars.tf new file mode 100644 index 0000000..54c34da --- /dev/null +++ b/ansible_master/vars.tf @@ -0,0 +1,31 @@ +variable "access_key" { + description = "Access Key ID of IAM User" +} + +variable "secret_key" { + description = "Secret Key of IAM User" +} + +variable "name" { + description = "Name of the instance." +} + +variable "type" { + description = "Type i.e. Master or Slave" +} + +variable "environment" { + description = "Enviroment of the instance. i.e. Dev, QA or Prod" +} + +variable "role" { + description = "Role of the instance." +} + +variable "user" { + description = "User to login to the created instance." +} + +variable "private_key_path" { + description = "Path for Private Key" +} diff --git a/ansible_slave/README.MD b/ansible_slave/README.MD new file mode 100644 index 0000000..d980bca --- /dev/null +++ b/ansible_slave/README.MD @@ -0,0 +1,58 @@ +# Ansible Slave + +Ansible Slave is to setup EC2 instance in order to get maintain by Ansible. + +## How it works? + +It is using Terraform which is a **infrastructure as a code** tool to provision resources on AWS then uses Playbook to setup it. + +## Things Need To Know + +Your machine from where you running this project need to install below things. + +1. Terraform +2. Ansible + +You need to create `IAM User` with Access Key and Secret with permission that can create resources on AWS. Also, you need to create a `SSH KEY` on AWS which you will be using to login into the server. + +`ansibleadmin` user will be created and added to Sudoers file in order to have root access. + +## Variables + +Terrform has different variables and its values can be change in [Terraform Vars](terraform.tfvars) according to your need. + +| Variable Name | Description | +| --- | --- | +| access_key | Access Key ID of IAM User +| secret_key | Secret Key of IAM User +| name | Name of the instance +| type | Type i.e. Master +| environment | Enviroment of the instance. i.e. Dev, QA or Prod +| user | User to login to the created instance +| private_key_path | Path for Private Ke + +## Provisioning Ansible Master + +First, you need to replace the necessary variables in [Terraform Vars](terraform.tfvars) and then initiate terraform by using below command in order to get the appropriated plugin. + +``` +terraform init +``` + +You can check the changes Terraform is making using below command + +``` +terraform plan +``` + +Once everything looks good, you can provision the resource using below command + +``` +terraform apply +``` + +## References + +[Setup Terraform] (https://learn.hashicorp.com/terraform/getting-started/install.html) + +[Creating IAM User] (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console) diff --git a/ansible_slave/main.tf b/ansible_slave/main.tf new file mode 100644 index 0000000..635b4cf --- /dev/null +++ b/ansible_slave/main.tf @@ -0,0 +1,63 @@ +provider "aws" { + region = "us-east-1" + access_key = var.access_key + secret_key = var.secret_key +} + +data "aws_ami" "ubuntu" { + most_recent = true + + filter { + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + owners = ["099720109477"] +} + +resource "aws_security_group" "ansible_slave_sg" { + name = "Ansible Slave Security Group" + description = "Security Group Rules For Ansible Slave" + + ingress { + from_port = 22 + protocol = "TCP" + to_port = 22 + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + protocol = "-1" + to_port = 0 + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_instance" "ansible_slave" { + ami = data.aws_ami.ubuntu.id + instance_type = "t2.micro" + associate_public_ip_address = true + availability_zone = "us-east-1b" + tenancy = "default" + key_name = "demokey" + + tags = { + Name = var.name + "Type" = var.type + "Environment" = var.environment + } + + vpc_security_group_ids = [ + aws_security_group.ansible_slave_sg.id + ] + + provisioner "local-exec" { + command = "sleep 60 && ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook playbook/run-setup.yml -i '${self.public_ip},' -e ansible_user=${var.user} --private-key '${var.private_key_path}'" + } +} diff --git a/ansible_slave/output.tf b/ansible_slave/output.tf new file mode 100644 index 0000000..9c1c079 --- /dev/null +++ b/ansible_slave/output.tf @@ -0,0 +1,3 @@ +output "ansible_slave_ip" { + value = "${aws_instance.ansible_slave.public_ip}" +} diff --git a/ansible_slave/playbook/roles/ansible-slave-setup/tasks/main.yml b/ansible_slave/playbook/roles/ansible-slave-setup/tasks/main.yml new file mode 100644 index 0000000..7e646f6 --- /dev/null +++ b/ansible_slave/playbook/roles/ansible-slave-setup/tasks/main.yml @@ -0,0 +1,20 @@ +--- + +- name: Create Ansibleadmin User + user: + name: ansibleadmin + shell: /bin/bash + +- name: Set authorized key for ansibleadmin + authorized_key: + user: ansibleadmin + state: present + key: "{{ public_key }}" + +- name: Configure Sudo Access + copy: + content: "{{ sudo_access_content }}" + dest: /etc/sudoers.d/ansible_admin + owner: root + group: root + mode: 0440 \ No newline at end of file diff --git a/ansible_slave/playbook/roles/ansible-slave-setup/vars/main.yml b/ansible_slave/playbook/roles/ansible-slave-setup/vars/main.yml new file mode 100644 index 0000000..7d32bce --- /dev/null +++ b/ansible_slave/playbook/roles/ansible-slave-setup/vars/main.yml @@ -0,0 +1,5 @@ +public_key: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== tom@mylaptop.local +sudo_access_content: |+ + #Sudo Access For Ansibleadmin + ansibleadmin ALL=(ALL) NOPASSWD: ALL + \ No newline at end of file diff --git a/ansible_slave/playbook/run-setup.yml b/ansible_slave/playbook/run-setup.yml new file mode 100644 index 0000000..3be8b28 --- /dev/null +++ b/ansible_slave/playbook/run-setup.yml @@ -0,0 +1,7 @@ +--- +- hosts: all + gather_facts: no + become: true + become_user: root + roles: + - ansible-slave-setup \ No newline at end of file diff --git a/ansible_slave/terraform.tfvars b/ansible_slave/terraform.tfvars new file mode 100644 index 0000000..8d8db13 --- /dev/null +++ b/ansible_slave/terraform.tfvars @@ -0,0 +1,7 @@ +access_key = "REPLACEMEWITHACCESSKEY" +secret_key = "REPLACEMEWITHSECRET" +name = "Ansible Slave" +type = "Ansible Slave" +environment = "Dev" +user = "ubuntu" +private_key_path = "REPLACEMEWITHPRIVATEKEYPATH" diff --git a/ansible_slave/vars.tf b/ansible_slave/vars.tf new file mode 100644 index 0000000..401fe41 --- /dev/null +++ b/ansible_slave/vars.tf @@ -0,0 +1,27 @@ +variable "access_key" { + description = "Access Key ID of IAM User" +} + +variable "secret_key" { + description = "Secret Key of IAM User" +} + +variable "name" { + description = "Name of the instance." +} + +variable "type" { + description = "Type i.e. Master or Slave" +} + +variable "environment" { + description = "Enviroment of the instance. i.e. Dev, QA or Prod" +} + +variable "user" { + description = "User to login to the created instance." +} + +variable "private_key_path" { + description = "Path for Private Key" +} From 3e95f570788f45ac935631d0f8e7bd46b5d23f66 Mon Sep 17 00:00:00 2001 From: Mohsin Zaheer Date: Wed, 12 Feb 2020 17:30:02 +0000 Subject: [PATCH 2/3] Updated readme --- ansible_master/README.MD | 10 +++++----- ansible_slave/README.MD | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ansible_master/README.MD b/ansible_master/README.MD index e0513c1..4a681e0 100644 --- a/ansible_master/README.MD +++ b/ansible_master/README.MD @@ -17,7 +17,7 @@ You need to create `IAM User` with Access Key and Secret with permission that ca `ansibleadmin` user will be created and will be use for ansible purpose. -[Vault Variable] (playbook/roles/ansible-master-setup/vars/vault) is left unencrypted but in real after replace credentials it should be encrypted. You can use below command to do that +[Vault Variable](playbook/roles/ansible-master-setup/vars/vault) is left unencrypted but in real after replace credentials it should be encrypted. You can use below command to do that ``` ansible-vault encrypt --vault-password-file=REPLACEWITHPASSWORDFIE playbook/roles/ansible-master-setup/vars/vault @@ -68,11 +68,11 @@ ansible -i ec2.py -m ping tag_Name_Ansible_Slave ## References -[AWS Dynamic Inventory] (https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/) +[AWS Dynamic Inventory](https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/) -[Ansible Dynamic Inventory] (https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html) +[Ansible Dynamic Inventory](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html) -[Setup Terraform] (https://learn.hashicorp.com/terraform/getting-started/install.html) +[Setup Terraform](https://learn.hashicorp.com/terraform/getting-started/install.html) -[Creating IAM User] (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console) +[Creating IAM User](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console) diff --git a/ansible_slave/README.MD b/ansible_slave/README.MD index d980bca..0258569 100644 --- a/ansible_slave/README.MD +++ b/ansible_slave/README.MD @@ -13,7 +13,7 @@ Your machine from where you running this project need to install below things. 1. Terraform 2. Ansible -You need to create `IAM User` with Access Key and Secret with permission that can create resources on AWS. Also, you need to create a `SSH KEY` on AWS which you will be using to login into the server. +You need to create `IAM User` with Access Key and Secret with permission that can create resources on AWS. You can use same credentials used for Ansible Master if you want to. Also, you need to create a `SSH KEY` on AWS which you will be using to login into the server. `ansibleadmin` user will be created and added to Sudoers file in order to have root access. @@ -53,6 +53,6 @@ terraform apply ## References -[Setup Terraform] (https://learn.hashicorp.com/terraform/getting-started/install.html) +[Setup Terraform](https://learn.hashicorp.com/terraform/getting-started/install.html) -[Creating IAM User] (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console) +[Creating IAM User](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console) From 0629658584a3de79196e94e699dfd477740a7f7b Mon Sep 17 00:00:00 2001 From: Mohsin Zaheer Date: Wed, 12 Feb 2020 17:33:00 +0000 Subject: [PATCH 3/3] Updated Reference Title --- ansible_master/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible_master/README.MD b/ansible_master/README.MD index 4a681e0..a3e2d12 100644 --- a/ansible_master/README.MD +++ b/ansible_master/README.MD @@ -68,7 +68,7 @@ ansible -i ec2.py -m ping tag_Name_Ansible_Slave ## References -[AWS Dynamic Inventory](https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/) +[AWS Setup With Dynamic Inventory](https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/) [Ansible Dynamic Inventory](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html)