Ansible
From charlesreid1
Ansible can be thought of as a for-loop over SSH scripts, but it's also much more than that.
Ansible is all about taking care of the heavy lifting involved in infrastructure automation.
Related:
- Ansible/Playbooks - this is where Ansible becomes really powerful
- Ansible/Hosts - configuring machines to work with Ansible
Basic Features
Summary:
- Ansible is Python-based
- Ansible uses playbooks, which are YAMl files, to configure remote machines
- Ansible is push-based, which means your workflow involves making changes to the playbook and pushing those changes to the server
- Ansible is idempotent, which means you can run the playbook multiple times and it will only carry out new tasks (it will not repeat tasks)
- Ansible allows executing arbitrary shell commands
- Ansible uses Jinja templates, in addition to YAML, to deploy files to machines
Directory Structure
The basic directory structure we'll use with Ansible is to create a playbooks directory to hold everything:
playbooks/
hosts <-- ansible inventory file
.vagrant/ <-- directory used by vagrant for keys/machines (if using vagrant)
playbook.yml
Using Ansible Locally with Vagrant
Vagrant allows you to set up virtual machine(s) using VirtualBox, which can give you a way of testing Ansible scripts locally (without using the AWS or Google Cloud platforms).
Ansible uses the hosts file to connect to Vagrant. You can either manage the hosts file by hand (for a small number of machines), or you can use a dynamic inventory script (for an arbitrary number of machines).
See Ansible/Vagrant for coverage of both methods when using Vagrant.