This demonstrates a playbook I wrote to automate the tasks outlined in my previous video here: • OpenStack: Add New Project/User/Network vi...
Playbook on Github: https://github.com/vvaldez/ansible-op...
I've been working with Ansible a lot lately and have mostly used the shell/command module to execute the OpenStack CLI client. I know 2.0 and 2.1 have os_server modules, but for my current project work I am limited to 1.9.x for now.
This led me to explore the URI module. I couldn't find any specific examples online showing the URI module making OpenStack API calls. I can see why, I couldn't get the Identity auth tokens to work with v2.0 API, but was able to do so with the v3 API (using nearly the exact same syntax of the body payload).
I much prefer this method over using OpenStack clients for several reasons. First, it is much quicker as you can obtain a token once, then reuse that for the remaining tasks, rather than the CLI which authenticates on every execution. But most importantly the return data of each call results in JSON which Ansible is very efficient at handling. There is a closed Won't Fix bug to add JSON support here: https://bugs.launchpad.net/python-nov...