Merge pull request #10 from Mirantis/puppet-tests
Puppet handler & example-puppet.py
This commit is contained in:
commit
0ab0825734
@ -36,5 +36,8 @@ input:
|
||||
keystone_host:
|
||||
schema: str!
|
||||
value:
|
||||
keystone_port:
|
||||
schema: int!
|
||||
value:
|
||||
|
||||
tags: [resource/container]
|
||||
|
@ -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': []}
|
||||
|
@ -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'])
|
||||
)
|
||||
|
4
resources/keystone_puppet/actions/remove.pp
Normal file
4
resources/keystone_puppet/actions/remove.pp
Normal file
@ -0,0 +1,4 @@
|
||||
class {'keystone':
|
||||
admin_token => '{{ admin_token }}',
|
||||
package_ensure => 'absent'
|
||||
}
|
25
resources/keystone_puppet/actions/run.pp
Normal file
25
resources/keystone_puppet/actions/run.pp
Normal file
@ -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')
|
||||
#}
|
7
resources/keystone_puppet/actions/update.pp
Normal file
7
resources/keystone_puppet/actions/update.pp
Normal file
@ -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 }}'
|
||||
}
|
44
resources/keystone_puppet/meta.yaml
Normal file
44
resources/keystone_puppet/meta.yaml
Normal file
@ -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]
|
10
resources/keystone_puppet/test.py
Normal file
10
resources/keystone_puppet/test.py
Normal file
@ -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)
|
||||
)
|
@ -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)
|
||||
)
|
||||
|
@ -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/
|
||||
|
||||
|
@ -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:
|
||||
|
49
resources/keystone_service_endpoint/test.py
Normal file
49
resources/keystone_service_endpoint/test.py
Normal file
@ -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))
|
||||
|
27
resources/keystone_user/test.py
Normal file
27
resources/keystone_user/test.py
Normal file
@ -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)
|
22
resources/neutron_puppet/actions/remove.pp
Normal file
22
resources/neutron_puppet/actions/remove.pp
Normal file
@ -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
|
||||
}
|
||||
|
44
resources/neutron_puppet/actions/run.pp
Normal file
44
resources/neutron_puppet/actions/run.pp
Normal file
@ -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')
|
||||
#}
|
53
resources/neutron_puppet/meta.yaml
Normal file
53
resources/neutron_puppet/meta.yaml
Normal file
@ -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
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user