Glance-puppet, not fully working yet

This commit is contained in:
Przemyslaw Kaminski 2015-07-17 15:14:35 +02:00 committed by Bogdan Dobrelya
parent 36858a9218
commit dff1ada9e9
8 changed files with 230 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# `glance_puppet` resource
Wraps OpenStack's `glance` Puppet resource from
https://github.com/openstack/puppet-glance (`stable/juno` branch).

View File

@ -0,0 +1,27 @@
$resource = hiera($::resource_name)
$ip = $resource['input']['ip']['value']
#class {'glance':
# package_ensure => 'absent'
#}
#
#user { 'glance':
# name => 'glance',
# ensure => 'absent',
# home => '/home/glance',
# system => true
#}
class { 'glance::api':
#package_ensure => 'absent',
verbose => true
}
class { 'glance::registry':
package_ensure => 'absent',
verbose => true
}
class { 'glance::backend::file': }

View File

@ -0,0 +1,53 @@
$resource = hiera($::resource_name)
$ip = $resource['input']['ip']['value']
$db_host = $resource['input']['db_host']['value']
$db_port = $resource['input']['db_port']['value']
$db_user = $resource['input']['db_user']['value']
$db_password = $resource['input']['db_password']['value']
$db_name = $resource['input']['db_name']['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_role = $resource['input']['keystone_role']['value']
$keystone_tenant = $resource['input']['keystone_tenant']['value']
#user { 'glance':
# name => 'glance',
# ensure => 'present',
# home => '/home/glance',
# system => true
#}
#
#class {'glance':
# package_ensure => 'present'
#}
class { 'glance::api':
#package_ensure => 'present',
verbose => true,
keystone_tenant => $keystone_tenant,
keystone_user => $keystone_user,
keystone_password => $keystone_password,
database_connection => "mysql://$db_user:$db_password@$db_host/$db_name",
}
class { 'glance::registry':
package_ensure => 'present',
verbose => true,
keystone_tenant => $keystone_tenant,
keystone_user => $keystone_user,
keystone_password => $keystone_password,
database_connection => "mysql://$db_user:$db_password@$db_host/$db_name",
}
class { 'glance::backend::file': }
#file { '/etc/keystone/keystone-exports':
# owner => 'root',
# group => 'root',
# content => template('keystone/exports.erb')
#}

View 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 }}'
}

View File

@ -0,0 +1,55 @@
id: glance_puppet
handler: puppet
puppet_module: glance
version: 1.0.0
input:
db_host:
schema: str!
value:
db_port:
schema: int!
value:
db_user:
schema: str!
value: keystone
db_password:
schema: str!
value: keystone
db_name:
schema: str!
value: keystone
keystone_host:
schema: str!
value:
keystone_port:
schema: int!
value: 5000
keystone_user:
schema: str!
value: glance
keystone_role:
schema: str!
value: glance
keystone_password:
schema: str!
value: glance123
keystone_tenant:
schema: str!
value: services
git:
schema: {repository: str!, branch: str!}
value: {repository: 'https://github.com/openstack/puppet-glance', branch: 'stable/juno'}
ip:
schema: str!
value:
ssh_key:
schema: str!
value:
ssh_user:
schema: str!
value:
tags: [resource/glance_service, resources/glance]

View File

@ -0,0 +1,30 @@
import json
import requests
from solar.core.log import log
def test(resource):
log.debug('Testing glance_puppet')
res = requests.get(
'http://%s:9292' % resource.args['ip'].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']
print res.json()

23
templates/glance.yml Normal file
View File

@ -0,0 +1,23 @@
id: glance_{{idx}}
resources:
- id: glance_base_{{ idx }}
from: templates/glance_db.yml
values:
idx: '{{ idx }}'
db_name: '{{ db_name }}'
db_user: '{{ db_user }}'
db_password: '{{ db_password }}'
db_host: '{{ db_host }}'
db_login_port: '{{ db_port }}'
db_login_user: '{{ db_login_user }}'
db_login_password: '{{ db_login_password }}'
ip: '{{ ip }}'
ssh_user: '{{ ssh_user }}'
ssh_key: '{{ ssh_key }}'
tags: ['resources/glance', 'resource/glance_api', 'resource/glance_registry']

30
templates/glance_db.yml Normal file
View File

@ -0,0 +1,30 @@
id: glance_db_{{ idx }}
resources:
- id: glance_db_db_{{ idx }}
from: resources/mariadb_db
values:
db_name: '{{ db_name }}'
login_user: '{{ db_login_user }}'
login_password: '{{ db_login_password }}'
login_port: '{{ db_login_port }}'
ip: '{{ ip }}'
ssh_user: '{{ ssh_user }}'
ssh_key: '{{ ssh_key }}'
- id: glance_db_user
from: resources/mariadb_user
values:
user_password: '{{ db_password }}'
user_name: '{{ db_user }}'
db_name: '{{ db_name }}'
login_user: '{{ db_login_user }}'
login_password: '{{ db_login_password }}'
login_port: '{{ db_login_port }}'
ip: '{{ ip }}'
ssh_user: '{{ ssh_user }}'
ssh_key: '{{ ssh_key }}'