Merge pull request #18 from Mirantis/rabbitmq_puppet

Rabbitmq puppet
This commit is contained in:
CGenie 2015-07-17 10:32:11 +02:00
commit fbfe8bbc33
14 changed files with 81 additions and 89 deletions

View File

@ -39,13 +39,16 @@ def deploy():
node1 = vr.create('node1', 'resources/ro_node/', {'ip': '10.0.0.3', 'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key', 'ssh_user': 'vagrant'})[0] node1 = vr.create('node1', 'resources/ro_node/', {'ip': '10.0.0.3', 'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key', 'ssh_user': 'vagrant'})[0]
rabbitmq_service1 = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', {'management_port': 15672, 'port': 5672, 'container_name': 'rabbitmq_service1', 'image': 'rabbitmq:3-management'})[0] # MARIADB
openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0]
openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {'user_name': 'openstack', 'password': 'openstack_password'})[0]
mariadb_service1 = vr.create('mariadb_service1', 'resources/mariadb_service', {'image': 'mariadb', 'root_password': 'mariadb', 'port': 3306})[0] mariadb_service1 = vr.create('mariadb_service1', 'resources/mariadb_service', {'image': 'mariadb', 'root_password': 'mariadb', 'port': 3306})[0]
signals.connect(node1, mariadb_service1) signals.connect(node1, mariadb_service1)
# RABBIT
rabbitmq_service1 = vr.create('rabbitmq1', 'resources/rabbitmq_service', {'management_port': 15672, 'port': 5672, 'node_name': 'rabbitmq_service1'})[0]
openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0]
openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {'user_name': 'openstack', 'password': 'openstack_password'})[0]
signals.connect(node1, rabbitmq_service1) signals.connect(node1, rabbitmq_service1)
signals.connect(rabbitmq_service1, openstack_vhost) signals.connect(rabbitmq_service1, openstack_vhost)
signals.connect(rabbitmq_service1, openstack_rabbitmq_user) signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
@ -62,12 +65,6 @@ def deploy():
admin_role = vr.create('admin_role', 'resources/keystone_role', {'role_name': 'admin'})[0] admin_role = vr.create('admin_role', 'resources/keystone_role', {'role_name': 'admin'})[0]
services_tenant = vr.create('services_tenant', 'resources/keystone_tenant', {'tenant_name': 'services'})[0] services_tenant = vr.create('services_tenant', 'resources/keystone_tenant', {'tenant_name': 'services'})[0]
signals.connect(node1, rabbitmq_service1)
signals.connect(rabbitmq_service1, openstack_vhost)
signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'})
signals.connect(node1, mariadb_service1)
signals.connect(node1, keystone_db) signals.connect(node1, keystone_db)
signals.connect(node1, keystone_db_user) signals.connect(node1, keystone_db_user)
signals.connect(node1, keystone_puppet) signals.connect(node1, keystone_puppet)
@ -92,12 +89,19 @@ def deploy():
signals.connect(keystone_db, keystone_puppet, {'db_name': 'db_name'}) signals.connect(keystone_db, keystone_puppet, {'db_name': 'db_name'})
signals.connect(keystone_db_user, keystone_puppet, {'new_user_name': 'db_user', 'new_user_password': 'db_password'}) signals.connect(keystone_db_user, keystone_puppet, {'new_user_name': 'db_user', 'new_user_password': 'db_password'})
# OPENRC
openrc = vr.create('openrc_file', 'resources/openrc_file', {})[0]
signals.connect(node1, openrc)
signals.connect(keystone_puppet, openrc, {'ip': 'keystone_host', 'admin_port':'keystone_port'})
signals.connect(admin_user, openrc, {'user_name': 'user_name','user_password':'password', 'tenant_name': 'tenant'})
# NEUTRON # NEUTRON
# TODO: vhost cannot be specified in neutron Puppet manifests so this user has to be admin anyways # TODO: vhost cannot be specified in neutron Puppet manifests so this user has to be admin anyways
neutron_puppet = vr.create('neutron_puppet', 'resources/neutron_puppet', {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0] neutron_puppet = vr.create('neutron_puppet', 'resources/neutron_puppet', {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0]
neutron_keystone_user = vr.create('neutron_keystone_user', 'resources/keystone_user', {'user_name': 'neutron', 'user_password': 'neutron'})[0] neutron_keystone_user = vr.create('neutron_keystone_user', 'resources/keystone_user', {'user_name': 'neutron', 'user_password': 'neutron'})[0]
neutron_keystone_role = vr.create('neutron_keystone_role', 'resources/keystone_role', {'role_name': 'neutron'})[0] neutron_keystone_role = vr.create('neutron_keystone_role', 'resources/keystone_role', {'role_name': 'neutron'})[0]
neutron_keystone_service_endpoint = vr.create('neutron_keystone_service_endpoint', 'resources/keystone_service_endpoint', {'endpoint_name': 'neutron', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}', 'publicurl': 'http://{{public_ip}}:{{public_port}}', 'description': 'OpenStack Network Service', 'type': 'network'})[0] neutron_keystone_service_endpoint = vr.create('neutron_keystone_service_endpoint', 'resources/keystone_service_endpoint', {'endpoint_name': 'neutron', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}', 'publicurl': 'http://{{public_ip}}:{{public_port}}', 'description': 'OpenStack Network Service', 'type': 'network'})[0]
signals.connect(node1, neutron_puppet) signals.connect(node1, neutron_puppet)
@ -195,6 +199,7 @@ def deploy():
actions.resource_action(keystone_db, 'run') actions.resource_action(keystone_db, 'run')
actions.resource_action(keystone_db_user, 'run') actions.resource_action(keystone_db_user, 'run')
actions.resource_action(keystone_puppet, 'run') actions.resource_action(keystone_puppet, 'run')
actions.resource_action(openrc, 'run')
actions.resource_action(admin_tenant, 'run') actions.resource_action(admin_tenant, 'run')
actions.resource_action(admin_user, 'run') actions.resource_action(admin_user, 'run')
@ -235,17 +240,18 @@ def undeploy():
'neutron_keystone_role', 'neutron_keystone_role',
'neutron_keystone_user', 'neutron_keystone_user',
'services_tenant', 'services_tenant',
'keystone_service_endpoint', #'keystone_service_endpoint',
'admin_role', 'admin_role',
'admin_user', 'admin_user',
'admin_tenant', 'admin_tenant',
'openrc_file',
'keystone_puppet', 'keystone_puppet',
'keystone_db_user', 'keystone_db_user',
'keystone_db', 'keystone_db',
'mariadb_service1', 'mariadb_service1',
'openstack_rabbitmq_user', 'openstack_rabbitmq_user',
'openstack_vhost', 'openstack_vhost',
'rabbitmq_service1', 'rabbitmq1',
] ]
resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource)) resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource))
@ -283,7 +289,7 @@ def undeploy():
# actions.resource_action(resources['openstack_rabbitmq_user'], 'remove') # actions.resource_action(resources['openstack_rabbitmq_user'], 'remove')
# actions.resource_action(resources['openstack_vhost'], 'remove') # actions.resource_action(resources['openstack_vhost'], 'remove')
# actions.resource_action(resources['rabbitmq_service1'], 'remove') # actions.resource_action(resources['rabbitmq1'], 'remove')
db.clear() db.clear()

