# Hail Marry - Ansible - Open Stack

**URL:** <https://forum.ansible.com/t/hail-marry-ansible-open-stack/20906>\
**Category:** Ansible Project\
**Created:** [March 17, 2016, 1:58pm UTC](https://forum.ansible.com/t/hail-marry-ansible-open-stack/20906 "2016-03-17T13:58:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Biglin](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@David\_Biglin](https://forum.ansible.com/u/David_Biglin)\
**Post date:** [March 17, 2016, 1:58pm UTC](https://forum.ansible.com/t/hail-marry-ansible-open-stack/20906/1 "2016-03-17T13:58:38Z")

</div>

Hi all,

Sorry if this is in the wrong area for posting however I have been struggling for a while with this issue.

I am trying to use Ansible to build a VM environment on an OpenStack based Hypervisor.

I have used Ansible in the past to configure VMs once they have been configured.

I have read through the Ansible Doc’s and understand the OS Cloud management modules. However the issue I am having is regarding authentication with DataCentered our Cloud provider.

When I connect up using the CLI I can list all the servers and create new machines using python.

However the issue I am having is i cant seem to authenticate using Ansible.

Has anyone successfully managed to build new VMs on OpenStack with Ansible and would they happen to have some sample code which is not just on the Ansible Docs.

I have googled and only found how to install openstack with ansible.

Cheers in advance.

---

<div class="post-metadata">

**Author:** ![gundalow](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gundalow/32/99_2.png) [@gundalow](https://forum.ansible.com/u/gundalow)\
**Post date:** [March 19, 2016, 7:00pm UTC](https://forum.ansible.com/t/hail-marry-ansible-open-stack/20906/2 "2016-03-19T19:00:02Z")

</div>

Hi,  
You may find something useful here

> **[GitHub - openstack/openstack-ansible: Ansible playbooks for deploying OpenStack. Mirror...](https://github.com/openstack/openstack-ansible)**
>
> Ansible playbooks for deploying OpenStack. Mirror of code maintained at opendev.org.

Regards,  
John Barker

---

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [March 20, 2016, 5:20am UTC](https://forum.ansible.com/t/hail-marry-ansible-open-stack/20906/3 "2016-03-20T05:20:15Z")

</div>

Here is an example that works for me:

- name: launch compute instance  
&nbsp;&nbsp;hosts: localhost  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth\_url: "[http://controller:35357/v2.0/&quot](http://controller:35357/v2.0/&quot);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;project:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image: CentOS-7-x86\_64-GenericCloud-1601  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: somekey  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout: 200  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flavor: m1.small  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;security: default

&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;- name: launch instance  
&nbsp;&nbsp;&nbsp;&nbsp;os\_server:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth\_url: "{{ auth\_url }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: "{{ username }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: "{{ password }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;project\_name: "{{ project }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: test  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image: "{{ image }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key\_name: "{{ key }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout: "{{ timeout }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flavor: "{{ flavor }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;security\_groups: "{{ security }}"

---

<div class="post-metadata">

**Author:** ![David\_Shrewsbury1](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@David\_Shrewsbury1](https://forum.ansible.com/u/David_Shrewsbury1)\
**Post date:** [March 21, 2016, 8:41pm UTC](https://forum.ansible.com/t/hail-marry-ansible-open-stack/20906/4 "2016-03-21T20:41:01Z")

</div>

You’re probably running into versioning issues.

The OpenStack modules support reading authentication information from a clouds.yamlfile. I’d suggest using this method since Datacentred is one of the known providers that  
is known to work, and we automatically set the versions of the various services supplied  
by that provider. Otherwise you’d need to do that manually, which is a pain.

It would look something like this:

clouds:  
mycloud:  
profile: datacentred  
auth:  
username: MY\_USERNAME  
password: MY\_PASSWORD  
project\_name: MY\_PROJECT\_NAME

You’d then just set “cloud: mycloud” in your tasks. A detailed example can be found in  
my blog post:

[http://dshrewsbury.blogspot.com/2015/07/ansible-openstack-user-modules.html](http://dshrewsbury.blogspot.com/2015/07/ansible-openstack-user-modules.html)

Give that a try and see if that gets you going.

-Dave
