Ansible
- Chef
- Puppet
- Salt
- Ansible

Inventory
mail.example.com
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
ansible.cfg
[defaults]
hostfile = plugins/inventory/ec2.py
hash_behaviour = merge
site.yaml
- hosts: tag_Role_app
remote_user: ubuntu
sudo: yes
sudo_user: root
roles:
- { role: common, tags: common }
- { role: erlang, tags: erlang }
- { role: backend, tags: backend }
- { role: battle, tags: battle }
role/tasks/main.yml
- name: Backend repository directory created
file: path={{backend.dir}} state=directory
owner={{backend.user}} group={{backend.user}}
- name: Backend repository up to date
sudo: yes
sudo_user: "{{backend.user}}"
git: repo={{backend.git_repo}} version={{backend.git_version}}
dest={{backend.dir}} accept_hostkey=yes
key_file=/home/{{backend.user}}/.ssh/{{backend.key}}
notify:
- Release created
- Backend restarted
- Notify Slack that backend is updated
- name: Backend log directory created
file: path=/var/log/{{app}} owner={{backend.user}} group={{backend.user}}
state=directory
- name: Backend service is installed
template: src=init_script dest=/etc/init.d/{{app}} mode=0755
- name: Backend configuration directory created
file: path=/etc/{{app}} state=directory
- name: Backend configuration is set
template: src=sys.config
dest=/etc/{{app}}/sys.config
notify: Backend restarted
.
├── Makefile
├── Vagrantfile
├── ansible.cfg
├── appservers.yml
├── ec2_create_environment.yml
├── ec2_security.yml
├── group_vars
│ └── all.yml
├── library
│ └── sshknownhosts/...
├── localhost
├── plugins
│ └── inventory/ec2.py
├── roles
│ ├── backend
│ │ ├── handlers/main.yml
│ │ ├── tasks/main.yml
│ │ ├── templates
│ │ │ └── ...
│ │ └── vars/main.yml
│ ├── battle
│ │ ├── tasks/main.yml
│ │ └── vars/main.yml
│ ├── common
│ │ ├── tasks/main.yml
│ │ └── vars/main.yml
│ └── erlang
│ ├── files/erlang-pin-999
│ └── tasks/main.yml
├── site.yml
└── vagrant
├── hosts
└── provision.sh
21 directories, 29 files
$ ansible-playbook site.yml --tags erlang --limit tag_Env_development
PLAY [tag_Role_app] ***********************************************************
GATHERING FACTS ***************************************************************
ok: [54.77.52.128]
TASK: [erlang | Erlang repository added] **************************************
ok: [54.77.52.128]
TASK: [erlang | Erlang Solutions key added] ***********************************
skipping: [54.77.52.128]
TASK: [erlang | apt-cache is up to date] **************************************
skipping: [54.77.52.128]
TASK: [erlang | Erlang pinned to version and repository] **********************
changed: [54.77.52.128]
TASK: [erlang | Erlang installed] *********************************************
ok: [54.77.52.128] => (item=erlang-base,erlang-dev)
PLAY RECAP ********************************************************************
54.77.52.128 : ok=4 changed=1 unreachable=0 failed=0
$ ansible-playbook --tags erlang --limit tag_Env_development
$ ansible-playbook --tags battle --limit tag_Env_staging
$ ansible-playbook --limit tag_Name_staging-app-02
$ ansible-playbook ec2_create_environment.yml --inventory=localhost --extra-vars="env=prototype"
$ ansible-playbook -i vagrant/hosts site.yml --limit tag_Env_development --tags battle
- apt - Manages apt-packages
- authorized_key - Adds or removes an SSH authorized key
- cron - Manage cron.d and crontab entries.
- datadog_event - Posts events to DataDog service
- docker - manage docker containers
- ec2 - create, terminate, start or stop an instance in ec2, return instanceid
- ec2_elb_lb - Creates or destroys Amazon ELB.
- gem - Manage Ruby gems
- git - Deploy software (or files) from git checkouts
- irc - Send a message to an IRC channel
- librato_annotation - create an annotation in librato
- mysql_db - Add or remove MySQL databases from a remote host.
- nagios - Perform common tasks in Nagios related to downtime and notifications.
- newrelic_deployment - Notify newrelic about app deployments
- pagerduty - Create PagerDuty maintenance windows
- pingdom - Pause/unpause Pingdom alerts
- redis - Various redis commands, slave and flush
- riak - This module handles some common Riak operations
- s3 - S3 module putting a file into S3.
- service - Manage services.
- shell - Execute commands in nodes.
- slack - Send Slack notifications
- sns - Send Amazon Simple Notification Service (SNS) messages
- user - Manage user accounts
- wait_for - Waits for a condition before continuing.
- zfs - Manage zfs

API
$ tower-cli job launch --format human --monitor --job-template 38
Ansible
By Tarun Sharma
Ansible
- 1,230