Using Ansible to launch instances
Launching an instance using Ansible is a convenient, platform agnostic method. While we have to specify how to do this for OpenStack, as a particular task, an Ansible playbook could be extended to allow a user to use the same Ansible command to launch an instance on any cloud. This recipe is a very basic introduction to the use of Ansible with OpenStack.
Getting ready
Ensure that you are logged on to a correctly configured OpenStack client and can access the OpenStack environment that has Ansible installed.
How to do it...
Ansible executes tasks in what is known as a playbook. In this example, we will create a simple task that launches a specific instance called cookbook1
:
The first step is to create the Ansible playbook for our tasks that will launch our instance. Create the following file called
launch-instance.yml
on your client, in a directory of your choosing:- name: Launch instance on OpenStack hosts: localhost gather_facts: false tasks: - name...