Automating with Ansible
Michael DeHaan (Creator)
Ansible Background
The Ansible Story...
- Red Hat: Cobbler/Func
- Other tools...
- Hosted deployments...
- Lightblub...
What does Ansible do?
- Application deployment
- Configuration management
- Cloud provisioning
- Ad-hoc task execution
- Multi-tier orchestration & continuous deployment
Philosophy
- Agentless
- ssh used as a connection tunnel to push and execute scripts
- Automation shouldn't be your day job
- Keep things simple / auditable
- Batteries included (~235 modules in core)
Some statistics and info
- Open source
- ~2 years old
- #5 most contributions on GitHub
- Top 10 python project on GitHub for stars & forks
- New contributor added every ~1.3 days
Use case examples
- edX.org and Fedora Infrastructure have OSS'ed their Ansible content
- Gawker - continuously deploying 5-10 times an hour with rolling updates
- MapR - product installer
- Rackspace orchestrates production OpenStack upgrades with Ansible
Examples
Inventory
Playbooks
ansible-playbook [playbook file]
Task Files
Ansible Galaxy
Ansible Vault
- allows storing encrypted data in playbooks
- encrypt secrets and put them in version control
- de-encrypt in memory when needed
Rolling Updates are simple
Extending Ansible with Python
Modules
- can implement in any language that can emit JSON
- or even return key=value and write one in bash
- core modules are all Python
Plugins
- lookup plugins / enumerations
- connection plugins
- could implement a protocol other than ssh
- action plugins
- filter plugins (extend Jinja2)
- inventory
- examples: OpenStack, AWS, Rackspace
- any executable program that can emit JSON
- core/examples plugins are all Python
API/REST API
- python API for runner -- not the main purpose of the app
- REST API is part of Tower, fully discoverable, annotated, and awesome
- based on Django-REST-Framework
Requirements
- Python 2.6+ on server, 2.4+ on nodes
- python 2 only now, for reasons
Modules used Heavily
- multiprocessing
- native OpenSSH and paramiko
- PyYAML, json
- Jinja2
- subprocess