Book Image

OpenStack Administration with Ansible

By : Walter Bentley
Book Image

OpenStack Administration with Ansible

By: Walter Bentley

Overview of this book

Most organizations are seeking methods to improve business agility because they have realized just having a cloud is not enough. Being able to improve application deployments, reduce infrastructure downtime, and eliminate daily manual tasks can only be accomplished through some sort of automation. Packed with real-world OpenStack administrative tasks, this book will walk you through working examples and explain how these tasks can be automated using one of the most popular open source automation tools—Ansible. We will start with a brief overview of OpenStack and Ansible and highlight some best practices. Each chapter will provide an introduction to handling various Cloud Operator administration tasks such as creating multiple users/tenants, setting up Multi-Tenant Isolation, customizing your clouds quotas, taking instance snapshots, evacuating compute hosts for maintenance, and running cloud health checks, and a step-by-step tutorial on how to automate these tasks with Ansible.
Table of Contents (18 chapters)
OpenStack Administration with Ansible
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Playbook and role review


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