O'Reilly logo

Ansible Configuration Management - Second Edition 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

Using a custom module

Now that we have written our very first module for Ansible, we should give it a go in a playbook. Ansible looks at several places for its modules—first it looks at the place specified in the library key in its config file (/etc/ansible/ansible.cfg), next it will look at the location specified using the --module-path argument in the command line, then it will look in the same directory as the playbook for a library directory containing modules, and finally it will look in the library directory for any roles that may be set.

Let's create a playbook that uses our new module and place it in a library directory in the same place so that we can see it in action. Here is a playbook that uses the hostname module:

--- - name: Test the ...

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