Friday, November 13, 2015

Running Ansible on AWS

0 lượt xem comment 0 comments

Ansible is Configuration Management and automation engine.  Its has a very minimal setup, its just depends on Python - witch is good because pretty much all linux distributions came with python.

You can run Ansible with just SSH, yes with-out agents. Like other engines Ansible is based on Recipes, in Ansible world recipes are called palybooks.

Playbooks are written in a kind of DSL inside a YAML file, often called main.yml. You can have multiple YAML files and reuse a lot your provision playbooks.

Ansible runs easily pretty much in all environments BUT windows.  For windows users its easy to use it with Vagrant.  It`s possible to have pretty complex provision scripts if needed, there are lots of modules like git, file, get_url and so one and on. Ansible provide variables, so you can bind custom values on conf files also called templates.  For this post i will how to do a very simple and straight forward setup for ansible on AWS, this will be a pretty basic setup but will be great for use as a developer doing any kinda of provisioning task, so you gonna have a enviroment to test your playbooks.

You need create a AMI on EC2, for this sample i will use Amazon Linux | CentOS based. You can do with other linux distribution if you like so, once you create the box and log into ssh, you just need run the following steps.

sudo su
yum update
yum install -y git
cd /usr/local/src
yum -y install git python-jinja2 python-paramiko PyYAML make MySQL-python
git clone git://github.com/ansible/ansible.git
cd ansible
git submodule update --init --recursive
make install
CTRL + D
sudo echo "[localhost]" > ~/ansible_hosts
sudo echo "localhost ansible_connection=local" >> ~/ansible_hosts
export ANSIBLE_INVENTORY=~/ansible_hosts
sudo vim /etc/ansible/hosts 
[127.0.0.1]
127.0.0.1 ansible_connection=local

[localhost]
127.0.0.1 ansible_connection=local
export AWS_ACCESS_KEY_ID='AK123'
export AWS_SECRET_ACCESS_KEY='abc123'

[test.yml]

---
- name: implicit localhost test...
  hosts: localhost
  tasks:
  - debug: msg="hello world" 
ansible-playbook test.yml
view raw ansible-aws.md hosted with ❤ by GitHub
Cheers,
Diego Pacheco
Tags: update, scripts,

comment 0 comments

Chuyên mục văn hoá giải trí của VnExpress

.

© 2017 www.blogthuthuatwin10.com

Tầng 5, Tòa nhà FPT Cầu Giấy, phố Duy Tân, Phường Dịch Vọng Hậu, Quận Cầu Giấy, Hà Nội
Email: nguyenanhtuan2401@gmail.com
Điện thoại: 0908 562 750 ext 4548; Liên hệ quảng cáo: 4567.