Ansible/Playbooks: Difference between revisions
From charlesreid1
(→Flags) |
No edit summary |
||
| Line 1: | Line 1: | ||
=Overview= | |||
The Ansible documentation has a nice overview of playbooks: https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html | |||
Notes on playbooks: | |||
* playbooks are a way of executing commands on remote machines in a scripted way | |||
* can orchestrate multiple ordered processes | |||
* playbooks are written in YAML | |||
* each playbook can contain one or more plays | |||
* each play will target different servers (maybe all of them, maybe just web servers, maybe just db servers) | |||
* user specifies hosts - remote machines on which Ansible will run commands | |||
* users - the remote user is the user that Ansible will run the particular task as | |||
Notes on tasks: | |||
* each play has a list of tasks associated with it | |||
* tasks are executed in order on all machines that match the host pattern | |||
* ansible completes the task on all remote machines before it moves on to the next task | |||
Notes on being idempotent: | |||
* idempotent means you can run it multiple times with the same outcome as running it one time | |||
* modules should check whether the desired final state has already been achieved, and exit without doing anything if so | |||
=Example: Secure Nginx Server= | =Example: Secure Nginx Server= | ||
Revision as of 16:42, 10 December 2018
Overview
The Ansible documentation has a nice overview of playbooks: https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html
Notes on playbooks:
- playbooks are a way of executing commands on remote machines in a scripted way
- can orchestrate multiple ordered processes
- playbooks are written in YAML
- each playbook can contain one or more plays
- each play will target different servers (maybe all of them, maybe just web servers, maybe just db servers)
- user specifies hosts - remote machines on which Ansible will run commands
- users - the remote user is the user that Ansible will run the particular task as
Notes on tasks:
- each play has a list of tasks associated with it
- tasks are executed in order on all machines that match the host pattern
- ansible completes the task on all remote machines before it moves on to the next task
Notes on being idempotent:
- idempotent means you can run it multiple times with the same outcome as running it one time
- modules should check whether the desired final state has already been achieved, and exit without doing anything if so
Example: Secure Nginx Server
Ansible/Nginx Playbook - a page that walks through two example playbooks
Full Stack Example: Django Celery RabbitMQ Postgres
Ansible/Full Stack Playbook - a page that walks through a playbook for a full stack example
Flags