Plugin Wizardry With Ansible
Alexander Sowitzki, Ansible Core Maintainer
Red Hat
WHAT YOU WILL LEARN
- What plugins are for
- Kinds of Plugins in existence
- When to use them
- When to stick to other tricks
WHAT ARE PLUGINS EVEN FOR?
- Fundamentally change Ansible without touching it
- Extend modules on controller side
- Needs to be in Python
- Different types for different uses
PULL IN INFORMATION: LOOKUP!
- Want to use some information from external sources?
- It is not really a fact?
- Use a lookup plugin to get it into play
WE HEARD YOUR LIKE VARIABLES: VARS!
- Want to pull in even more variables in bulk?
- Provide a source for vars to Ansible
MAKING SENSE OF YOUR DEFINITIONS: INVENTORY!
- You should define your inventory as YAML
- But in case your inventory is a base64 encoded PDF file: Inventory plugins
- (Don't do that please)
REMEMBER THE FACTS: CACHE!
- Persist facts and inventories instead of fetching them on each play
- Improve performance
INTERPRET INFORMATION: TEST!
- Extend tests and checks (like `when`)
- Check complex states without reducing readability
JINJA IS JUST TOO SHALLOW: FILTER!
- You want to extend the jinja filter set? Go for it.
- But are you sure there isn't already a filter for that?
THE UNIVERSAL ANSIBLE: CONNECTION!
- A node does not speak SSH? Give it a connection plugin
- Can be used to control a variety of devices like router
- Ever wanted to flash your ESP32 over Bluetooth?
GETTING TACTICAL: STRATEGY!
- Helps with synchronization
- Take a look at free, serial and linear
SPIDER IN THE WEB: CALLBACK!
- Lets Ansible do things on specific events
- Customize ordering of task execution
- Control LEDs on an indicator panel while running a playbook
THE SHOOTING STAR: ACTION!
- Modules run on the nodes, plugin runs on the controller
- Action can mess with variables, module can't
- Better together, alone still pretty good
MAYBE BETTER USE ROLES!
- For combos of existing actions
- Use the new role argument validation feature of 2.11
- You can describe everything as an action - ask yourself if you should though
MY PERSONAL LESSONS LEARNED
Thank You!