Ansible role to create linux users with Github accounts ssh key

In this short tutorial we’ll learn how to create or delete the linux user accounts with public ssh keys associated with their Github accounts using Ansible, so please create a Github account if you don’t already have one, and follow the instructions for associated SSH keys with your account, if you didn’t perform it already.

First, download this Repository from the GitHub:

git clone https://github.com/arbabnazar/ansible-roles.git

Note: If git is not installed then you can simply download the zip file.

Move inside the cloned directory:

cd ansible-roles

Read more of this post

Autoscaling with AWS instances using Ansible-Pull

Ansible has an excellent feature called ansible-pull, which many people don’t know or don’t use. This feature works best for self healing infrastructure, best example is AWS Autoscaling in which new ec2 instance is created from vanilla ami, then pull the code from somewhere (version control system) and configure itself before announcing that it is ready to serve (mean add to the serving ELB).

The steps for ansible-pull are:

1. Pull the git repo containing your playbooks.
2. That repo is cloned to the mentioned directory.
3. ansible-pull starts executing the local.yml found in your cloned repo directory.

Let’s assume that you want to pull the code from the private git repo and for this you need the ssh private key but you have taken the updated vanilla ubuntu ami from the Marketplace, then how you will clone this private repo? For this we’ll use the Bootstrap Pattern:

– Put the private part of ssh key for the git repository on S3.
– Getting ssh key from s3 bucket using IAM role credentials

For this, create a S3 bucket(in my case it is named “tendo-github-key-s3“):

s3-1

Read more of this post

Create AWS Cloudfront Distribution using Terraform

In this post, we’ll create the AWS Cloudfront Distribution using Terraform and for this, we need the latest version of Terraform.

Terraform v0.6.15
  • Complete Cloudfront Terraform Plan as gist
  • Complete Variables as gist

Before using the terraform, we need to export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables:

export AWS_ACCESS_KEY_ID="xxxxxxxxxxxxxxxx"
export AWS_SECRET_ACCESS_KEY="yyyyyyyyyyyyyyyyyyyy"

Read more of this post

How to compile a development version of Terraform

In this tutorial I’ll describe all the steps to build the development version of Terraform. At the end of this process, it will generate a set of binaries for each supported platforms(Linux, Mac OS X, Windows etc..).

First we need to clone the terraform’s github offical repo:

git clone https://github.com/hashicorp/terraform.git

Move inside the cloned repo:

cd terraform

Read more of this post

Highly-Available WordPress Setup inside AWS VPC using Terraform & Ansible

In this post,we’ll create the Infrastructure for Highly-Available WordPress website over AWS using Terraform and then install the WordPress using Ansible. If you don’t know about the Terraform, please check this link.

We’ll use the Terraform to create the fully operational AWS VPC infrastructure(subnets,routeing tables,igw etc), it will also create everything that need to be for creating EC2 and RDS instances (security key, security group, subnet group). It will also create the Elastic Load Balancer and add the EC2 instance(s) automatically to it as well as creating the Route53 entry for this wordpress site and add the ELB alias to it.

Ansible will be used to deploy the wordpress on the EC2 instances that have been created via Terraform, that will be fault tolerant and highly available.

Requirements:

  • Terraform
  • Ansible
  • AWS admin access

Tools Used: Read more of this post

AWS Infrastructure Creation with Ansible Part-4

By this point, you should have gone through the Part-1, Part-2 and Part-3 of this series. In this tutorial, we’ll create the RDS instance inside the VPC that we have created in Part-1  and Security Group created in Part-2 using Ansible.

If you have completed the previous parts of this series, then you have already clone the git repo that contains all the roles, if not then clone the git repo:

git clone https://github.com/arbabnazar/ansible-aws-roles.git
cd ansible-aws-roles

Modified the aws.yml playbook to add the desired roles:

Note: May be, you have already noticed that we have also added the vpc, ec2sg, ec2key, ec2instance and elb roles in the playbook, it will not re-create all this except the EC2 instance(this role is not idempotent), if you have created them in the previous parts, because Ansible is idempotent. Read more of this post

AWS Infrastructure Creation with Ansible Part-3

By this point, you should have already read the Part-1 and Part-2 of this series. In this tutorial, we’ll create the EC2 instances inside the VPC that we have created in Part-1, Security Group & EC2 Key Pair created in Part-2 and also add them inside the ELB, all with Ansible.

If you have completed the previous parts of this series, then you have already clone the git repo that contains all the roles, if not then clone the git repo:

git clone https://github.com/arbabnazar/ansible-aws-roles.git
 cd ansible-aws-roles

Read more of this post

AWS Infrastructure Creation with Ansible Part-2

In the second part of this series of tutorials, we’ll create the Security Group and EC2 Key Pair using Ansible. If you didn’t create the VPC already, then please check the Part-1 of this series.

If you have completed the Part-1, then you have already clone the git repo that contains all the roles, if not then clone the git repo:

git clone https://github.com/arbabnazar/ansible-aws-roles.git
cd ansible-aws-roles

Read more of this post

AWS Infrastructure Creation with Ansible Part-1

In this series of posts, we’ll create the Infrastructure over AWS using Ansible. For the first part of this series, we’ll create the VPC, the basic building block, because everything like Security Group, EC2 instance, RDS Instance, ELB etc will create inside the VPC.

Requirement to use these roles:

- Ansible v2.0
- boto
- AWS admin access

Specifically, these are the versions of mentioned software that I am using for this series:

ansible-boto

Read more of this post

AWSCli Installation & Configuration using Ansible

In this blog post, we’ll learn that how we can use simple Ansible role to install the AWS CLI with all the required dependencies on Ubuntu 14.04 LTS, it should work on other versions of Ubuntu too.

First, clone this Repository from the GitHub:

git clone https://github.com/arbabnazar/ansible-roles.git

Note: If git is not installed then you can simply download the zip file.

To use this role, edit the site.yml file:

vi site.yml

Read more of this post

%d bloggers like this: