From 8ef1feca80c0399fd6f54e7b22a4bd83c21ce46f Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Wed, 1 Jul 2015 12:13:36 +0300 Subject: [PATCH 1/6] Add local_ansible handler that will execute ansible-playbook locally This approach allows to reuse ansible roles (developer by community). Inventory is not created, all additional variables passed to playbook execution --- resources/ansible_sample/actions/run.yaml | 4 +++ .../actions/test_role/defaults/main.yml | 4 +++ .../actions/test_role/tasks/main.yml | 1 + resources/ansible_sample/meta.yaml | 11 ++++++++ solar/solar/core/handlers/__init__.py | 4 ++- .../core/handlers/local_ansible/__init__.py | 28 +++++++++++++++++++ .../core/handlers/local_ansible/inventory.py | 27 ++++++++++++++++++ 7 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 resources/ansible_sample/actions/run.yaml create mode 100644 resources/ansible_sample/actions/test_role/defaults/main.yml create mode 100644 resources/ansible_sample/actions/test_role/tasks/main.yml create mode 100644 resources/ansible_sample/meta.yaml create mode 100644 solar/solar/core/handlers/local_ansible/__init__.py create mode 100755 solar/solar/core/handlers/local_ansible/inventory.py diff --git a/resources/ansible_sample/actions/run.yaml b/resources/ansible_sample/actions/run.yaml new file mode 100644 index 00000000..fd3e8de7 --- /dev/null +++ b/resources/ansible_sample/actions/run.yaml @@ -0,0 +1,4 @@ +- hosts: localhost + sudo: yes + roles: + - { role: "test_role" } \ No newline at end of file diff --git a/resources/ansible_sample/actions/test_role/defaults/main.yml b/resources/ansible_sample/actions/test_role/defaults/main.yml new file mode 100644 index 00000000..14671490 --- /dev/null +++ b/resources/ansible_sample/actions/test_role/defaults/main.yml @@ -0,0 +1,4 @@ + +var1: initial +uuid: stuff +def1: the_same \ No newline at end of file diff --git a/resources/ansible_sample/actions/test_role/tasks/main.yml b/resources/ansible_sample/actions/test_role/tasks/main.yml new file mode 100644 index 00000000..1c628a0e --- /dev/null +++ b/resources/ansible_sample/actions/test_role/tasks/main.yml @@ -0,0 +1 @@ +- debug: msg="Variable1 {{ var1 }} with uuid {{ uuid }} and default var {{ def1 }}" \ No newline at end of file diff --git a/resources/ansible_sample/meta.yaml b/resources/ansible_sample/meta.yaml new file mode 100644 index 00000000..fba6f9cb --- /dev/null +++ b/resources/ansible_sample/meta.yaml @@ -0,0 +1,11 @@ +id: ansible_sample +handler: local_ansible +version: 0.0.1 +input: + var1: + type: str! + value: some_value + uuid: + type: str! + value: 'aa1das1231' + diff --git a/solar/solar/core/handlers/__init__.py b/solar/solar/core/handlers/__init__.py index 7f854ee0..2dc05656 100644 --- a/solar/solar/core/handlers/__init__.py +++ b/solar/solar/core/handlers/__init__.py @@ -3,12 +3,14 @@ from solar.core.handlers.ansible import Ansible from solar.core.handlers.base import Empty from solar.core.handlers.puppet import Puppet from solar.core.handlers.shell import Shell +from solar.core.handlers.local_ansible import LocalAnsible HANDLERS = {'ansible': Ansible, 'puppet': Puppet, 'shell': Shell, - 'none': Empty} + 'none': Empty, + 'local_ansible': LocalAnsible} def get(handler_name): handler = HANDLERS.get(handler_name, None) diff --git a/solar/solar/core/handlers/local_ansible/__init__.py b/solar/solar/core/handlers/local_ansible/__init__.py new file mode 100644 index 00000000..cb0a9a39 --- /dev/null +++ b/solar/solar/core/handlers/local_ansible/__init__.py @@ -0,0 +1,28 @@ + +from ansible.playbook import PlayBook +from ansible import utils +from ansible import callbacks + + +class LocalAnsible(object): + + def __init__(self, resources): + self.resources = resources + + def action(self, resource, action): + action_file = os.path.join( + resource.metadata['actions_path'], + resource.metadata['actions'][action]) + stats = callbacks.AggregateStats() + playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) + runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) + + play = PlayBook( + playbook=action_file, + host_list=['localhost'], + extra_vars=resource.args_dict(), + callbacks=playbook_cb, + runner_callbacks=runner_cb, + stats=stats, + transport='local') + return play.run() diff --git a/solar/solar/core/handlers/local_ansible/inventory.py b/solar/solar/core/handlers/local_ansible/inventory.py new file mode 100755 index 00000000..9cec48c1 --- /dev/null +++ b/solar/solar/core/handlers/local_ansible/inventory.py @@ -0,0 +1,27 @@ +#!/usr/bin/python + +import argparse +from ansible.playbook import PlayBook +from ansible import utils +from ansible import callbacks + +def expose(): + parser = argparse.ArgumentParser() + parser.add_argument('-p', type=str) + args = parser.parse_args() + + stats = callbacks.AggregateStats() + playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) + runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) + + play = PlayBook( + playbook=args.p, + host_list=['localhost'], + extra_vars={'var1': 'something', 'uuid': 'okay'}, + callbacks=playbook_cb, + runner_callbacks=runner_cb, + stats=stats, + transport='local') + return play.run() + +expose() From f7c7d1ad95f2da09f6ec62eee146d6cb6f42f40c Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Wed, 1 Jul 2015 15:17:23 +0300 Subject: [PATCH 2/6] Unify LocalAnsible and Ansible implementations --- resources/ansible_local/actions/run.yaml | 4 ++ .../actions/test_role/defaults/main.yml | 0 .../actions/test_role/tasks/main.yml | 0 .../meta.yaml | 2 +- resources/ansible_remote/actions/run.yaml | 4 ++ resources/ansible_remote/meta.yaml | 13 ++++++ resources/ansible_sample/actions/run.yaml | 4 -- solar/solar/cli/main.py | 12 ++--- solar/solar/core/handlers/__init__.py | 11 +++-- solar/solar/core/handlers/ansible_playbook.py | 44 +++++++++++++++++++ .../{ansible.py => ansible_template.py} | 4 +- solar/solar/core/handlers/base.py | 12 +++++ .../core/handlers/local_ansible/__init__.py | 28 ------------ .../core/handlers/local_ansible/inventory.py | 27 ------------ solar/solar/core/handlers/shell.py | 4 +- 15 files changed, 93 insertions(+), 76 deletions(-) create mode 100644 resources/ansible_local/actions/run.yaml rename resources/{ansible_sample => ansible_local}/actions/test_role/defaults/main.yml (100%) rename resources/{ansible_sample => ansible_local}/actions/test_role/tasks/main.yml (100%) rename resources/{ansible_sample => ansible_local}/meta.yaml (84%) create mode 100644 resources/ansible_remote/actions/run.yaml create mode 100644 resources/ansible_remote/meta.yaml delete mode 100644 resources/ansible_sample/actions/run.yaml create mode 100644 solar/solar/core/handlers/ansible_playbook.py rename solar/solar/core/handlers/{ansible.py => ansible_template.py} (94%) delete mode 100644 solar/solar/core/handlers/local_ansible/__init__.py delete mode 100755 solar/solar/core/handlers/local_ansible/inventory.py diff --git a/resources/ansible_local/actions/run.yaml b/resources/ansible_local/actions/run.yaml new file mode 100644 index 00000000..ce81d261 --- /dev/null +++ b/resources/ansible_local/actions/run.yaml @@ -0,0 +1,4 @@ +- hosts: '*' + sudo: yes + roles: + - { role: "test_role" } \ No newline at end of file diff --git a/resources/ansible_sample/actions/test_role/defaults/main.yml b/resources/ansible_local/actions/test_role/defaults/main.yml similarity index 100% rename from resources/ansible_sample/actions/test_role/defaults/main.yml rename to resources/ansible_local/actions/test_role/defaults/main.yml diff --git a/resources/ansible_sample/actions/test_role/tasks/main.yml b/resources/ansible_local/actions/test_role/tasks/main.yml similarity index 100% rename from resources/ansible_sample/actions/test_role/tasks/main.yml rename to resources/ansible_local/actions/test_role/tasks/main.yml diff --git a/resources/ansible_sample/meta.yaml b/resources/ansible_local/meta.yaml similarity index 84% rename from resources/ansible_sample/meta.yaml rename to resources/ansible_local/meta.yaml index fba6f9cb..77a47f18 100644 --- a/resources/ansible_sample/meta.yaml +++ b/resources/ansible_local/meta.yaml @@ -1,5 +1,5 @@ id: ansible_sample -handler: local_ansible +handler: ansible_playbook version: 0.0.1 input: var1: diff --git a/resources/ansible_remote/actions/run.yaml b/resources/ansible_remote/actions/run.yaml new file mode 100644 index 00000000..5206f498 --- /dev/null +++ b/resources/ansible_remote/actions/run.yaml @@ -0,0 +1,4 @@ +- hosts: '*' + sudo: yes + tasks: + - debug: "my message" \ No newline at end of file diff --git a/resources/ansible_remote/meta.yaml b/resources/ansible_remote/meta.yaml new file mode 100644 index 00000000..626215f5 --- /dev/null +++ b/resources/ansible_remote/meta.yaml @@ -0,0 +1,13 @@ +id: ansible_sample +handler: ansible_playbook +version: 0.0.1 +input: + ip: + type: str! + value: + ssh_user: + type: str! + value: + ssh_key: + type: str! + value: diff --git a/resources/ansible_sample/actions/run.yaml b/resources/ansible_sample/actions/run.yaml deleted file mode 100644 index fd3e8de7..00000000 --- a/resources/ansible_sample/actions/run.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- hosts: localhost - sudo: yes - roles: - - { role: "test_role" } \ No newline at end of file diff --git a/solar/solar/cli/main.py b/solar/solar/cli/main.py index 3073586c..49f6bd85 100644 --- a/solar/solar/cli/main.py +++ b/solar/solar/cli/main.py @@ -283,14 +283,14 @@ def init_cli_resource(): pass @resource.command() - @click.argument('resource_name') - @click.argument('action_name') - def action(action_name, resource_name): + @click.argument('action') + @click.argument('resource') + def action(action, resource): click.echo( - 'action {} for resource {}'.format(action_name, resource_name) + 'action {} for resource {}'.format(action, resource) ) - r = sresource.load(resource_name) - actions.resource_action(r, action_name) + actions.resource_action(sresource.load(resource), action) + @resource.command() def compile_all(): diff --git a/solar/solar/core/handlers/__init__.py b/solar/solar/core/handlers/__init__.py index 2dc05656..c0f5c825 100644 --- a/solar/solar/core/handlers/__init__.py +++ b/solar/solar/core/handlers/__init__.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- -from solar.core.handlers.ansible import Ansible +from solar.core.handlers.ansible_template import AnsibleTemplate +from solar.core.handlers.ansible_playbook import AnsiblePlaybook from solar.core.handlers.base import Empty from solar.core.handlers.puppet import Puppet from solar.core.handlers.shell import Shell -from solar.core.handlers.local_ansible import LocalAnsible -HANDLERS = {'ansible': Ansible, - 'puppet': Puppet, +HANDLERS = {'ansible': AnsibleTemplate, + 'ansible_playbook': AnsiblePlaybook, 'shell': Shell, - 'none': Empty, - 'local_ansible': LocalAnsible} + 'none': Empty} def get(handler_name): handler = HANDLERS.get(handler_name, None) diff --git a/solar/solar/core/handlers/ansible_playbook.py b/solar/solar/core/handlers/ansible_playbook.py new file mode 100644 index 00000000..f36faea6 --- /dev/null +++ b/solar/solar/core/handlers/ansible_playbook.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +import os + +from ansible.playbook import PlayBook +from ansible import utils +from ansible import callbacks +import ansible.constants as C + +from solar.core.handlers import base + + +class AnsiblePlaybook(base.BaseHandler): + + def action(self, resource, action): + action_file = os.path.join( + resource.metadata['actions_path'], + resource.metadata['actions'][action]) + stats = callbacks.AggregateStats() + playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) + runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) + + variables = resource.args_dict() + remote_user = variables.get('ssh_user') or C.DEFAULT_REMOTE_USER + private_key_file = variables.get('ssh_key') or C.DEFAULT_PRIVATE_KEY_FILE + if variables.get('ip'): + host_list = [variables['ip']] + transport = C.DEFAULT_TRANSPORT + else: + host_list = ['localhost'] + transport = 'local' + + play = PlayBook( + playbook=action_file, + remote_user=remote_user, + host_list = host_list, + private_key_file=private_key_file, + extra_vars=variables, + callbacks=playbook_cb, + runner_callbacks=runner_cb, + stats=stats, + transport=transport) + + return play.run() diff --git a/solar/solar/core/handlers/ansible.py b/solar/solar/core/handlers/ansible_template.py similarity index 94% rename from solar/solar/core/handlers/ansible.py rename to solar/solar/core/handlers/ansible_template.py index a5428259..dc6e8d45 100644 --- a/solar/solar/core/handlers/ansible.py +++ b/solar/solar/core/handlers/ansible_template.py @@ -3,10 +3,10 @@ from fabric import api as fabric_api import os from solar.core.log import log -from solar.core.handlers.base import BaseHandler +from solar.core.handlers.base import TempFileHandler -class Ansible(BaseHandler): +class AnsibleTemplate(TempFileHandler): def action(self, resource, action_name): inventory_file = self._create_inventory(resource) playbook_file = self._create_playbook(resource, action_name) diff --git a/solar/solar/core/handlers/base.py b/solar/solar/core/handlers/base.py index 6da7229a..b7fe46d2 100644 --- a/solar/solar/core/handlers/base.py +++ b/solar/solar/core/handlers/base.py @@ -9,6 +9,18 @@ from solar.core.log import log class BaseHandler(object): + + def __init__(self, resources): + self.resources = resources + + def __enter__(self): + return self + + def __exit__(self, exc, value, traceback): + return + + +class TempFileHandler(BaseHandler): def __init__(self, resources): self.dst = tempfile.mkdtemp() self.resources = resources diff --git a/solar/solar/core/handlers/local_ansible/__init__.py b/solar/solar/core/handlers/local_ansible/__init__.py deleted file mode 100644 index cb0a9a39..00000000 --- a/solar/solar/core/handlers/local_ansible/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ - -from ansible.playbook import PlayBook -from ansible import utils -from ansible import callbacks - - -class LocalAnsible(object): - - def __init__(self, resources): - self.resources = resources - - def action(self, resource, action): - action_file = os.path.join( - resource.metadata['actions_path'], - resource.metadata['actions'][action]) - stats = callbacks.AggregateStats() - playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) - runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) - - play = PlayBook( - playbook=action_file, - host_list=['localhost'], - extra_vars=resource.args_dict(), - callbacks=playbook_cb, - runner_callbacks=runner_cb, - stats=stats, - transport='local') - return play.run() diff --git a/solar/solar/core/handlers/local_ansible/inventory.py b/solar/solar/core/handlers/local_ansible/inventory.py deleted file mode 100755 index 9cec48c1..00000000 --- a/solar/solar/core/handlers/local_ansible/inventory.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python - -import argparse -from ansible.playbook import PlayBook -from ansible import utils -from ansible import callbacks - -def expose(): - parser = argparse.ArgumentParser() - parser.add_argument('-p', type=str) - args = parser.parse_args() - - stats = callbacks.AggregateStats() - playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) - runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) - - play = PlayBook( - playbook=args.p, - host_list=['localhost'], - extra_vars={'var1': 'something', 'uuid': 'okay'}, - callbacks=playbook_cb, - runner_callbacks=runner_cb, - stats=stats, - transport='local') - return play.run() - -expose() diff --git a/solar/solar/core/handlers/shell.py b/solar/solar/core/handlers/shell.py index 6bd86645..c74d4b49 100644 --- a/solar/solar/core/handlers/shell.py +++ b/solar/solar/core/handlers/shell.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from fabric import api as fabric_api -from solar.core.handlers.base import BaseHandler +from solar.core.handlers.base import TempFileHandler -class Shell(BaseHandler): +class Shell(TempFileHandler): def action(self, resource, action_name): action_file = self._compile_action_file(resource, action_name) fabric_api.local('bash {}'.format(action_file)) From b6cddda99492e2386b5a5cd047567bfb4c159231 Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Thu, 2 Jul 2015 09:17:09 +0300 Subject: [PATCH 3/6] Add error handling for ansible_playbook handler --- resources/ansible_local/actions/run.yaml | 9 +++++++-- resources/ansible_local/meta.yaml | 2 +- resources/ansible_remote/actions/run.yaml | 4 +++- resources/ansible_remote/meta.yaml | 3 +++ solar/solar/core/handlers/ansible_playbook.py | 15 +++++++++++---- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/resources/ansible_local/actions/run.yaml b/resources/ansible_local/actions/run.yaml index ce81d261..7351a738 100644 --- a/resources/ansible_local/actions/run.yaml +++ b/resources/ansible_local/actions/run.yaml @@ -1,4 +1,9 @@ -- hosts: '*' +- hosts: localhost sudo: yes + vars: + var1: 'playbook' roles: - - { role: "test_role" } \ No newline at end of file + - { role: "test_role" } + tasks: + - debug: msg="VAR1 value is {{var1}}" + - fail: msg='just test failure' \ No newline at end of file diff --git a/resources/ansible_local/meta.yaml b/resources/ansible_local/meta.yaml index 77a47f18..cddbb391 100644 --- a/resources/ansible_local/meta.yaml +++ b/resources/ansible_local/meta.yaml @@ -4,7 +4,7 @@ version: 0.0.1 input: var1: type: str! - value: some_value + value: meta uuid: type: str! value: 'aa1das1231' diff --git a/resources/ansible_remote/actions/run.yaml b/resources/ansible_remote/actions/run.yaml index 5206f498..7482f7f8 100644 --- a/resources/ansible_remote/actions/run.yaml +++ b/resources/ansible_remote/actions/run.yaml @@ -1,4 +1,6 @@ - hosts: '*' sudo: yes + vars: + default1: playbook tasks: - - debug: "my message" \ No newline at end of file + - debug: msg="my message {{default1}}" \ No newline at end of file diff --git a/resources/ansible_remote/meta.yaml b/resources/ansible_remote/meta.yaml index 626215f5..90026220 100644 --- a/resources/ansible_remote/meta.yaml +++ b/resources/ansible_remote/meta.yaml @@ -11,3 +11,6 @@ input: ssh_key: type: str! value: + default1: + type: str! + value: meta diff --git a/solar/solar/core/handlers/ansible_playbook.py b/solar/solar/core/handlers/ansible_playbook.py index f36faea6..06a5dd7b 100644 --- a/solar/solar/core/handlers/ansible_playbook.py +++ b/solar/solar/core/handlers/ansible_playbook.py @@ -8,6 +8,7 @@ from ansible import callbacks import ansible.constants as C from solar.core.handlers import base +from solar import errors class AnsiblePlaybook(base.BaseHandler): @@ -24,16 +25,16 @@ class AnsiblePlaybook(base.BaseHandler): remote_user = variables.get('ssh_user') or C.DEFAULT_REMOTE_USER private_key_file = variables.get('ssh_key') or C.DEFAULT_PRIVATE_KEY_FILE if variables.get('ip'): - host_list = [variables['ip']] + host = variables['ip'] transport = C.DEFAULT_TRANSPORT else: - host_list = ['localhost'] + host = 'localhost' transport = 'local' play = PlayBook( playbook=action_file, remote_user=remote_user, - host_list = host_list, + host_list = [host], private_key_file=private_key_file, extra_vars=variables, callbacks=playbook_cb, @@ -41,4 +42,10 @@ class AnsiblePlaybook(base.BaseHandler): stats=stats, transport=transport) - return play.run() + play.run() + summary = stats.summarize(host) + + if summary.get('unreachable') or summary.get('failures'): + raise errors.SolarError( + 'Ansible playbook %s failed with next summary %s', + action_file, summary) From 784e45c8839c80f4c109c6513fc31a53e045a945 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Thu, 16 Jul 2015 17:00:04 +0200 Subject: [PATCH 4/6] Del duplicating connections Signed-off-by: Bogdan Dobrelya --- example-puppet.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/example-puppet.py b/example-puppet.py index 7e565631..df78ef5b 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -62,12 +62,6 @@ def deploy(): 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] - 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_user) signals.connect(node1, keystone_puppet) From 29da07e870ca9e50b4002efb5097005edaafc5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 17 Jul 2015 10:21:44 +0000 Subject: [PATCH 5/6] Use deb package --- main.yml | 2 +- resources/keystone_role/actions/run.yml | 2 +- resources/keystone_tenant/actions/run.yml | 2 +- resources/keystone_user/actions/run.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.yml b/main.yml index e179bc83..613d125c 100644 --- a/main.yml +++ b/main.yml @@ -14,7 +14,7 @@ - apt: name=python-pudb state=present #- apt: name=python-pip state=present - shell: pip install docker-py==1.1.0 - - shell: pip install python-keystoneclient==1.5.0 + - apt: name=python-keystoneclient state=present - apt: name=redis-server state=present #- apt: name=python-redis state=present diff --git a/resources/keystone_role/actions/run.yml b/resources/keystone_role/actions/run.yml index 4d3df76c..eb30523b 100644 --- a/resources/keystone_role/actions/run.yml +++ b/resources/keystone_role/actions/run.yml @@ -2,6 +2,6 @@ sudo: yes tasks: - name: install python-keystoneclient - shell: pip install python-keystoneclient + shell: apt-get install python-keystoneclient - name: keystone role keystone_user: endpoint=http://{{keystone_host}}:{{keystone_port}}/v2.0/ token={{admin_token}} user={{user_name}} tenant={{tenant_name}} role={{role_name}} state=present diff --git a/resources/keystone_tenant/actions/run.yml b/resources/keystone_tenant/actions/run.yml index 1cf2597f..f9e72527 100644 --- a/resources/keystone_tenant/actions/run.yml +++ b/resources/keystone_tenant/actions/run.yml @@ -2,6 +2,6 @@ sudo: yes tasks: - name: install python-keystoneclient - shell: pip install python-keystoneclient + shell: apt-get install python-keystoneclient - name: keystone tenant keystone_user: endpoint=http://{{keystone_host}}:{{keystone_port}}/v2.0/ token={{admin_token}} tenant={{tenant_name}} state=present diff --git a/resources/keystone_user/actions/run.yml b/resources/keystone_user/actions/run.yml index eb3c3743..02f2b337 100644 --- a/resources/keystone_user/actions/run.yml +++ b/resources/keystone_user/actions/run.yml @@ -2,6 +2,6 @@ sudo: yes tasks: - name: install python-keystoneclient - shell: pip install python-keystoneclient + shell: apt-get install python-keystoneclient - name: keystone user keystone_user: endpoint=http://{{ keystone_host }}:{{ keystone_port }}/v2.0/ token={{ admin_token }} user={{ user_name }} password={{ user_password }} tenant={{ tenant_name }} state=present From b694f44694d7971269a925858586d834ea1f2aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 17 Jul 2015 11:49:12 +0000 Subject: [PATCH 6/6] Fix rabbitmq startup Rabbitmq start with the default node name. Puppet tries to change nodename. After this start stop status stops to work --- example-puppet.py | 2 +- resources/rabbitmq_service/actions/run.pp | 6 +----- resources/rabbitmq_user/actions/remove.yml | 1 - resources/rabbitmq_user/actions/run.yml | 1 - resources/rabbitmq_user/meta.yaml | 3 --- resources/rabbitmq_vhost/actions/remove.yml | 1 - resources/rabbitmq_vhost/actions/run.yml | 1 - resources/rabbitmq_vhost/meta.yaml | 3 --- 8 files changed, 2 insertions(+), 16 deletions(-) diff --git a/example-puppet.py b/example-puppet.py index 4f3d8c07..9356fbb2 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -45,7 +45,7 @@ def deploy(): signals.connect(node1, mariadb_service1) # RABBIT - rabbitmq_service1 = vr.create('rabbitmq1', 'resources/rabbitmq_service', {'management_port': 15672, 'port': 5672, 'node_name': 'rabbitmq_service1'})[0] + rabbitmq_service1 = vr.create('rabbitmq1', 'resources/rabbitmq_service', {'management_port': 15672, 'port': 5672})[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] diff --git a/resources/rabbitmq_service/actions/run.pp b/resources/rabbitmq_service/actions/run.pp index 807f93bd..befa93d9 100644 --- a/resources/rabbitmq_service/actions/run.pp +++ b/resources/rabbitmq_service/actions/run.pp @@ -5,12 +5,8 @@ $management_port = "${resource['input']['management_port']['value']}" $node_name = $resource['input']['node_name']['value'] class { '::rabbitmq': - service_manage => false, + service_manage => true, port => $port, management_port => $management_port, delete_guest_user => true, - environment_variables => { - 'RABBITMQ_NODENAME' => $node_name, - 'RABBITMQ_SERVICENAME' => 'RabbitMQ' - } } diff --git a/resources/rabbitmq_user/actions/remove.yml b/resources/rabbitmq_user/actions/remove.yml index 7e1d80ed..b73859bc 100644 --- a/resources/rabbitmq_user/actions/remove.yml +++ b/resources/rabbitmq_user/actions/remove.yml @@ -4,4 +4,3 @@ - new_rabbitmq_user: user={{user_name}} vhost={{vhost_name}} state=absent - node={{node_name}} diff --git a/resources/rabbitmq_user/actions/run.yml b/resources/rabbitmq_user/actions/run.yml index 46fc5bf1..bc5c3e5c 100644 --- a/resources/rabbitmq_user/actions/run.yml +++ b/resources/rabbitmq_user/actions/run.yml @@ -8,4 +8,3 @@ read_priv=.* write_priv=.* state=present - node={{node_name}} diff --git a/resources/rabbitmq_user/meta.yaml b/resources/rabbitmq_user/meta.yaml index b5be384d..d7185aa9 100644 --- a/resources/rabbitmq_user/meta.yaml +++ b/resources/rabbitmq_user/meta.yaml @@ -2,9 +2,6 @@ id: rabbitmq_user handler: ansible version: 1.0.0 input: - node_name: - schema: str! - value: user_name: schema: str! value: openstack diff --git a/resources/rabbitmq_vhost/actions/remove.yml b/resources/rabbitmq_vhost/actions/remove.yml index 81038528..8dcefd7f 100644 --- a/resources/rabbitmq_vhost/actions/remove.yml +++ b/resources/rabbitmq_vhost/actions/remove.yml @@ -3,4 +3,3 @@ tasks: - new_rabbitmq_vhost: name={{vhost_name}} state=absent - node={{node_name}} diff --git a/resources/rabbitmq_vhost/actions/run.yml b/resources/rabbitmq_vhost/actions/run.yml index ac45faf0..52b8bb20 100644 --- a/resources/rabbitmq_vhost/actions/run.yml +++ b/resources/rabbitmq_vhost/actions/run.yml @@ -2,5 +2,4 @@ sudo: yes tasks: - new_rabbitmq_vhost: name={{vhost_name}} - node={{node_name}} state=present diff --git a/resources/rabbitmq_vhost/meta.yaml b/resources/rabbitmq_vhost/meta.yaml index 313f20a7..8291f2a6 100644 --- a/resources/rabbitmq_vhost/meta.yaml +++ b/resources/rabbitmq_vhost/meta.yaml @@ -2,9 +2,6 @@ id: rabbitmq_vhost handler: ansible version: 1.0.0 input: - node_name: - schema: str! - value: vhost_name: schema: str! value: openstack