TriLUG meeting - Ansible in Real Life

Joseph Tate

Terminology

Variable: setting that may vary based on host, group, etc.

Fact: Special variable discovered from host

Inventory: Collection of host arranged in groups

Task: smallest unit of work in Ansible, parameters sent to modules to do work. Can be conditional.

Handler: special task run in response to a notification from another task.

Roles: Collection of vriables, tasks, handlers, dependencies, and associated data.

Playbook: Collection of roles, one-off tasks and handlers, overiding variables as applicable to specific inventory groupings.

Challenges

External resources are sometimes unavailable.

Make liberal use of handlers and post tasks to restart services only at the end.

Ignore errors offers some small amount of error handling or ignoring.

Running extensive playbooks can take considerable time.

Use tags, host limits, and other filtering methods to limit what gets run.

No undo.

YAML is a terrible programming language.

Use Include to prevent when proliferation.

Write modules.

Best Practices (according to Joseph)

Start by doing one thing.

Don't do "packaging" things in Ansible.

Use OS packages if possible. Otherwise language packages.

Keep inventory up to date, or use dynamic inventories. Avoid YAGNI groupings.

Use playbooks to distinguish systems. Avoid running multiple playbooks with common dependencies against the same system.

Limit logic in playbooks

Write your own modules.

Use role dependencies and include files (DRY).

Use tags and host limits to constrain execution.

Best Practices (according to Ansible)

http://docs.ansible.com/ansible/playbooks_best_practices.html