O'Reilly logo

OpenStack Administration with Ansible 2 - Second Edition by Walter Bentley

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

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}}" ...

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