Ansible module development: getting started Sept. 23, 2019, 12:18 p.m.

A module is a reusable, standalone script that Ansible runs on your behalf, either locally or remotely. Modules interact with your local machine, an API, or a remote system to perform specific tasks like changing a database password or spinning up a cloud instance. Each module can be used by the Ansible API, or by the ansible or ansible-playbook programs. A module provides a defined interface, accepting arguments and returning information to Ansible by printing a JSON string to stdout before exiting. Ansible ships with thousands of modules, and you can easily write your own. If you’re writing a module for local use, you can choose any programming language and follow your own rules. This tutorial illustrates how to get started developing an Ansible module in Python.

tutorial ansible python

Extending Ansible – modules Sept. 19, 2019, 1:51 p.m.

One of possible use cases for custom modules is a wrapper for shell command. If there is a task you do with cli command on different remote hosts and in differen parts of your playbook/project, you may want to wrap it into idempotent module with check-mode support to make your playbooks’ code clean and easy to read.

tutorial ansible

Ansible Debug Print All Variables Oct. 5, 2018, 10:31 a.m.

Display all variables/facts known for a host

- name: Display all variables/facts known for a host
  debug:
    var: hostvars[inventory_hostname]
ansible debugging