diff --git a/resources/glance_api_service/meta.yaml b/resources/glance_api_service/meta.yaml index f1f06b6..213dffc 100644 --- a/resources/glance_api_service/meta.yaml +++ b/resources/glance_api_service/meta.yaml @@ -36,5 +36,8 @@ input: keystone_host: schema: str! value: + keystone_port: + schema: int! + value: tags: [resource/container] diff --git a/resources/glance_api_service/test.py b/resources/glance_api_service/test.py index d56e7f2..9cbe0fa 100644 --- a/resources/glance_api_service/test.py +++ b/resources/glance_api_service/test.py @@ -1,28 +1,30 @@ import json import requests +from solar.core.log import log + def test(resource): - print 'Testing glance_service' + log.debug('Testing glance_service') token_data = requests.post( - 'http://%s:%s/v2.0/tokens' % (resource.args['ip'].value, resource.args['listen_port'].value), + 'http://%s:%s/v2.0/tokens' % (resource.args['ip'].value, resource.args['keystone_port'].value), json.dumps({ 'auth': { - 'tenantName': resource.args['tenant_name'].value, + 'tenantName': 'services', 'passwordCredentials': { - 'username': resource.args['user_name'].value, - 'password': resource.args['user_password'].value, - } + 'username': 'glance_admin', + 'password': resource.args['keystone_password'].value, + } } }), headers={'Content-Type': 'application/json'} ) token = token_data.json()['access']['token']['id'] - print 'GLANCE TOKEN: {}'.format(token) + log.debug('GLANCE TOKEN: %s', token) images = requests.get( - 'http://%s:%s/v1/images' % (resource.args['ip'].value, resource.args['listen_port'].value), + 'http://%s:%s/v1/images' % (resource.args['ip'].value, 9393), headers={'X-Auth-Token': token} ) assert images.json() == {'images': []} diff --git a/resources/haproxy_service/test.py b/resources/haproxy_service/test.py index f5941d0..e760508 100644 --- a/resources/haproxy_service/test.py +++ b/resources/haproxy_service/test.py @@ -1,8 +1,10 @@ import requests +from solar.core.log import log + def test(resource): - print 'Testing haproxy_service' + log.debug('Testing haproxy_service') requests.get( 'http://%s:%s' % (resource.args['ip'].value, resource.args['ports'].value[0]['value'][0]['value']) ) diff --git a/resources/keystone_puppet/actions/remove.pp b/resources/keystone_puppet/actions/remove.pp new file mode 100644 index 0000000..958de8c --- /dev/null +++ b/resources/keystone_puppet/actions/remove.pp @@ -0,0 +1,4 @@ +class {'keystone': + admin_token => '{{ admin_token }}', + package_ensure => 'absent' +} diff --git a/resources/keystone_puppet/actions/run.pp b/resources/keystone_puppet/actions/run.pp new file mode 100644 index 0000000..0ee3018 --- /dev/null +++ b/resources/keystone_puppet/actions/run.pp @@ -0,0 +1,25 @@ +$resource = hiera($::resource_name) + +$ip = $resource['input']['ip']['value'] +$admin_token = $resource['input']['admin_token']['value'] +$db_user = $resource['input']['db_user']['value'] +$db_password = $resource['input']['db_password']['value'] +$db_name = $resource['input']['db_name']['value'] +$admin_port = $resource['input']['admin_port']['value'] +$port = $resource['input']['port']['value'] + +class {'keystone': + package_ensure => 'present', + verbose => True, + catalog_type => 'sql', + admin_token => $admin_token, + database_connection => "mysql://$db_user:$db_password@$ip/$db_name", + public_port => "$port", + token_driver => 'keystone.token.backends.kvs.Token' +} + +#file { '/etc/keystone/keystone-exports': +# owner => 'root', +# group => 'root', +# content => template('keystone/exports.erb') +#} diff --git a/resources/keystone_puppet/actions/update.pp b/resources/keystone_puppet/actions/update.pp new file mode 100644 index 0000000..eb2ef64 --- /dev/null +++ b/resources/keystone_puppet/actions/update.pp @@ -0,0 +1,7 @@ +class {'keystone': + verbose => True, + catalog_type => 'sql', + admin_token => '{{ admin_token }}', + sql_connection => 'mysql://{{ db_user }}:{{ db_password }}@{{ ip }}/{{ db_name }}', + public_port => '{{ port }}' +} diff --git a/resources/keystone_puppet/meta.yaml b/resources/keystone_puppet/meta.yaml new file mode 100644 index 0000000..e55a905 --- /dev/null +++ b/resources/keystone_puppet/meta.yaml @@ -0,0 +1,44 @@ +id: keystone_puppet +handler: puppet +puppet_module: keystone +version: 1.0.0 +input: + admin_token: + schema: str! + value: admin_token + db_user: + schema: str! + value: keystone + db_password: + schema: str! + value: keystone + db_name: + schema: str! + value: keystone + + admin_port: + schema: int! + value: 35357 + port: + schema: int! + value: 5000 + + git: + schema: {repository: str!, branch: str!} + value: {repository: 'https://github.com/openstack/puppet-keystone', branch: 'stable/juno'} + +# forge: +# schema: str! +# value: 'stackforge-keystone' + + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: + +tags: [resource/keystone_service, resources/keystone] diff --git a/resources/keystone_puppet/test.py b/resources/keystone_puppet/test.py new file mode 100644 index 0000000..a82c8ea --- /dev/null +++ b/resources/keystone_puppet/test.py @@ -0,0 +1,10 @@ +import requests + +from solar.core.log import log + + +def test(resource): + log.debug('Testing keystone_puppet') + requests.get( + 'http://%s:%s' % (resource.args['ip'].value, resource.args['port'].value) + ) diff --git a/resources/keystone_service/test.py b/resources/keystone_service/test.py index b397bd2..fb3d57e 100644 --- a/resources/keystone_service/test.py +++ b/resources/keystone_service/test.py @@ -1,8 +1,10 @@ import requests +from solar.core.log import log + def test(resource): - print 'Testing keystone_service' + log.debug('Testing keystone_service') requests.get( 'http://%s:%s' % (resource.args['ip'].value, resource.args['port'].value) ) diff --git a/resources/keystone_service_endpoint/actions/remove.yaml b/resources/keystone_service_endpoint/actions/remove.yaml index dadc9ae..cf415ce 100644 --- a/resources/keystone_service_endpoint/actions/remove.yaml +++ b/resources/keystone_service_endpoint/actions/remove.yaml @@ -16,5 +16,5 @@ adminurl: {{adminurl}} region: "RegionOne" state: present - endpoint: http://{{keystone_host}}:{{keystone_port}}/v2.0/ + endpoint: http://{{keystone_host}}:{{keystone_admin_port}}/v2.0/ diff --git a/resources/keystone_service_endpoint/meta.yaml b/resources/keystone_service_endpoint/meta.yaml index a140418..3af6d0e 100644 --- a/resources/keystone_service_endpoint/meta.yaml +++ b/resources/keystone_service_endpoint/meta.yaml @@ -11,33 +11,41 @@ input: admin_token: schema: str! value: + type: schema: str! + value: description: schema: str! - name: - schema: str! + value: public_ip: schema: str! + value: public_port: schema: int! + value: publicurl: schema: str! value: http://{{public_ip}}:{{public_port}}/v2.0 internal_ip: schema: str! + value: internal_port: schema: int! + value: internalurl: schema: str! value: http://{{ip}}:{{port}}/v2.0 admin_ip: schema: str! + value: admin_port: schema: int! + value: adminurl: schema: str! value: http://{{ip}}:{{admin_port}}/v2.0 + ip: schema: str! value: diff --git a/resources/keystone_service_endpoint/test.py b/resources/keystone_service_endpoint/test.py new file mode 100644 index 0000000..34f7b66 --- /dev/null +++ b/resources/keystone_service_endpoint/test.py @@ -0,0 +1,49 @@ +import jinja2 +import json +import requests + +from solar.core.log import log + + +def test(resource): + log.debug('Testing keystone_service_endpoint %s', resource.name) + + resp = requests.get( + 'http://%s:%s/v3/services' % (resource.args['ip'].value, resource.args['keystone_admin_port'].value), + headers={ + 'X-Auth-Token': resource.args['admin_token'].value, + } + ) + + resp_json = resp.json() + assert 'services' in resp_json + + service = [s for s in resp_json['services'] if s['name'] == resource.name][0] + service_id = service['id'] + + assert service['description'] == resource.args['description'].value + + log.debug('%s service: %s', resource.name, json.dumps(service, indent=2)) + + resp = requests.get( + 'http://%s:%s/v3/endpoints' % (resource.args['ip'].value, resource.args['keystone_admin_port'].value), + headers={ + 'X-Auth-Token': resource.args['admin_token'].value, + } + ) + + resp_json = resp.json() + assert 'endpoints' in resp_json + + endpoints = {} + + for endpoint in resp_json['endpoints']: + if endpoint['service_id'] == service_id: + endpoints[endpoint['interface']] = endpoint + + assert jinja2.Template(resource.args['adminurl'].value).render(**resource.args_dict()) == endpoints['admin']['url'] + assert jinja2.Template(resource.args['internalurl'].value).render(**resource.args_dict()) == endpoints['internal']['url'] + assert jinja2.Template(resource.args['publicurl'].value).render(**resource.args_dict()) == endpoints['public']['url'] + + log.debug('%s endpoints: %s', resource.name, json.dumps(endpoints, indent=2)) + diff --git a/resources/keystone_user/test.py b/resources/keystone_user/test.py new file mode 100644 index 0000000..b1c5f49 --- /dev/null +++ b/resources/keystone_user/test.py @@ -0,0 +1,27 @@ +import json +import requests + +from solar.core.log import log + + +def test(resource): + log.debug('Testing keystone_user %s', resource.args['user_name'].value) + + token_data = requests.post( + 'http://%s:%s/v2.0/tokens' % (resource.args['keystone_host'].value, + resource.args['keystone_port'].value), + json.dumps({ + 'auth': { + 'tenantName': resource.args['tenant_name'].value, + 'passwordCredentials': { + 'username': resource.args['user_name'].value, + 'password': resource.args['user_password'].value, + }, + }, + }), + headers={'Content-Type': 'application/json'} + ) + + token = token_data.json()['access']['token']['id'] + + log.debug('%s TOKEN: %s', resource.args['user_name'].value, token) diff --git a/resources/neutron_puppet/actions/remove.pp b/resources/neutron_puppet/actions/remove.pp new file mode 100644 index 0000000..d696795 --- /dev/null +++ b/resources/neutron_puppet/actions/remove.pp @@ -0,0 +1,22 @@ +$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'] +$rabbitmq_port = $resource['input']['rabbitmq_port']['value'] + +class { 'neutron::server': + enabled => false, + package_ensure => 'absent', + auth_type => 'noauth' +} + +class { 'neutron': + enabled => false, + package_ensure => 'absent', + rabbit_user => $rabbitmq_user, + rabbit_password => $rabbitmq_password, + rabbit_host => $rabbitmq_host, + rabbit_port => $rabbitmq_port +} + diff --git a/resources/neutron_puppet/actions/run.pp b/resources/neutron_puppet/actions/run.pp new file mode 100644 index 0000000..c57f3af --- /dev/null +++ b/resources/neutron_puppet/actions/run.pp @@ -0,0 +1,44 @@ +$resource = hiera('{{ resource_name }}') + +$ip = $resource['input']['ip']['value'] + +$rabbitmq_user = $resource['input']['rabbitmq_user']['value'] +$rabbitmq_password = $resource['input']['rabbitmq_password']['value'] +$rabbitmq_host = $resource['input']['rabbitmq_host']['value'] +$rabbitmq_port = $resource['input']['rabbitmq_port']['value'] + +$keystone_host = $resource['input']['keystone_host']['value'] +$keystone_port = $resource['input']['keystone_port']['value'] +$keystone_user = $resource['input']['keystone_user']['value'] +$keystone_password = $resource['input']['keystone_password']['value'] +$keystone_tenant = $resource['input']['keystone_tenant']['value'] + +class { 'neutron': + debug => true, + verbose => true, + enabled => true, + package_ensure => 'present', + auth_strategy => 'keystone', + rabbit_user => $rabbitmq_user, + rabbit_password => $rabbitmq_password, + rabbit_host => $rabbitmq_host, + rabbit_port => $rabbitmq_port, + service_plugins => ['metering'] +} + +class { 'neutron::server': + enabled => true, + package_ensure => 'present', + auth_type => 'keystone', + auth_password => $keystone_password, + auth_user => $keystone_user, + auth_tenant => $keystone_tenant +} + +class { 'neutron::agents::dhcp': } + +#file { '/etc/neutron/neutron-exports': +# owner => 'root', +# group => 'root', +# content => template('neutron/exports.erb') +#} diff --git a/resources/neutron_puppet/meta.yaml b/resources/neutron_puppet/meta.yaml new file mode 100644 index 0000000..a6bc77a --- /dev/null +++ b/resources/neutron_puppet/meta.yaml @@ -0,0 +1,53 @@ +handler: puppet +id: 'neutron' +input: + ip: + schema: str! + value: '' + ssh_key: + schema: str! + value: '' + ssh_user: + schema: str! + value: '' + + # TODO: add vhost! + rabbitmq_host: + schema: str! + value: '' + rabbitmq_port: + schema: int! + value: '' + rabbitmq_user: + schema: str! + value: '' + rabbitmq_password: + schema: str! + value: '' + + git: + schema: {repository: str!, branch: str!} + value: {repository: 'https://github.com/openstack/puppet-neutron', branch: 'stable/juno'} + + port: + schema: int! + value: 9696 + + keystone_host: + schema: str! + value: '' + keystone_port: + schema: int! + value: '' + keystone_user: + schema: str! + value: '' + keystone_password: + schema: str! + value: '' + keystone_tenant: + schema: str! + value: '' +puppet_module: 'neutron' +tags: [] +version: 1.0.0 diff --git a/resources/rabbitmq_service/test.py b/resources/rabbitmq_service/test.py index da81cb1..d8602ec 100644 --- a/resources/rabbitmq_service/test.py +++ b/resources/rabbitmq_service/test.py @@ -1,7 +1,9 @@ import requests +from solar.core.log import log + def test(resource): - print 'Testing rabbitmq_service' + log.debug('Testing rabbitmq_service') requests.get('http://%s:%s' % (resource.args['ip'].value, resource.args['management_port'].value))