Vars plugins inject additional variable data into Ansible runs that did not come from an inventory source, playbook, or command line. Playbook constructs like ‘host_vars’ and ‘group_vars’ work using vars plugins.
Vars plugins were partially implemented in Ansible 2.0 and rewritten to be fully implemented starting with Ansible 2.4.
The host_group_vars plugin shipped with Ansible enables reading variables from Assigning a variable to one machine: host variables and Assigning a variable to many machines: group variables.
You can activate a custom vars plugin by either dropping it into a vars_plugins
directory adjacent to your play, inside a role, or by putting it in one of the directory sources configured in ansible.cfg.
Vars plugins are used automatically after they are enabled.
You can use ansible-doc -t vars -l
to see the list of available plugins. Use ansible-doc -t vars <plugin name>
to see specific plugin-specific documentation and examples.
See also
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/plugins/vars.html