diff --git a/example.py b/example.py index 2c944a81..72b0fd3c 100644 --- a/example.py +++ b/example.py @@ -74,6 +74,7 @@ def deploy(): admin_user = vr.create('admin_user', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_user'), {'user_name': 'admin', 'user_password': 'admin'})[0] admin_role = vr.create('admin_role', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_role'), {'role_name': 'admin'})[0] keystone_service_endpoint = vr.create('keystone_service_endpoint', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_service_endpoint'), {'adminurl': 'http://{{ip}}:{{admin_port}}/v2.0', 'internalurl': 'http://{{ip}}:{{port}}/v2.0', 'publicurl': 'http://{{ip}}:{{port}}/v2.0', 'description': 'OpenStack Identity Service', 'type': 'identity'})[0] + openrc = vr.create('openrc_file', 'resources/openrc_file', {'ip':'', 'ssh_key' : '', 'ssh_user':'', 'keystone_host':'', 'keystone_port':'', 'user_name':'','password':'', 'tenant': ''})[0] #### @@ -177,6 +178,9 @@ def deploy(): signals.connect(keystone_service1, glance_api_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port'}) signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'admin_port'}) signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'port'}) + signals.connect(node1, openrc) + signals.connect(keystone_service1, openrc, {'ip': 'keystone_host', 'admin_port':'keystone_port'}) + signals.connect(admin_user, openrc, {'user_name': 'user_name','user_password':'password', 'tenant_name': 'tenant'}) errors = vr.validate_resources() @@ -205,6 +209,7 @@ def deploy(): actions.resource_action(admin_user, 'run') actions.resource_action(admin_role, 'run') actions.resource_action(keystone_service_endpoint, 'run') + actions.resource_action(openrc, 'run') actions.resource_action(services_tenant, 'run') actions.resource_action(glance_keystone_user, 'run') @@ -276,6 +281,7 @@ def undeploy(): actions.resource_action(resources['glance_keystone_user'], 'remove') actions.resource_action(resources['glance_keystone_tenant'], 'remove') + actions.resource_action(resources['openrc_file'], 'remove') actions.resource_action(resources['keystone_service_endpoint'], 'remove') actions.resource_action(resources['admin_role'], 'remove') actions.resource_action(resources['admin_user'], 'remove') diff --git a/resources/openrc_file/actions/remove.yaml b/resources/openrc_file/actions/remove.yaml new file mode 100644 index 00000000..7f1884b4 --- /dev/null +++ b/resources/openrc_file/actions/remove.yaml @@ -0,0 +1,5 @@ +- hosts: [ {{ ip }} ] + sudo: yes + tasks: + - file: path=/root/openrc state=absent + diff --git a/resources/openrc_file/actions/run.yaml b/resources/openrc_file/actions/run.yaml new file mode 100644 index 00000000..510b4caa --- /dev/null +++ b/resources/openrc_file/actions/run.yaml @@ -0,0 +1,10 @@ +- hosts: [{{ ip }}] + sudo: yes + vars: + tenant: {{tenant}} + user_name: {{user_name}} + password: {{password}} + keystone_host: {{keystone_host}} + keystone_port: {{keystone_port}} + tasks: + - template: src={{resource_dir}}/templates/openrc.template dest=/root/openrc diff --git a/resources/openrc_file/meta.yaml b/resources/openrc_file/meta.yaml new file mode 100644 index 00000000..0ea09051 --- /dev/null +++ b/resources/openrc_file/meta.yaml @@ -0,0 +1,29 @@ +id: nova_config +handler: ansible +version: 1.0.0 + +input: + keystone_host: + schema: str! + value: + keystone_port: + schema: int! + value: + tenant: + schema: str! + value: + user_name: + schema: str! + value: + password: + schema: str! + value: + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: diff --git a/resources/openrc_file/templates/openrc.template b/resources/openrc_file/templates/openrc.template new file mode 100644 index 00000000..7f7e548d --- /dev/null +++ b/resources/openrc_file/templates/openrc.template @@ -0,0 +1,9 @@ +#!/bin/sh +export LC_ALL=C +export OS_NO_CACHE="true" +export OS_TENANT_NAME={{tenant}} +export OS_USERNAME={{user_name}} +export OS_PASSWORD={{password}} +export OS_AUTH_URL=http://{{keystone_host}}:{{keystone_port}}/v2.0 +export OS_AUTH_STRATEGY=keystone +export OS_REGION_NAME='RegionOne'