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.
Hi,
You may find something useful here
https://github.com/openstack/openstack-ansible
Regards,
John Barker
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’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
Give that a try and see if that gets you going.
-Dave