Let's jump right into examining the role we created called create-snapshot
. The completed role and file named main.yml
located in the create-snapshot/tasks
directory looks similar to this:
--- - name: Retrieve tenantID shell: keystone --os-username={{ OS_USERNAME }} --os-password={{ OS_PASSWORD }} --os-tenant-name={{ OS_TENANT_NAME }} --os-auth-url={{ OS_AUTH_URL }} tenant-list | awk '/ {{ tenantname }} / { print $2 }' register: tenantid - name: Retrieve instance id from tenant shell: nova --os-username={{ OS_USERNAME }} --os-password={{ OS_PASSWORD }} --os-tenant-name={{ OS_TENANT_NAME }} --os-auth-url={{ OS_AUTH_URL }} list --all-tenants --tenant {{ tenantid.stdout }} --minimal | awk 'NR > 3 { print $2 }' register: instid - name: Create instance snapshot command: nova --os-username={{ OS_USERNAME }} --os-password={{ OS_PASSWORD }} --os-tenant-name={{ OS_TENANT_NAME }} --os-auth-url={{ OS_AUTH_URL }} image-create {{ item }} {{ tenantname }}-snap-{{ item }...