summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-10-20 08:07:27 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-10-20 13:20:14 +0000
commitd2f2bfb1fa955baf2023fc9cfa12a88c5a7b527f (patch)
tree4c0bbb5c38845aa11e0706491a2c89ca692a5cc5
parent41e9602244454495a480b0075bba31a9c7d1afc8 (diff)
downloaddefinitions-d2f2bfb1fa955baf2023fc9cfa12a88c5a7b527f.tar.gz
Use Ansible to generate config for OpenStack
-rw-r--r--mason.configure18
-rw-r--r--mason/ansible/mason-setup.yml22
-rwxr-xr-xmason/mason.sh2
-rw-r--r--mason/share/os.conf (renamed from mason/os.conf)10
4 files changed, 46 insertions, 6 deletions
diff --git a/mason.configure b/mason.configure
index 8b4532e0..e5695dea 100644
--- a/mason.configure
+++ b/mason.configure
@@ -24,6 +24,8 @@
# * MASON_DEFINITIONS_REF
# * MASON_DISTBUILD_ARCH
# * MASON_TEST_HOST
+# * OPENSTACK_NET_ID
+# * TEST_INFRA
# * TROVE_HOST
# * TROVE_ID
# * CONTROLLERHOST
@@ -41,6 +43,7 @@ ROOT="$1"
mkdir -p "$ROOT"/usr/lib/mason
cp mason/mason.sh "$ROOT"/usr/lib/mason/mason.sh
cp mason/mason-report.sh "$ROOT"/usr/lib/mason/mason-report.sh
+cp mason/os-init-script "$ROOT"/usr/lib/mason/os-init-script
cp mason/mason.timer "$ROOT"/etc/systemd/system/mason.timer
@@ -118,6 +121,21 @@ mason_configuration={
yaml.dump(mason_configuration, sys.stdout, default_flow_style=False)
EOF
+if [ "$TEST_INFRA" = "openstack" ]; then
+ python <<'EOF' >"$MASON_DATA/os.conf"
+import os, sys, yaml
+
+openstack_credentials={
+ 'OS_USERNAME': os.environ['OPENSTACK_USER'],
+ 'OS_TENANT_NAME': os.environ['OPENSTACK_TENANT'],
+ 'OS_TENANT_ID': os.environ['OPENSTACK_TENANT_ID'],
+ 'OS_AUTH_URL': os.environ['OPENSTACK_AUTH_URL'],
+ 'OS_PASSWORD': os.environ['OPENSTACK_PASSWORD'],
+}
+
+yaml.dump(openstack_credentials, sys.stdout, default_flow_style=False)
+EOF
+fi
##########################################################################
# Enable services
diff --git a/mason/ansible/mason-setup.yml b/mason/ansible/mason-setup.yml
index f15559f6..e1c371b0 100644
--- a/mason/ansible/mason-setup.yml
+++ b/mason/ansible/mason-setup.yml
@@ -2,6 +2,7 @@
- hosts: localhost
vars_files:
- "/etc/mason/mason.conf"
+ - "/etc/mason/os.conf"
tasks:
@@ -35,11 +36,32 @@
- fail: msg='OPENSTACK_NET_ID is mandatory when TEST_INFRA=openstack'
when: TEST_INFRA == "openstack" and OPENSTACK_NET_ID is not defined
+ - fail: msg='OS_USERNAME is mandatory when TEST_INFRA=openstack'
+ when: TEST_INFRA == "openstack" and OS_USERNAME is not defined
+
+ - fail: msg='OS_PASSWORD is mandatory when TEST_INFRA=openstack'
+ when: TEST_INFRA == "openstack" and OS_PASSWORD is not defined
+
+ - fail: msg='OS_TENANT_ID is mandatory when TEST_INFRA=openstack'
+ when: TEST_INFRA == "openstack" and OS_TENANT_ID is not defined
+
+ - fail: msg='OS_TENANT_NAME is mandatory when TEST_INFRA=openstack'
+ when: TEST_INFRA == "openstack" and OS_TENANT_NAME is not defined
+
+ - fail: msg='OS_AUTH_URL is mandatory when TEST_INFRA=openstack'
+ when: TEST_INFRA == "openstack" and OS_AUTH_URL is not defined
+
- name: Create the Mason configuration file
template: src=/usr/share/mason-setup/{{ item }} dest=/etc/{{ item }}
with_items:
- mason.conf
+ - name: Create the OpenStack credentials file
+ template: src=/usr/share/mason-setup/{{ item }} dest=/etc/{{ item }}
+ with_items:
+ - os.conf
+ when: TEST_INFRA == "openstack"
+
- name: Enable the mason service
service: name=mason.service enabled=yes
register: mason_service
diff --git a/mason/mason.sh b/mason/mason.sh
index dbcfdb4a..39c2e850 100755
--- a/mason/mason.sh
+++ b/mason/mason.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Load OpenStack credentials
-. /root/os.conf
+. /etc/os.conf
set -e
set -x
diff --git a/mason/os.conf b/mason/share/os.conf
index d9f69fda..64a19f19 100644
--- a/mason/os.conf
+++ b/mason/share/os.conf
@@ -7,17 +7,17 @@
#
# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We
# will use the 1.1 *compute api*
-export OS_AUTH_URL=<os-auth-url>
+export OS_AUTH_URL={{ OS_AUTH_URL|quote }}
# With the addition of Keystone we have standardized on the term **tenant**
# as the entity that owns the resources.
-export OS_TENANT_ID=<os-tenant-id>
-export OS_TENANT_NAME="<os-tenant>"
+export OS_TENANT_ID={{ OS_TENANT_ID|quote }}
+export OS_TENANT_NAME={{ OS_TENANT_NAME|quote }}
# In addition to the owning entity (tenant), openstack stores the entity
# performing the action as the **user**.
-export OS_USERNAME="<os-user>"
+export OS_USERNAME={{ OS_USERNAME|quote }}
# With Keystone you pass the keystone password.
-export OS_PASSWORD="<os-pass>"
+export OS_PASSWORD={{ OS_PASSWORD|quote }}