Ansible is a configuration management and can clearly helps in managing and automating a lot of things which we do in our daily life with servers. This probably is among one of the swiss army knife for sysadmins and developers similar as puppet, chef and cfgengine. I have worked with puppet and now working with ansible. I see advantage of ansible over puppet is unlike puppet it does not require agents running on every node, a centeral ansible server can manage your servers farms and take care of their configuration. Today, I am trying to set up ansible with ec2 and how I can deploy my ELK tesk stack on EC2.
I am planning to write this document as free from any OS dependencies as possible. Though, for refrence I am using Arch Linux on an IBM Thinkpad with 2 GB memory and SSD disk.
Some of the requirements while working with EC2 and ansible are:
- Your system have ansible installed on it.
You have an amazon aws account.
To install ansible.
Setting up ansible is as simple as running the below commands.
pip install boto pip install ansible
Setting up amazon aws account.
This may not be as easy as running the above to command, in practice not that difficult either, you will need a web based browser and internet connection to resgister yourself for aws account.
Go to the aws webpage and get your account created. You need to provide your credit card info for amazon to verify and also they will give you a verification call to confirm.
Once you are done with the amazon account creation, get your “AWS_ACCESS_KEY_ID” and “AWS_SECRET_ACCESS_KEY”. Go to IAM(Identity and access management) -> Create a new user or select the existing one -> Go to security credentials and click “create the access key.”
An example of the keyids and secret keys are as below, replace them with your keys.
Access Key ID: NUHKOIJFOJF9GFJDO
Secret Access Key: LSDJKFODSJF9SDJF8UH3U3HFKW
You can also keep these varaibles defined in your profile file for easy access. I would suggest it to create a seprate file and add these variables there.