Ansible: Difference between revisions
From charlesreid1
No edit summary |
|||
| Line 2: | Line 2: | ||
Ansible is all about taking care of the heavy lifting involved in infrastructure automation. | Ansible is all about taking care of the heavy lifting involved in infrastructure automation. | ||
==Basic Features== | ==Basic Features== | ||
| Line 33: | Line 27: | ||
</pre> | </pre> | ||
==Using Ansible Locally with Vagrant== | ==Using Ansible== | ||
===Using Ansible Locally with Vagrant=== | |||
{{Main|Ansible/Vagrant}} | {{Main|Ansible/Vagrant}} | ||
| Line 45: | Line 41: | ||
See [[Ansible/Vagrant/Dynamic_Inventory]] for a dynamic inventory script with Vagrant. | See [[Ansible/Vagrant/Dynamic_Inventory]] for a dynamic inventory script with Vagrant. | ||
==Using Ansible with EC2== | ===Using Ansible with EC2=== | ||
{{Main|Ansible/EC2}} | {{Main|Ansible/EC2}} | ||
| Line 56: | Line 52: | ||
See [[Ansible/EC2/Dynamic Inventory]] for an example EC2 dynamic inventory script. | See [[Ansible/EC2/Dynamic Inventory]] for an example EC2 dynamic inventory script. | ||
==Ansible Features== | |||
[[Ansible/Playbooks]] - this is where Ansible becomes really powerful | |||
[[Ansible/Hosts]] - configuring machines to work with Ansible | |||
[[Ansible/Variables]] - defining and using variables to remove complexity | |||
[[Ansible/Roles]] - defining and using roles to make playbooks more powerful | |||
=Flags= | =Flags= | ||
{{AnsibleFlag}} | {{AnsibleFlag}} | ||
Revision as of 16:42, 13 November 2018
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.
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
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.
See Ansible/Vagrant/Dynamic_Inventory for a dynamic inventory script with Vagrant.
Using Ansible with EC2
When using Ansible with Amazon AWS EC2, AWS manages the compute nodes.
Like with Vagrant, Ansible uses the hosts file to connect to the EC2 nodes. The hosts file can either be maintained by hand using the information from AWS, or a dynamic inventory script can be used to call the AWS API and get information about computational resources to give to Ansible.
See Ansible/EC2 for coverage of both methods (the static inventory script and the dynamic inventory script) when using Amazon EC2.
See Ansible/EC2/Dynamic Inventory for an example EC2 dynamic inventory script.
Ansible Features
Ansible/Playbooks - this is where Ansible becomes really powerful
Ansible/Hosts - configuring machines to work with Ansible
Ansible/Variables - defining and using variables to remove complexity
Ansible/Roles - defining and using roles to make playbooks more powerful
Flags