View File

@ -0,0 +1,12 @@
$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'
}
}

View File

@ -1,8 +0,0 @@
- hosts: [{{ ip }}]
sudo: yes
tasks:
- name: rabbitmq container
docker:
name: {{ container_name }}
image: {{ image }}
state: absent

View File

@ -0,0 +1,16 @@
$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 => false,
port => $port,
management_port => $management_port,
delete_guest_user => true,
environment_variables => {
'RABBITMQ_NODENAME' => $node_name,
'RABBITMQ_SERVICENAME' => 'RabbitMQ'
}
}

View File

@ -1,22 +0,0 @@
- hosts: [{{ ip }}]
sudo: yes
tasks:
- name: rabbitmq container
docker:
command: /bin/bash -c rabbitmq-server
name: {{ container_name }}
image: {{ image }}
state: running
expose:
- 5672
- 15672
ports:
- {{ port }}:5672
- {{ management_port }}:15672
env:
RABBITMQ_NODENAME: {{container_name}}
- shell: docker exec -t {{ container_name }} rabbitmqctl list_users
register: result
until: result.rc == 0
retries: 20
delay: 0.5

View File

@ -1,27 +1,29 @@
id: rabbitmq_service handler: puppet
handler: ansible id: 'rabbitmq'
version: 1.0.0
input: input:
image: ip:
schema: str! schema: str!
value: rabbitmq:3-management value: ''
container_name: ssh_key:
schema: str! schema: str!
value: rabbitmq_service value: ''
management_port: ssh_user:
schema: int! schema: str!
value: 15672 value: ''
port:
schema: int!
value: 5672
ip:
schema: str!
value:
ssh_key:
schema: str!
value:
ssh_user:
schema: str!
value:
tags: [resources/rabbitmq, resource/rabbitmq_service] node_name:
schema: str!
value: 'node1'
port:
schema: int!
value: ''
management_port:
schema: int!
value: ''
git:
schema: {repository: str!, branch: str!}
value: {repository: 'https://github.com/puppetlabs/puppetlabs-rabbitmq.git', branch: '5.1.0'}
puppet_module: 'rabbitmq'
tags: []
version: 1.0.0

