Reviewing playbooks and roles

Let's jump right into examining the role we created, named create-snapshot. The completed role and file, named main.yml, located in the create-snapshot/tasks directory, looks like this:

--- - name: Retrieve tenantID shell: openstack --os-cloud="{{ CLOUD_NAME }}" project list | awk '/ "{{tenantname}}" / { print $2 }' register: tenantid - name: Retrieve instance id from tenant shell: openstack --os-cloud="{{ CLOUD_NAME }}" server list --all-projects --project "{{ tenantid.stdout }}" | awk 'NR > 3 { print $2 }' register: instid - name: Create instance snapshot command: openstack --os-cloud="{{ CLOUD_NAME }}" server image create --name="{{ tenantname }}"-snap-"{{ item }}" "{{ item }}" with_items: "{{instid.stdout_lines}}" ...

Get OpenStack Administration with Ansible 2 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.