From 7dfd32eb1a002e12db8cef05b371b5d28f3b2fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 16 Jul 2015 22:59:08 +0000 Subject: [PATCH 1/5] nova-api resource --- example-puppet.py | 97 ++++++++++++++++++++++------ resources/nova/actions/remove.yml | 6 -- resources/nova/actions/run.yml | 6 -- resources/nova/meta.yaml | 13 ---- resources/nova_api/actions/remove.pp | 29 +++++++++ resources/nova_api/actions/run.pp | 33 ++++++++++ resources/nova_api/meta.yaml | 59 +++++++++++++++++ 7 files changed, 197 insertions(+), 46 deletions(-) delete mode 100644 resources/nova/actions/remove.yml delete mode 100644 resources/nova/actions/run.yml delete mode 100644 resources/nova/meta.yaml create mode 100644 resources/nova_api/actions/remove.pp create mode 100644 resources/nova_api/actions/run.pp create mode 100644 resources/nova_api/meta.yaml diff --git a/example-puppet.py b/example-puppet.py index 72d4f431..690b343a 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -238,25 +238,75 @@ def deploy(): # signals.connect(cinder_keystone_user, cinder_keystone_role) # NOVA - # #nova_network_puppet = vr.create('nova_network_puppet', GitProvider(GIT_PUPPET_LIBS_URL, 'nova_network'), {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0] - # # TODO: fix rabbitmq user/password - # nova_network_puppet = vr.create('nova_network_puppet', 'resources/nova_network_puppet', {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0] + nova_api = vr.create('nova_api', 'resources/nova_api', {})[0] + nova_db = vr.create('nova_db', 'resources/mariadb_db/', { + 'db_name': 'nova_db', + 'login_user': 'root'})[0] + nova_db_user = vr.create('nova_db_user', 'resources/mariadb_user/', { + 'user_name': 'nova', + 'user_password': 'nova', + 'login_user': 'root'})[0] + nova_keystone_user = vr.create('nova_keystone_user', 'resources/keystone_user', { + 'user_name': 'nova', + 'user_password': 'nova'})[0] + nova_keystone_role = vr.create('nova_keystone_role', 'resources/keystone_role', { + 'role_name': 'admin'})[0] + nova_keystone_service_endpoint = vr.create('nova_keystone_service_endpoint', 'resources/keystone_service_endpoint', { + 'endpoint_name': 'nova', + 'adminurl': 'http://{{admin_ip}}:{{admin_port}}/v2/%(tenant_id)s', + 'internalurl': 'http://{{internal_ip}}:{{internal_port}}/v2/%(tenant_id)s', + 'publicurl': 'http://{{public_ip}}:{{public_port}}/v2/%(tenant_id)s', + 'description': 'OpenStack Compute Service', + 'type': 'compute', + 'public_port': 8774, + 'internal_port': 8774, + 'admin_port': 8774})[0] - # nova_keystone_user = vr.create('nova_keystone_user', 'resources/keystone_user', {'user_name': 'nova', 'user_password': 'nova'})[0] - # nova_keystone_role = vr.create('nova_keystone_role', 'resources/keystone_role', {'role_name': 'nova'})[0] + signals.connect(node1, nova_api) + signals.connect(node1, nova_db) + signals.connect(node1, nova_db_user) + signals.connect(mariadb_service1, nova_db, { + 'port': 'login_port', + 'root_password': 'login_password'}) + signals.connect(mariadb_service1, nova_db_user, { + 'port': 'login_port', + 'root_password': 'login_password'}) + signals.connect(nova_db, nova_db_user, { + 'db_name': 'db_name'}) + signals.connect(services_tenant, nova_keystone_user) + signals.connect(nova_keystone_user, nova_keystone_role) + signals.connect(keystone_puppet, nova_api, { + 'ip': 'keystone_host', + 'admin_port': 'keystone_port'}) + signals.connect(nova_keystone_user, nova_api, { + 'user_name': 'keystone_user_name', + 'tenant_name': 'keystone_tenant_name', + 'user_password': 'keystone_password'}) + signals.connect(rabbitmq_service1, nova_api, { + 'ip': 'rabbitmq_host'}) + signals.connect(openstack_rabbitmq_user, nova_api, { + 'user_name': 'rabbitmq_user', + 'password': 'rabbitmq_password'}) + signals.connect(keystone_puppet, nova_keystone_service_endpoint, { + 'ip': 'keystone_host', + 'admin_port': 'keystone_admin_port', + 'admin_token': 'admin_token'}) + signals.connect(mariadb_service1, nova_api, { + 'ip':'db_host'}) + signals.connect(nova_db_user, nova_api, { + 'user_name':'db_user', + 'db_name':'db_name', + 'user_password':'db_password'}) + signals.connect(nova_api, nova_keystone_service_endpoint, { + 'ip': ['ip', 'public_ip', 'internal_ip', 'admin_ip'], + 'ssh_key': 'ssh_key', + 'ssh_user': 'ssh_user'}) + signals.connect(nova_api, nova_keystone_service_endpoint, { + 'ip': 'ip', + 'ssh_key': 'ssh_key', + 'ssh_user': 'ssh_user'}) - # TODO: 'services' tenant-id is hardcoded - # nova_keystone_service_endpoint = vr.create('nova_keystone_service_endpoint', 'resources/keystone_service_endpoint', {'adminurl': 'http://{{ip}}:{{admin_port}}/v2/services', 'internalurl': 'http://{{ip}}:{{public_port}}/v2/services', 'publicurl': 'http://{{ip}}:{{port}}/v2/services', 'description': 'OpenStack Compute Service', 'type': 'compute', 'port': 8776, 'admin_port': 8776})[0] - - # signals.connect(node1, nova_network_puppet) - - # signals.connect(services_tenant, nova_keystone_user) - # signals.connect(neutron_keystone_user, nova_keystone_role) - - # signals.connect(nova_keystone_user, nova_network_puppet, {'user_name': 'keystone_user', 'user_password': 'keystone_password', 'tenant_name': 'keystone_tenant'}) # signals.connect(keystone_puppet, nova_network_puppet, {'ip': 'keystone_host', 'port': 'keystone_port'}) - - # signals.connect(nova_network_puppet, nova_keystone_service_endpoint, {'ip': 'ip', 'ssh_key': 'ssh_key', 'ssh_user': 'ssh_user'}) # signals.connect(keystone_puppet, nova_keystone_service_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port', 'admin_token': 'admin_token'}) # signals.connect(rabbitmq_service1, nova_network_puppet, {'ip': 'rabbitmq_host', 'port': 'rabbitmq_port'}) @@ -308,11 +358,12 @@ def deploy(): # actions.resource_action(cinder_puppet, 'run') - # actions.resource_action(nova_keystone_user, 'run') - # actions.resource_action(nova_keystone_role, 'run') - - # actions.resource_action(nova_network_puppet, 'run') - #actions.resource_action(nova_keystone_service_endpoint, 'run') + actions.resource_action(nova_db, 'run') + actions.resource_action(nova_db_user, 'run') + actions.resource_action(nova_keystone_user, 'run') + actions.resource_action(nova_keystone_role, 'run') + actions.resource_action(nova_api, 'run') + actions.resource_action(nova_keystone_service_endpoint, 'run') time.sleep(10) @@ -322,6 +373,10 @@ def undeploy(): db = get_db() to_remove = [ + 'nova_db', + 'nova_db_user', + 'nova_keystone_service_endpoint', + 'nova_api', 'neutron_keystone_service_endpoint', 'neutron_puppet', 'neutron_keystone_role', diff --git a/resources/nova/actions/remove.yml b/resources/nova/actions/remove.yml deleted file mode 100644 index 76142acf..00000000 --- a/resources/nova/actions/remove.yml +++ /dev/null @@ -1,6 +0,0 @@ -# TODO -- hosts: [{{ ip }}] - sudo: yes - tasks: - - shell: docker stop {{ name }} - - shell: docker rm {{ name }} diff --git a/resources/nova/actions/run.yml b/resources/nova/actions/run.yml deleted file mode 100644 index e223fe8f..00000000 --- a/resources/nova/actions/run.yml +++ /dev/null @@ -1,6 +0,0 @@ -# TODO -- hosts: [{{ ip }}] - sudo: yes - tasks: - - shell: docker run -d --net="host" --privileged \ - --name {{ name }} {{ image }} diff --git a/resources/nova/meta.yaml b/resources/nova/meta.yaml deleted file mode 100644 index 5c48b0b9..00000000 --- a/resources/nova/meta.yaml +++ /dev/null @@ -1,13 +0,0 @@ -id: nova -handler: ansible -version: 1.0.0 -input: - ip: - schema: str! - value: - port: - schema: int! - value: 8774 - image: # TODO - schema: str! - value: diff --git a/resources/nova_api/actions/remove.pp b/resources/nova_api/actions/remove.pp new file mode 100644 index 00000000..4d6c4864 --- /dev/null +++ b/resources/nova_api/actions/remove.pp @@ -0,0 +1,29 @@ +$resource = hiera($::resource_name) + +$rabbitmq_user = $resource['input']['rabbitmq_user']['value'] +$rabbitmq_password = $resource['input']['rabbitmq_password']['value'] +$rabbitmq_host = $resource['input']['rabbitmq_host']['value'] +$db_user = $resource['input']['db_user']['value'] +$db_password = $resource['input']['db_password']['value'] +$db_name = $resource['input']['db_name']['value'] +$db_host = $resource['input']['db_host']['value'] +$keystone_password = $resource['input']['keystone_password']['value'] +$keystone_host = $resource['input']['keystone_host']['value'] +$keystone_port = $resource['input']['keystone_port']['value'] +$keystone_tenant_name = $resource['input']['keystone_tenant_name']['value'] +$keystone_user = $resource['input']['keystone_user_name']['value'] + +class { 'nova': + database_connection => "mysql://${db_user}:${db_password}@${db_host}/${db_name}?charset=utf8", + rabbit_userid => $rabbitmq_user, + rabbit_password => $rabbitmq_password, + rabbit_host => $rabbitmq_host, + image_service => 'nova.image.glance.GlanceImageService', + glance_api_servers => 'localhost:9292', + verbose => false, +} + +class { 'nova::api': + admin_password => $keystone_password, + ensure_package => 'absent' +} diff --git a/resources/nova_api/actions/run.pp b/resources/nova_api/actions/run.pp new file mode 100644 index 00000000..c1384f8b --- /dev/null +++ b/resources/nova_api/actions/run.pp @@ -0,0 +1,33 @@ +$resource = hiera($::resource_name) + +$rabbitmq_user = $resource['input']['rabbitmq_user']['value'] +$rabbitmq_password = $resource['input']['rabbitmq_password']['value'] +$rabbitmq_host = $resource['input']['rabbitmq_host']['value'] +$db_user = $resource['input']['db_user']['value'] +$db_password = $resource['input']['db_password']['value'] +$db_name = $resource['input']['db_name']['value'] +$db_host = $resource['input']['db_host']['value'] +$keystone_password = $resource['input']['keystone_password']['value'] +$keystone_host = $resource['input']['keystone_host']['value'] +$keystone_port = $resource['input']['keystone_port']['value'] +$keystone_tenant_name = $resource['input']['keystone_tenant_name']['value'] +$keystone_user = $resource['input']['keystone_user_name']['value'] + +class { 'nova': + database_connection => "mysql://${db_user}:${db_password}@${db_host}/${db_name}?charset=utf8", + rabbit_userid => $rabbitmq_user, + rabbit_password => $rabbitmq_password, + rabbit_host => $rabbitmq_host, + image_service => 'nova.image.glance.GlanceImageService', + glance_api_servers => 'localhost:9292', + verbose => false, +} + +class { 'nova::api': + enabled => true, + admin_user => $keystone_user, + admin_password => $keystone_password, + auth_host => $keystone_host, + auth_port => $keystone_port, + admin_tenant_name => $keystone_tenant_name, +} diff --git a/resources/nova_api/meta.yaml b/resources/nova_api/meta.yaml new file mode 100644 index 00000000..55f033ec --- /dev/null +++ b/resources/nova_api/meta.yaml @@ -0,0 +1,59 @@ +id: nova +handler: puppet +puppet_module: nova +version: 1.0.0 +input: + db_user: + schema: str! + value: nova + db_password: + schema: str! + value: + db_name: + schema: str! + value: + db_host: + schema: str! + value: + + rabbitmq_user: + schema: str! + value: + rabbitmq_password: + schema: str! + value: + rabbitmq_host: + schema: str! + value: + + keystone_password: + schema: str! + value: + keystone_port: + schema: int! + value: + keystone_host: + schema: str! + value: + keystone_tenant_name: + schema: str! + value: + keystone_user_name: + schema: str! + value: + + git: + schema: {repository: str!, branch: str!} + value: {repository: 'https://github.com/openstack/puppet-nova', branch: 'stable/juno'} + + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: + +tags: [resource/nova_service, resources/nova] From 21f18a5f75e13780d4950fce072e80e7db516417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 17 Jul 2015 12:46:53 +0000 Subject: [PATCH 2/5] add tag --- resources/nova_api/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/nova_api/meta.yaml b/resources/nova_api/meta.yaml index 55f033ec..96ff21dc 100644 --- a/resources/nova_api/meta.yaml +++ b/resources/nova_api/meta.yaml @@ -56,4 +56,4 @@ input: schema: str! value: -tags: [resource/nova_service, resources/nova] +tags: [resource/nova_service, resources/nova, resource/nova-api] From 674dbb5709010c3a3288019463a5e581f31eff8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 17 Jul 2015 12:52:50 +0000 Subject: [PATCH 3/5] change path --- example-puppet.py | 2 +- resources/{nova_api => nova_api_puppet}/actions/remove.pp | 0 resources/{nova_api => nova_api_puppet}/actions/run.pp | 0 resources/{nova_api => nova_api_puppet}/meta.yaml | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename resources/{nova_api => nova_api_puppet}/actions/remove.pp (100%) rename resources/{nova_api => nova_api_puppet}/actions/run.pp (100%) rename resources/{nova_api => nova_api_puppet}/meta.yaml (100%) diff --git a/example-puppet.py b/example-puppet.py index 690b343a..f83a5149 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -238,7 +238,7 @@ def deploy(): # signals.connect(cinder_keystone_user, cinder_keystone_role) # NOVA - nova_api = vr.create('nova_api', 'resources/nova_api', {})[0] + nova_api = vr.create('nova_api', 'resources/nova_api_puppet', {})[0] nova_db = vr.create('nova_db', 'resources/mariadb_db/', { 'db_name': 'nova_db', 'login_user': 'root'})[0] diff --git a/resources/nova_api/actions/remove.pp b/resources/nova_api_puppet/actions/remove.pp similarity index 100% rename from resources/nova_api/actions/remove.pp rename to resources/nova_api_puppet/actions/remove.pp diff --git a/resources/nova_api/actions/run.pp b/resources/nova_api_puppet/actions/run.pp similarity index 100% rename from resources/nova_api/actions/run.pp rename to resources/nova_api_puppet/actions/run.pp diff --git a/resources/nova_api/meta.yaml b/resources/nova_api_puppet/meta.yaml similarity index 100% rename from resources/nova_api/meta.yaml rename to resources/nova_api_puppet/meta.yaml From 21112df4f69bf58c79b4bdc21bb18885ddc78c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Mon, 20 Jul 2015 10:07:02 +0000 Subject: [PATCH 4/5] Remove nodename --- resources/rabbitmq_service/actions/remove.pp | 3 --- resources/rabbitmq_service/actions/run.pp | 1 - resources/rabbitmq_service/meta.yaml | 3 --- 3 files changed, 7 deletions(-) diff --git a/resources/rabbitmq_service/actions/remove.pp b/resources/rabbitmq_service/actions/remove.pp index 1047bc46..f1121da5 100644 --- a/resources/rabbitmq_service/actions/remove.pp +++ b/resources/rabbitmq_service/actions/remove.pp @@ -1,11 +1,8 @@ $resource = hiera($::resource_name) -$node_name = $resource['input']['node_name']['value'] - class { '::rabbitmq': package_ensure => 'absent', environment_variables => { - 'RABBITMQ_NODENAME' => $node_name, 'RABBITMQ_SERVICENAME' => 'RabbitMQ' } } diff --git a/resources/rabbitmq_service/actions/run.pp b/resources/rabbitmq_service/actions/run.pp index befa93d9..2ea22054 100644 --- a/resources/rabbitmq_service/actions/run.pp +++ b/resources/rabbitmq_service/actions/run.pp @@ -2,7 +2,6 @@ $resource = hiera($::resource_name) $port = "${resource['input']['port']['value']}" $management_port = "${resource['input']['management_port']['value']}" -$node_name = $resource['input']['node_name']['value'] class { '::rabbitmq': service_manage => true, diff --git a/resources/rabbitmq_service/meta.yaml b/resources/rabbitmq_service/meta.yaml index 69ef8a08..010753fc 100644 --- a/resources/rabbitmq_service/meta.yaml +++ b/resources/rabbitmq_service/meta.yaml @@ -11,9 +11,6 @@ input: schema: str! value: '' - node_name: - schema: str! - value: 'node1' port: schema: int! value: '' From 32b8edac419dbf7f4586647fa4e45f3bdcb8f91a Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Wed, 29 Jul 2015 12:04:41 +0200 Subject: [PATCH 5/5] Fix db_host connections for nova resource Signed-off-by: Bogdan Dobrelya --- example-puppet.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/example-puppet.py b/example-puppet.py index 17be43de..42b410d7 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -308,12 +308,13 @@ def deploy(): signals.connect(node1, nova_db_user) signals.connect(mariadb_service1, nova_db, { 'port': 'login_port', - 'root_password': 'login_password'}) + 'root_password': 'login_password', + 'root_user': 'login_user', + 'ip' : 'db_host'}) signals.connect(mariadb_service1, nova_db_user, { 'port': 'login_port', 'root_password': 'login_password'}) - signals.connect(nova_db, nova_db_user, { - 'db_name': 'db_name'}) + signals.connect(nova_db, nova_db_user, {'db_name', 'db_host'}) signals.connect(services_tenant, nova_keystone_user) signals.connect(nova_keystone_user, nova_keystone_role) signals.connect(keystone_puppet, nova_api, { @@ -337,7 +338,8 @@ def deploy(): signals.connect(nova_db_user, nova_api, { 'user_name':'db_user', 'db_name':'db_name', - 'user_password':'db_password'}) + 'user_password':'db_password', + 'db_host' : 'db_host'}) signals.connect(nova_api, nova_keystone_service_endpoint, { 'ip': ['ip', 'public_ip', 'internal_ip', 'admin_ip'], 'ssh_key': 'ssh_key',