View File

@ -1 +0,0 @@
{{erlang_cookie}}

View File

@ -1,9 +0,0 @@
import requests
from solar.core.log import log
def test(resource):
log.debug('Testing rabbitmq_service')
requests.get('http://%s:%s' % (resource.args['ip'].value, resource.args['management_port'].value))

View File

@ -4,5 +4,4 @@
- new_rabbitmq_user: user={{user_name}} - new_rabbitmq_user: user={{user_name}}
vhost={{vhost_name}} vhost={{vhost_name}}
state=absent state=absent
node={{container_name}} node={{node_name}}
rabbitmqctl="docker exec -it {{container_name}} rabbitmqctl"

View File

@ -8,5 +8,4 @@
read_priv=.* read_priv=.*
write_priv=.* write_priv=.*
state=present state=present
node={{container_name}} node={{node_name}}
rabbitmqctl="docker exec -it {{container_name}} rabbitmqctl"

View File

@ -2,7 +2,7 @@ id: rabbitmq_user
handler: ansible handler: ansible
version: 1.0.0 version: 1.0.0
input: input:
container_name: node_name:
schema: str! schema: str!
value: value:
user_name: user_name:

View File

@ -3,5 +3,4 @@
tasks: tasks:
- new_rabbitmq_vhost: name={{vhost_name}} - new_rabbitmq_vhost: name={{vhost_name}}
state=absent state=absent
rabbitmqctl="docker exec -it {{container_name}} rabbitmqctl" node={{node_name}}
node={{container_name}}

View File

@ -2,6 +2,5 @@
sudo: yes sudo: yes
tasks: tasks:
- new_rabbitmq_vhost: name={{vhost_name}} - new_rabbitmq_vhost: name={{vhost_name}}
node={{container_name}} node={{node_name}}
state=present state=present
rabbitmqctl="docker exec -it {{container_name}} rabbitmqctl"

View File

@ -2,7 +2,7 @@ id: rabbitmq_vhost
handler: ansible handler: ansible
version: 1.0.0 version: 1.0.0
input: input:
container_name: node_name:
schema: str! schema: str!
value: value:
vhost_name: vhost_name: