Once your modules are configured, and all requirements (be they Python module dependencies or device software ones) are met, it's time to start writing your playbook. This should be a simple task of following the documentation for the module. Let's suppose we want to reset the configuration on an F5 BIG-IP device. From the documentation, we can see that authentication parameters are passed to the module itself. Also, the example code shows the use of the delegate_to task keyword; both of these clues tell us that the module is not using the native SSH transport of Ansible, but rather one that is defined in the module itself. Thus, a playbook to reset the configuration of a single device might look something like this:
---
- name: reset an F5
hosts: localhost
gather_facts: false
tasks:
- name: reset my F5
bigip_config: reset: yes save: yes server: lb.mastery.example.com
user: admin
password: mastery
validate_certs: no
In this case, we are using a textbook example from the documentation to reset our configuration. Note that as our hosts parameter only defines localhost, we do not need the delegate_to keyword, since the bigip_config module will be run from localhost only in this playbook.
In this way, we have automated a simple, but otherwise manual and repetitive, task that might need to be performed. Running the playbook would be as simple as executing the following command:
ansible-playbook -i mastery-hosts reset-f5.yaml
Naturally, to actually test this playbook, you would have to have an F5 BIG-IP device to test against. Not everyone will have this available, so, in the next section of this chapter, we will move on to demonstrate a real-world example that everyone reading this book can work with. However, the intent of this part of this chapter has been to give you a solid overview of integrating your network devices, whatever they may be, with Ansible. Thus, it is hoped that even if you have a device that we haven't mentioned here, you understand the fundamentals of how to get it working.