Tutorials/Tips

How to Extend Ansible Through Plugins

Did you know a large portion of Ansible’s functionality comes from the Ansible plugin system? These important pieces of code augment Ansible’s core functionality such as parsing and loading inventory and Playbooks, running Playbooks and reading the results. Essentially, Ansible uses plugins to extend what the system is doing under the hood.

In this blog, I’ll review each of these plugins and offer a high-level overview on how to write your own plugin to extend Ansible functionality.

Action Plugins

One of the core critical plugins used by Ansible are action plugins. Anytime you run a module, Ansible first runs an action plugin.

Related Post:  Attacking WPE Enterprise with hostapd-wpe in Kali

Action plugins are a layer between the executor engine and the module and allow for controller-side actions to be taken before the module is executed. A good example of this is the template module. If you look at template.py in the modules directory, it’s basically a Python stub with documentation strings, everything is done by the action plugin. The template action plugin itself creates the template file locally as a temporary file, and then uses the copy or file modules to push it out to the target system.

Related Post:  Running Node.js on Linux with systemd

If Ansible finds an action plugin with the same name as the module, that action plugin is used, otherwise the ‘normal’ action plugin is used. Tasks which use ‘async’ have a special action plugin, which is used to launch the task using the ‘async_wrapper’ module.

The following code is the entirety of the ‘normal’ action plugin. Continue reading

Ansible

JOIN OUR NEWSLETTER
Enjoying the article you're reading? Subscribe to our newsletter to receive updates and new articles as soon as they are published - right in your Inbox
We hate spam. Your email address will not be sold or shared with anyone else.
Please share:

We Recommend These Vendors and Free Offers

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).

Deploy an SSD Cloud server in 55 seconds on DigitalOcean. Built for developers and starting at $5:00/month (20 GB SSD, 512 MB of RAM).

Want to become an expert ethical hacker and penetration tester? Request your free video training course of Online Penetration Testing and Ethical Hacking

Whether you're new to Linux or are a Linux guru, you can learn a lot more about the Linux kernel by requesting your free ebook of Linux Kernel In A Nutshell.


Leave a Comment

Your email address will not be published. Required fields are marked *

*