Skip to content

Instantly share code, notes, and snippets.

@alghanmi
Last active April 8, 2018 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alghanmi/f8c33d83f4536d159018 to your computer and use it in GitHub Desktop.
Save alghanmi/f8c33d83f4536d159018 to your computer and use it in GitHub Desktop.
Ansible OpenStack Test
[defaults]
inventory = hosts
log_path = logs/ansible.log
host_key_checking = no
record_host_keys = no
ssh_args = -o ControlMaster=auto -o ControlPersist=30m
gather_facts = smart
library = /opt/ansible/lib:
clouds:
cloudfire:
auth:
auth_url: 'https://keystone.example.com:443/v3'
username: rami_alghanmi
password: 'XXXXX'
project_id: 6fc52aecd7d94f4ab538cb9d9bd3fe78
project_domain_name: DEV
user_domain_name: DEV
region_name: ash2
private: true
#!/bin/bash
# v0.1
#
# With the addition of Keystone, to use an openstack cloud you should
# authenticate against keystone, which returns a **Token** and **Service
# Catalog**. The catalog contains the endpoint for all services the
# user/tenant has access to - including nova, glance, keystone, swift.
export OS_AUTH_URL=https://keystone.example.com:443/v3
export OS_IDENTITY_API_VERSION=3
export OS_USER_DOMAIN_NAME="DEV"
unset OS_DOMAIN_NAME
# With the addition of Keystone we have standardized on the term **tenant**
# as the entity that owns the resources.
export OS_TENANT_ID=6fc52aecd7d94f4ab538cb9d9bd3fe78
export OS_TENANT_NAME="rami-alghanmi"
export OS_PROJECT_NAME=$OS_TENANT_NAME
# In addition to the owning entity (tenant), openstack stores the entity
# performing the action as the **user**.
export OS_USERNAME="rami_alghanmi"
# With Keystone you pass the keystone password.
echo "Please enter your OpenStack Password: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT
echo "Please enter the OpenStack domain name of your project: "
read OS_PROJECT_DOMAIN_NAME_INPUT
export OS_PROJECT_DOMAIN_NAME=$OS_PROJECT_DOMAIN_NAME_INPUT
('envvars', 'ash2', {'auth_type': 'password', 'compute_api_version': '2', 'region_name': 'REGION', 'auth': {'username': 'rami_alghanmi', 'project_name': 'rami-alghanmi', 'user_domain_name': 'DEV', 'auth_url': 'https://keystone.example.com:443/v3', 'password': 'PASSWORD', 'project_domain_name': 'rami_alghanmi'}, 'network_api_version': '2', 'object_api_version': '1', 'image_api_version': '1', 'identity_api_version': '3', 'volume_api_version': '1'})
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- os_server:
#cloud: cloudfire
auth:
auth_url: https://keystone.example.com:443/v3
username: rami_alghanmi
password: 'XXXXX'
project_id: 6fc52aecd7d94f4ab538cb9d9bd3fe78
project_domain_name: DEV
region_name: ash2
state: present
name: vm-host-test-02
image: cpe-centos-7
flavor: v1-micro
key_name: rami_pub
auto_floating_ip: false
nics:
- net-id: f6e4d559-4119-495a-9e45-8f60460ee855
meta:
hostname: myhostname
group: somegroup
PLAY [localhost] **************************************************************
TASK: [os_server ] ************************************************************
failed: [localhost] => {"failed": true, "parsed": false}
Traceback (most recent call last):
File "/home/rami_alghanmi/.ansible/tmp/ansible-tmp-1430852034.42-179667716691565/os_server", line 2156, in <module>
main()
File "/home/rami_alghanmi/.ansible/tmp/ansible-tmp-1430852034.42-179667716691565/os_server", line 432, in main
cloud = shade.openstack_cloud(**cloud_params)
File "/usr/local/lib/python2.7/dist-packages/shade/__init__.py", line 80, in openstack_cloud
cloud_config = config.get_one_cloud(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/os_client_config/config.py", line 355, in get_one_cloud
config = self._get_base_cloud_config(cloud)
File "/usr/local/lib/python2.7/dist-packages/os_client_config/config.py", line 173, in _get_base_cloud_config
name=name))
os_client_config.exceptions.OpenStackConfigException: Named cloud cloudfire requested that was not found.
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/rami_alghanmi/os_server_test.retry
localhost : ok=0 changed=0 unreachable=0 failed=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment