O'Reilly logo

Ansible Configuration Management by Daniel Hall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing modules in Python

All of the modules that are distributed with Ansible are written in Python. Because Ansible is also written in Python, these modules can directly integrate with Ansible. This increases the speed at which they can run. Here are a few other reasons why you might write modules in Python:

  • Modules written in Python can use boilerplate, which reduces the amount of code required
  • Python modules can provide documentation to be used by Ansible
  • Arguments to your module are handled automatically
  • Output is automatically converted to JSON for you
  • Ansible upstream only accepts plugins using Python with the boilerplate code included

You can still build Python modules without this integration by parsing the arguments and outputting JSON yourself. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required