Hail Marry - Ansible - Open Stack

26 views
Skip to first unread message

David Biglin

unread,
Mar 18, 2016, 4:00:12 PM3/18/16
to Ansible Project
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. 


John Barker

unread,
Mar 19, 2016, 3:00:02 PM3/19/16
to Ansible Project
Hi,
You may find something useful here

Regards,
John Barker

John Favorite

unread,
Mar 20, 2016, 1:20:39 AM3/20/16
to Ansible Project
Here is an example that works for me:

- name: launch compute instance
hosts: localhost
vars:
auth_url: "http://controller:35357/v2.0/"
username:
password:
project:
image: CentOS-7-x86_64-GenericCloud-1601
key: somekey
timeout: 200
flavor: m1.small
security: default

tasks:
- name: launch instance
os_server:
state: present
auth:
auth_url: "{{ auth_url }}"
username: "{{ username }}"
password: "{{ password }}"
project_name: "{{ project }}"
name: test
image: "{{ image }}"
key_name: "{{ key }}"
timeout: "{{ timeout }}"
flavor: "{{ flavor }}"
security_groups: "{{ security }}"
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3c0d3108-738d-4044-aa4c-09fe536fd9b7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

David Shrewsbury

unread,
Mar 21, 2016, 4:41:02 PM3/21/16
to Ansible Project
You're probably running into versioning issues.

The OpenStack modules support reading authentication information from a clouds.yaml
file. 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:


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

-Dave
Reply all
Reply to author
Forward
0 new messages