Ansible/Quickstart
< Ansible
Noisebridge uses Ansible for DevOps tasks. This page is a quick introduction to the concepts found in Noisebridge's Ansible config and playbooks.
- How Ansible works
- https://www.ansible.com/overview/how-ansible-works
- Definitions
- https://docs.ansible.com/ansible/latest/reference_appendices/glossary.html
- Best Practices
- https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html
- Working with PLaybooks
- https://docs.ansible.com/ansible/latest/user_guide/playbooks.html#working-with-playbooks
- playbook
- Playbooks are the language by which Ansible orchestrates, configures, administers, or deploys systems.
- play
- A playbook is a list of plays. A play is minimally a mapping between a set of hosts selected by a host specifier (usually chosen by groups but sometimes by hostname globs) and the tasks which run on those hosts to define the role that those systems will perform. There can be one or many plays in a playbook.
- group_vars
- The group_vars/ files are files that live in a directory alongside an inventory file, with an optional filename named after each group. This is a convenient place to put variables that are provided to a given group, especially complex data structures, so that these variables do not have to be embedded in the inventory file or playbook.
- roles
- Roles are units of organization in Ansible. Assigning a role to a group of hosts (or a set of groups, or host patterns, etc.) implies that they should implement a specific behavior. A role may include applying certain variable values, certain tasks, and certain handlers – or just one or more of these things. Because of the file structure associated with a role, roles become redistributable units that allow you to share behavior among playbooks – or even with other users.
- vars
- As opposed to Facts, variables are names of values (they can be simple scalar values – integers, booleans, strings) or complex ones (dictionaries/hashes, lists) that can be used in templates and playbooks. They are declared things, not things that are inferred from the remote system’s current state or nature (which is what Facts are).
- tasks
- Playbooks exist to run tasks. Tasks combine an action (a module and its arguments) with a name and optionally some other keywords (like looping directives). Handlers are also tasks, but they are a special kind of task that do not run unless they are notified by name when a task reports an underlying change on a remote system.
- templates
- Ansible can easily transfer files to remote systems but often it is desirable to substitute variables in other files. Variables may come from the inventory file, Host Vars, Group Vars, or Facts. Templates use the Jinja2 template engine and can also include logical constructs like loops and if statements.
- handlers
- Handlers are just like regular tasks in an Ansible playbook (see Tasks) but are only run if the Task contains a notify directive and also indicates that it changed something. For example, if a config file is changed, then the task referencing the config file templating operation may notify a service restart handler. This means services can be bounced only if they need to be restarted. Handlers can be used for things other than service restarts, but service restarts are the most common usage.
- files
- ?
- defaults
- ?