From f027801d875a6a359ad9d006abf5c823887d58c5 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 10:09:06 +0200 Subject: [PATCH 01/15] Create ansible.log file during provisioning --- bootstrap/solar-master.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bootstrap/solar-master.json b/bootstrap/solar-master.json index 9b4ab421..8e79b147 100644 --- a/bootstrap/solar-master.json +++ b/bootstrap/solar-master.json @@ -31,6 +31,13 @@ "sudo echo 'log_path = {{ user `ansible_log_file` }}' >> {{ user `ansible_config_path` }}/{{ user `ansible_config_file` }}" ] }, + { + "type": "shell", + "inline": [ + "touch /tmp/ansible.log", + "chmod 666 /tmp/ansible.log" + ] + }, { "type": "shell", "script": "playbooks/files/ubuntu-ansible.sh" From 077936e8930926badb74b6d15cbdba0c261d9635 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 10:35:32 +0200 Subject: [PATCH 02/15] Ansible log stuff together in solar-master.json --- bootstrap/solar-master.json | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bootstrap/solar-master.json b/bootstrap/solar-master.json index 8e79b147..439fca6a 100644 --- a/bootstrap/solar-master.json +++ b/bootstrap/solar-master.json @@ -28,14 +28,9 @@ { "type": "shell", "inline": [ - "sudo echo 'log_path = {{ user `ansible_log_file` }}' >> {{ user `ansible_config_path` }}/{{ user `ansible_config_file` }}" - ] - }, - { - "type": "shell", - "inline": [ - "touch /tmp/ansible.log", - "chmod 666 /tmp/ansible.log" + "sudo echo 'log_path = {{ user `ansible_log_file` }}' >> {{ user `ansible_config_path` }}/{{ user `ansible_config_file` }}", + "touch `ansible_log_file", + "chmod 666 `ansible_log_file`" ] }, { @@ -51,4 +46,4 @@ "type": "vagrant", "output": "solar-master.box" }] -} \ No newline at end of file +} From 1e4404cf533fe260bd87d92a84d12c7b30a9dc13 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 10:53:39 +0200 Subject: [PATCH 03/15] fixed missing ` --- bootstrap/solar-master.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/solar-master.json b/bootstrap/solar-master.json index 439fca6a..b179da53 100644 --- a/bootstrap/solar-master.json +++ b/bootstrap/solar-master.json @@ -29,7 +29,7 @@ "type": "shell", "inline": [ "sudo echo 'log_path = {{ user `ansible_log_file` }}' >> {{ user `ansible_config_path` }}/{{ user `ansible_config_file` }}", - "touch `ansible_log_file", + "touch `ansible_log_file`", "chmod 666 `ansible_log_file`" ] }, From d3595bf6124f0762b8cbd1ec548431beb9bb8e06 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 12:09:53 +0200 Subject: [PATCH 04/15] Moved ansible log from /tmp/ansible.log to /var/tmp/ansible.log --- bootstrap/solar-master.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/solar-master.json b/bootstrap/solar-master.json index b179da53..f25f7bea 100644 --- a/bootstrap/solar-master.json +++ b/bootstrap/solar-master.json @@ -2,7 +2,7 @@ "variables": { "ansible_config_path": "/etc/ansible", "ansible_config_file": "ansible.cfg", - "ansible_log_file": "/tmp/ansible.log" + "ansible_log_file": "/var/tmp/ansible.log" }, "builders": [{ "type": "virtualbox-ovf", From 3f93abb839a96f1ae37ed655badb8aa4090c0bc4 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 12:13:58 +0200 Subject: [PATCH 05/15] Fixed renderer --- bootstrap/solar-master.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap/solar-master.json b/bootstrap/solar-master.json index f25f7bea..6d8a82d2 100644 --- a/bootstrap/solar-master.json +++ b/bootstrap/solar-master.json @@ -29,8 +29,8 @@ "type": "shell", "inline": [ "sudo echo 'log_path = {{ user `ansible_log_file` }}' >> {{ user `ansible_config_path` }}/{{ user `ansible_config_file` }}", - "touch `ansible_log_file`", - "chmod 666 `ansible_log_file`" + "touch {{ user `ansible_log_file` }}", + "chmod 666 {{ user `ansible_log_file` }}" ] }, { From 13e35d8a024ed3e2666f38d29cea147ada490aaa Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 14:18:54 +0200 Subject: [PATCH 06/15] Fixed paths in riak README --- examples/riak/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/riak/README.md b/examples/riak/README.md index e639474d..fe119902 100644 --- a/examples/riak/README.md +++ b/examples/riak/README.md @@ -2,7 +2,7 @@ Example of 3 node riak cluster. At first run: -`python riak-example.py deploy` +`python examples/riak/riaks.py deploy` It will prepare riak nodes etc. @@ -17,7 +17,7 @@ watch -n 1 solar changes report last After that you can add HAProxy on each node: -`python riak-example.py add_haproxies` +`python examples/riak/riaks.py add_haproxies` Then again normal solar stuff From 418ac03ef6c702f85184680c65cfcd12b78ab4b5 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 4 Sep 2015 14:22:20 +0200 Subject: [PATCH 07/15] Added description about SUCCESS state in riak example --- examples/riak/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/riak/README.md b/examples/riak/README.md index fe119902..25baa71d 100644 --- a/examples/riak/README.md +++ b/examples/riak/README.md @@ -15,6 +15,7 @@ solar changes run-once last watch -n 1 solar changes report last ``` +Wait until all actions have state `SUCCESS` After that you can add HAProxy on each node: `python examples/riak/riaks.py add_haproxies` @@ -28,6 +29,8 @@ solar changes run-once last watch -n 1 solar changes report last ``` + +Wait until all actions have state `SUCCESS` After that you have basic 3 node riak cluster running. You can also modify riak http port by: From 543d96b49160ae55cfa4581181ce7ab1376d530e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 4 Sep 2015 14:26:33 +0200 Subject: [PATCH 08/15] Delete Dockerfile --- Dockerfile | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d499b764..00000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM debian:jessie -MAINTAINER Andrew Woodward awoodward@mirantis.com - -ENV DEBIAN_FRONTEND noninteractive - -RUN apt-get update && apt-get -y install --fix-missing \ - curl \ - ssh \ - sudo \ - ansible \ - python-pip - -ADD . /vagrant/ -WORKDIR /vagrant - -RUN ansible-playbook -i "localhost," -c local main.yml - -VOLUME /vagrant \ No newline at end of file From 0fac784cf292bd1d6f7eb468906d818a7b7c76bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 4 Sep 2015 14:27:53 +0200 Subject: [PATCH 09/15] Delete simple-deployment.yaml --- simple-deployment.yaml | 43 ------------------------------------------ 1 file changed, 43 deletions(-) delete mode 100755 simple-deployment.yaml diff --git a/simple-deployment.yaml b/simple-deployment.yaml deleted file mode 100755 index 7360183d..00000000 --- a/simple-deployment.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# HAProxy deployment with MariaDB, Keystone and Nova - -workdir: /vagrant -resource-save-path: rs/ -#test-suite: haproxy_deployment.haproxy_deployment - -resources: - - name: node1 - model: x/resources/ro_node/ - args: - ip: 10.0.0.3 - ssh_key: /vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key - ssh_user: vagrant - - - name: keystone1 - model: x/resources/keystone/ - args: - ip: - image: TEST - ssh_user: - ssh_key: - - - name: haproxy_keystone_config - model: x/resources/haproxy_config/ - args: - listen_port: 5000 - ports: {} - servers: {} - - -connections: - - emitter: node1 - receiver: keystone1 - - # Multiple subscription test - - emitter: node1 - receiver: keystone1 - - - emitter: keystone1 - receiver: haproxy_keystone_config - mapping: - ip: servers - port: ports From ed05d83fe89f5efa06d8274438bbb89e4aff2eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 4 Sep 2015 14:34:57 +0200 Subject: [PATCH 10/15] Delete main.yml --- main.yml | 82 -------------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 main.yml diff --git a/main.yml b/main.yml deleted file mode 100644 index 605492dd..00000000 --- a/main.yml +++ /dev/null @@ -1,82 +0,0 @@ ---- - -- hosts: all - sudo: yes - tasks: - - apt: name=git state=present - - apt: name=python-mock state=present - - apt: name=python-keystoneclient state=present - - # PIP - - apt: name=python-pip state=absent - - apt: name=python-six state=absent - - shell: easy_install pip - - shell: pip install -U pip - - shell: pip install -U setuptools - - shell: pip install httpie - - shell: pip install docker-py==1.1.0 - - # Redis - - apt: name=redis-server state=present - - shell: pip install redis - - lineinfile: dest=/etc/redis/redis.conf regexp='^bind ' line='bind 0.0.0.0' - - service: name=redis-server state=restarted - - # Puppet - - shell: wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb -O /root/puppetlabs-release-trusty.deb - - shell: dpkg -i /root/puppetlabs-release-trusty.deb - - shell: apt-get update - - - apt: name=puppet state=present - - git: repo=https://github.com/CGenie/hiera-redis dest=/root/hiera-redis - - shell: gem build hiera-redis.gemspec && gem install hiera-redis-3.0.0.gem chdir=/root/hiera-redis - - template: src=/vagrant/hiera.yaml dest=/etc/puppet/hiera.yaml - - file: path=/etc/puppet/hieradata state=directory - # Make paths puppet 4 compatible - - file: path=/etc/puppetlabs/code/ state=directory - - file: src=/etc/puppet/hiera.yaml dest=/etc/puppetlabs/code/hiera.yaml state=link - - apt: name=ruby-dev state=present - - file: path=/var/tmp/puppet/modules state=directory owner=puppet - - file: path=/var/tmp/puppet/Puppetfile state=touch owner=puppet - - file: path=/etc/puppet/modules state=absent - - file: path=/etc/puppetlabs/code/modules state=absent - - file: path=/etc/puppetlabs/code/hieradata state=absent - - file: src=/var/tmp/puppet/modules dest=/etc/puppet/modules state=link - - file: src=/var/tmp/puppet/modules dest=/etc/puppetlabs/code/modules state=link - - file: src=/etc/puppet/hieradata dest=/etc/puppetlabs/code/hieradata state=link - - shell: gem install librarian-puppet --no-ri --no-rdoc - - # Setup additional development tools - - name: Additional development tools - apt: name={{ item }} state=present - with_items: - - vim - - tmux - - htop - - python-mysqldb - - jq - - ipython - - python-pudb - - # Graph drawing - #- apt: name=python-matplotlib state=present - - apt: name=python-pygraphviz state=present - #- shell: pip install pygraphviz - - # Setup development env for solar - - shell: python setup.py develop chdir=/vagrant/solar - - # Ubuntu OpenStack packages - #- apt: name=ubuntu-cloud-keyring state=present - #- shell: echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/kilo main" > /etc/apt/sources.list.d/cloudarchive-kilo.list - #- shell: echo "deb http://osci-mirror-poz.infra.mirantis.net/pkgs/ubuntu-2015-06-25-194717 trusty-updates main" > /etc/apt/sources.list.d/fuel-kilo.list - #- shell: echo "deb http://osci-mirror-poz.infra.mirantis.net/pkgs/ubuntu-latest trusty main" > /etc/apt/sources.list.d/fuel-kilo.list - # cloudarchive key - #- shell: apt-key adv --recv-key --keyserver keyserver.ubuntu.com 5EDB1B62EC4926EA - # some other keys - #- shell: apt-key adv --recv-key --keyserver keyserver.ubuntu.com 9D6D8F6BC857C906 - #- shell: apt-key adv --recv-key --keyserver keyserver.ubuntu.com 7638D0442B90D010 - # mirantis poznan - #- shell: apt-key adv --recv-key --keyserver keyserver.ubuntu.com 40976EAF437D05B5 - #- shell: apt-key adv --recv-key --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 - #- shell: apt-get update From ec721c668f84806e68abb2b334588057a95f7216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 4 Sep 2015 18:25:17 +0000 Subject: [PATCH 11/15] Remove unused ansible modules. Update resources --- library/new_rabbitmq_user.py | 263 -------------------- library/new_rabbitmq_vhost.py | 157 ------------ resources/rabbitmq_user/actions/remove.yml | 6 +- resources/rabbitmq_user/actions/run.yml | 16 +- resources/rabbitmq_vhost/actions/remove.yml | 4 +- resources/rabbitmq_vhost/actions/run.yml | 4 +- 6 files changed, 15 insertions(+), 435 deletions(-) delete mode 100644 library/new_rabbitmq_user.py delete mode 100644 library/new_rabbitmq_vhost.py diff --git a/library/new_rabbitmq_user.py b/library/new_rabbitmq_user.py deleted file mode 100644 index 95f10d5e..00000000 --- a/library/new_rabbitmq_user.py +++ /dev/null @@ -1,263 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2013, Chatham Financial -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -DOCUMENTATION = ''' ---- -module: rabbitmq_user -short_description: Adds or removes users to RabbitMQ -description: - - Add or remove users to RabbitMQ and assign permissions -version_added: "1.1" -author: Chris Hoffman -options: - user: - description: - - Name of user to add - required: true - default: null - aliases: [username, name] - password: - description: - - Password of user to add. - - To change the password of an existing user, you must also specify - C(force=yes). - required: false - default: null - tags: - description: - - User tags specified as comma delimited - required: false - default: null - vhost: - description: - - vhost to apply access privileges. - required: false - default: / - node: - description: - - erlang node name of the rabbit we wish to configure - required: false - default: rabbit - version_added: "1.2" - configure_priv: - description: - - Regular expression to restrict configure actions on a resource - for the specified vhost. - - By default all actions are restricted. - required: false - default: ^$ - write_priv: - description: - - Regular expression to restrict configure actions on a resource - for the specified vhost. - - By default all actions are restricted. - required: false - default: ^$ - read_priv: - description: - - Regular expression to restrict configure actions on a resource - for the specified vhost. - - By default all actions are restricted. - required: false - default: ^$ - force: - description: - - Deletes and recreates the user. - required: false - default: "no" - choices: [ "yes", "no" ] - state: - description: - - Specify if user is to be added or removed - required: false - default: present - choices: [present, absent] - rabbitmqctl: - description: - - Custom path to rabbitmqctl - required: false - default: null -''' - -EXAMPLES = ''' -# Add user to server and assign full access control -- rabbitmq_user: user=joe - password=changeme - vhost=/ - configure_priv=.* - read_priv=.* - write_priv=.* - state=present -''' - -class RabbitMqUser(object): - def __init__(self, module, username, password, tags, vhost, configure_priv, write_priv, read_priv, node, rabbitmqctl): - self.module = module - self.username = username - self.password = password - self.node = node - if tags is None: - self.tags = list() - else: - self.tags = tags.split(',') - - permissions = dict( - vhost=vhost, - configure_priv=configure_priv, - write_priv=write_priv, - read_priv=read_priv - ) - self.permissions = permissions - - self._tags = None - self._permissions = None - if rabbitmqctl is None: - self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True) - else: - self._rabbitmqctl = rabbitmqctl - - def _exec(self, args, run_in_check_mode=False): - if not self.module.check_mode or (self.module.check_mode and run_in_check_mode): - cmd = self._rabbitmqctl.split() + ['-q', '-n', self.node] - rc, out, err = self.module.run_command(cmd + args, check_rc=True) - return out.splitlines() - return list() - - def get(self): - users = self._exec(['list_users'], True) - - for user_tag in users: - user, tags = user_tag.split('\t') - - if user == self.username: - for c in ['[',']',' ']: - tags = tags.replace(c, '') - - if tags != '': - self._tags = tags.split(',') - else: - self._tags = list() - - self._permissions = self._get_permissions() - return True - return False - - def _get_permissions(self): - perms_out = self._exec(['list_user_permissions', self.username], True) - - for perm in perms_out: - vhost, configure_priv, write_priv, read_priv = perm.split('\t') - if vhost == self.permissions['vhost']: - return dict(vhost=vhost, configure_priv=configure_priv, write_priv=write_priv, read_priv=read_priv) - - return dict() - - def add(self): - if self.password is not None: - self._exec(['add_user', self.username, self.password]) - else: - self._exec(['add_user', self.username, '']) - self._exec(['clear_password', self.username]) - - def delete(self): - self._exec(['delete_user', self.username]) - - def set_tags(self): - self._exec(['set_user_tags', self.username] + self.tags) - - def set_permissions(self): - cmd = ['set_permissions'] - cmd.append('-p') - cmd.append(self.permissions['vhost']) - cmd.append(self.username) - cmd.append(self.permissions['configure_priv']) - cmd.append(self.permissions['write_priv']) - cmd.append(self.permissions['read_priv']) - self._exec(cmd) - - def has_tags_modifications(self): - return set(self.tags) != set(self._tags) - - def has_permissions_modifications(self): - return self._permissions != self.permissions - -def main(): - arg_spec = dict( - user=dict(required=True, aliases=['username', 'name']), - password=dict(default=None), - tags=dict(default=None), - vhost=dict(default='/'), - configure_priv=dict(default='^$'), - write_priv=dict(default='^$'), - read_priv=dict(default='^$'), - force=dict(default='no', type='bool'), - state=dict(default='present', choices=['present', 'absent']), - node=dict(default='rabbit'), - rabbitmqctl=dict(default=None, aliases=['rabbitmqctl']), - ) - module = AnsibleModule( - argument_spec=arg_spec, - supports_check_mode=True - ) - - username = module.params['user'] - password = module.params['password'] - tags = module.params['tags'] - vhost = module.params['vhost'] - configure_priv = module.params['configure_priv'] - write_priv = module.params['write_priv'] - read_priv = module.params['read_priv'] - force = module.params['force'] - state = module.params['state'] - node = module.params['node'] - rabbitmqctl = module.params['rabbitmqctl'] - - rabbitmq_user = RabbitMqUser(module, username, password, tags, vhost, configure_priv, write_priv, read_priv, node, rabbitmqctl) - - changed = False - if rabbitmq_user.get(): - if state == 'absent': - rabbitmq_user.delete() - changed = True - else: - if force: - rabbitmq_user.delete() - rabbitmq_user.add() - rabbitmq_user.get() - changed = True - - if rabbitmq_user.has_tags_modifications(): - rabbitmq_user.set_tags() - changed = True - - if rabbitmq_user.has_permissions_modifications(): - rabbitmq_user.set_permissions() - changed = True - elif state == 'present': - rabbitmq_user.add() - rabbitmq_user.set_tags() - rabbitmq_user.set_permissions() - changed = True - - module.exit_json(changed=changed, user=username, state=state) - -# import module snippets -from ansible.module_utils.basic import * -main() diff --git a/library/new_rabbitmq_vhost.py b/library/new_rabbitmq_vhost.py deleted file mode 100644 index 88435f46..00000000 --- a/library/new_rabbitmq_vhost.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2013, Chatham Financial -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . -# - -DOCUMENTATION = ''' ---- -module: rabbitmq_vhost -short_description: Manage the state of a virtual host in RabbitMQ -description: - - Manage the state of a virtual host in RabbitMQ -version_added: "1.1" -author: Chris Hoffman -options: - name: - description: - - The name of the vhost to manage - required: true - default: null - aliases: [vhost] - node: - description: - - erlang node name of the rabbit we wish to configure - required: false - default: rabbit - version_added: "1.2" - tracing: - description: - - Enable/disable tracing for a vhost - default: "no" - choices: [ "yes", "no" ] - aliases: [trace] - state: - description: - - The state of vhost - default: present - choices: [present, absent] - rabbitmqctl: - description: - - Custom path to rabbitmqctl - required: false - default: null -''' - -EXAMPLES = ''' -# Ensure that the vhost /test exists. -- rabbitmq_vhost: name=/test state=present -''' - -class RabbitMqVhost(object): - def __init__(self, module, name, tracing, node, rabbitmqctl): - self.module = module - self.name = name - self.tracing = tracing - self.node = node - - self._tracing = False - if rabbitmqctl is None: - self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True) - else: - self._rabbitmqctl = rabbitmqctl - - def _exec(self, args, run_in_check_mode=False): - if not self.module.check_mode or (self.module.check_mode and run_in_check_mode): - cmd = self._rabbitmqctl.split() + ['-q', '-n', self.node] - rc, out, err = self.module.run_command(cmd + args, check_rc=True) - return out.splitlines() - return list() - - def get(self): - vhosts = self._exec(['list_vhosts', 'name', 'tracing'], True) - - for vhost in vhosts: - name, tracing = vhost.split('\t') - if name == self.name: - self._tracing = self.module.boolean(tracing) - return True - return False - - def add(self): - return self._exec(['add_vhost', self.name]) - - def delete(self): - return self._exec(['delete_vhost', self.name]) - - def set_tracing(self): - if self.tracing != self._tracing: - if self.tracing: - self._enable_tracing() - else: - self._disable_tracing() - return True - return False - - def _enable_tracing(self): - return self._exec(['trace_on', '-p', self.name]) - - def _disable_tracing(self): - return self._exec(['trace_off', '-p', self.name]) - - -def main(): - arg_spec = dict( - name=dict(required=True, aliases=['vhost']), - rabbitmqctl=dict(default=None, aliases=['rabbitmqctl']), - tracing=dict(default='off', aliases=['trace'], type='bool'), - state=dict(default='present', choices=['present', 'absent']), - node=dict(default='rabbit'), - ) - - module = AnsibleModule( - argument_spec=arg_spec, - supports_check_mode=True - ) - - name = module.params['name'] - rabbitmqctl = module.params['rabbitmqctl'] - tracing = module.params['tracing'] - state = module.params['state'] - node = module.params['node'] - - rabbitmq_vhost = RabbitMqVhost(module, name, tracing, node, rabbitmqctl) - - changed = False - if rabbitmq_vhost.get(): - if state == 'absent': - rabbitmq_vhost.delete() - changed = True - else: - if rabbitmq_vhost.set_tracing(): - changed = True - elif state == 'present': - rabbitmq_vhost.add() - rabbitmq_vhost.set_tracing() - changed = True - - module.exit_json(changed=changed, name=name, state=state) - -# import module snippets -from ansible.module_utils.basic import * -main() diff --git a/resources/rabbitmq_user/actions/remove.yml b/resources/rabbitmq_user/actions/remove.yml index b73859bc..cafb5982 100644 --- a/resources/rabbitmq_user/actions/remove.yml +++ b/resources/rabbitmq_user/actions/remove.yml @@ -1,6 +1,6 @@ - hosts: [{{ ip }}] sudo: yes tasks: - - new_rabbitmq_user: user={{user_name}} - vhost={{vhost_name}} - state=absent + - rabbitmq_user: user={{user_name}} + vhost={{vhost_name}} + state=absent diff --git a/resources/rabbitmq_user/actions/run.yml b/resources/rabbitmq_user/actions/run.yml index 9964c22b..0a9f719a 100644 --- a/resources/rabbitmq_user/actions/run.yml +++ b/resources/rabbitmq_user/actions/run.yml @@ -1,11 +1,11 @@ - hosts: [{{ ip }}] sudo: yes tasks: - - new_rabbitmq_user: user={{user_name}} - password={{password}} - vhost={{vhost_name}} - configure_priv=.* - read_priv=.* - write_priv=.* - tags={{tags}} - state=present + - rabbitmq_user: user={{user_name}} + password={{password}} + vhost={{vhost_name}} + configure_priv=.* + read_priv=.* + write_priv=.* + tags={{tags}} + state=present diff --git a/resources/rabbitmq_vhost/actions/remove.yml b/resources/rabbitmq_vhost/actions/remove.yml index 8dcefd7f..f5d1a7ce 100644 --- a/resources/rabbitmq_vhost/actions/remove.yml +++ b/resources/rabbitmq_vhost/actions/remove.yml @@ -1,5 +1,5 @@ - hosts: [{{ ip }}] sudo: yes tasks: - - new_rabbitmq_vhost: name={{vhost_name}} - state=absent + - rabbitmq_vhost: name={{vhost_name}} + state=absent diff --git a/resources/rabbitmq_vhost/actions/run.yml b/resources/rabbitmq_vhost/actions/run.yml index 52b8bb20..dadf4b76 100644 --- a/resources/rabbitmq_vhost/actions/run.yml +++ b/resources/rabbitmq_vhost/actions/run.yml @@ -1,5 +1,5 @@ - hosts: [{{ ip }}] sudo: yes tasks: - - new_rabbitmq_vhost: name={{vhost_name}} - state=present + - rabbitmq_vhost: name={{vhost_name}} + state=present From 99db986ef96c1b0735bb99f4c5215524182d7cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 4 Sep 2015 19:53:10 +0000 Subject: [PATCH 12/15] Remove mock from requirements. It is already added to requiremenets-test --- solar/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/solar/requirements.txt b/solar/requirements.txt index c4288753..1896bfa0 100644 --- a/solar/requirements.txt +++ b/solar/requirements.txt @@ -16,4 +16,3 @@ Fabric==1.10.2 tabulate==0.7.5 ansible celery -mock From 6b5673a2dce2af722216d22754be6baf2fe038a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Fri, 4 Sep 2015 20:02:42 +0000 Subject: [PATCH 13/15] Add required packages for run_tests.sh --- bootstrap/playbooks/tasks/base.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bootstrap/playbooks/tasks/base.yml b/bootstrap/playbooks/tasks/base.yml index 813bb09d..612a79cd 100644 --- a/bootstrap/playbooks/tasks/base.yml +++ b/bootstrap/playbooks/tasks/base.yml @@ -25,6 +25,8 @@ # Dev - ipython - python-pudb + - python-dev + - python-virtualenv # Required by packer - build-essential From b9f3006075d7d5627bf00e7b56c30b0b0aa19587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Mon, 7 Sep 2015 06:59:06 +0000 Subject: [PATCH 14/15] Move requiring mock to requirements.txt. It is used in cli --- solar/requirements.txt | 1 + solar/test-requirements.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/solar/requirements.txt b/solar/requirements.txt index 1896bfa0..c4288753 100644 --- a/solar/requirements.txt +++ b/solar/requirements.txt @@ -16,3 +16,4 @@ Fabric==1.10.2 tabulate==0.7.5 ansible celery +mock diff --git a/solar/test-requirements.txt b/solar/test-requirements.txt index fe653b6e..bc04b496 100644 --- a/solar/test-requirements.txt +++ b/solar/test-requirements.txt @@ -1,2 +1 @@ -r requirements.txt -mock From ceaabc02aa5ca3df026d68225178225ab578eea4 Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Mon, 7 Sep 2015 10:21:32 +0300 Subject: [PATCH 15/15] Add README for lxc example --- examples/lxc/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/lxc/README.md diff --git a/examples/lxc/README.md b/examples/lxc/README.md new file mode 100644 index 00000000..b9803372 --- /dev/null +++ b/examples/lxc/README.md @@ -0,0 +1,25 @@ +Bootstraping lxc containers using solar and roles from os-ansible-deployment + +At first run: + +`python examples/lxc/example-lxc.py deploy` + +It will do several things: + +* Prepare about ~10 containers on solar-dev1 +* Add linux bridge on solar-dev and solar-dev1 with uid br-int53 +* Setup vxlan tunnel for solar-dev and solar-dev1 +* Generate ssh key and inject it into containers + +Later this containers can be used as regular nodes in solar. +Check rabbitmq example at the end of the file. + +To deploy everything use usual solar commands. +``` +solar changes stage -d +solar changes process +solar changes run-once last +watch -n 1 solar changes report last +``` + +Wait until all actions have state `SUCCESS`