Commit 95692ce9 by Feanil Patel

Playbook simplified by moving to rabbitmq 3.x instead of 2.x

parent 4b69defb
--- ---
# Tasks related to setting up the rabbitmq machines # It is recommended that this role be played with serial set to 1 because
- name: create a rabbitmq group # There is a bug with initializing multiple nodes in the HA cluster at once
group: name=rabbitmq # http://rabbitmq.1065348.n5.nabble.com/Rabbitmq-boot-failure-with-quot-tables-not-present-quot-td24494.html
- name: create a rabbitmq user - name: trust rabbit repository
user: name=rabbitmq group=rabbitmq apt_key: url={{rabbitmq_apt_key}} state=present
- name: add rabbit repository
apt_repository: repo="{{rabbitmq_repository}}" state=present
- name: install rabbitmq
apt: pkg={{rabbitmq_pkg}} state=present
- name: stop rabbit cluster
service: name=rabbitmq-server state=stopped
# Defaulting to /var/lib/rabbitmq # Defaulting to /var/lib/rabbitmq
- name: crate cookie directory - name: create cookie directory
file: path={{rabbitmq_cookie_dir}} owner=rabbitmq group=rabbitmq mode=0755 state=directory file: path={{rabbitmq_cookie_dir}} owner=rabbitmq group=rabbitmq mode=0755 state=directory
- name: add rabbitmq erlang cookie
template: src=erlang.cookie.j2 dest=/home/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400
- name: add rabbitmq erlang cookie - name: add rabbitmq erlang cookie
template: src=erlang.cookie.j2 dest={{rabbitmq_cookie_location}} owner=rabbitmq group=rabbitmq mode=0400 template: src=erlang.cookie.j2 dest={{rabbitmq_cookie_location}} owner=rabbitmq group=rabbitmq mode=0400
register: erlang_cookie
# Defaulting to /etc/rabbitmq # Defaulting to /etc/rabbitmq
- name: create rabbitmq directory - name: create rabbitmq config directory
file: path={{rabbitmq_config_dir}} owner=root group=root mode=0755 state=directory file: path={{rabbitmq_config_dir}} owner=root group=root mode=0755 state=directory
- name: add rabbitmq environment configuration - name: add rabbitmq environment configuration
...@@ -25,45 +33,22 @@ ...@@ -25,45 +33,22 @@
- name: add rabbitmq cluster configuration - name: add rabbitmq cluster configuration
template: src=rabbitmq.config.j2 dest={{rabbitmq_config_dir}}/rabbitmq.config owner=root group=root mode=0644 template: src=rabbitmq.config.j2 dest={{rabbitmq_config_dir}}/rabbitmq.config owner=root group=root mode=0644
register: cluster_configuration
- name: install rabbitmq # When rabbitmq starts up it creates a folder of metadata at '/var/lib/rabbitmq/mnesia'.
apt: pkg={{rabbitmq_pkg}} state=present # This folder should be deleted before clustering is setup because it retains data
# that can conflict with the clustering information.
- name: stop rabbit cluster - name: remove mnesia configuration
service: name="rabbitmq-server" state=stopped file: path={{rabbitmq_mnesia_folder}} state=absent
when: erlang_cookie.changed or cluster_configuration.changed
# For some reason this needs to be run from the shell. Running it via the
# service module produces inconsintent results.
- name: kill rabbit nodes
shell: executable=/bin/bash killall epmd beam
ignore_errors: True
tags:
- testit
- name: start rabbit nodes - name: start rabbit nodes
shell: executable=/bin/bash service rabbitmq-server start service: name=rabbitmq-server state=restarted
tags:
- testit
- name: remove guest user - name: remove guest user
rabbitmq_user: user="guest" state=absent rabbitmq_user: user="guest" state=absent
ignore_errors: True
- name: add admin users - name: add admin users
rabbitmq_user: user='{{item.name}}' password='{{item.password}}' tags="administrator" state=present rabbitmq_user: user='{{item.name}}' password='{{item.password}}' tags="administrator" state=present
with_items: rabbitmq_auth_config.admins with_items: rabbitmq_auth_config.admins
when: "'admins' in rabbitmq_auth_config" when: "'admins' in rabbitmq_auth_config"
ignore_errors: True
# Verify user changes
- name: get rabbit user list
command: rabbitmqctl list_users
register: rabbitmq_users
- name: check all expected users exist.
command: rabbitmqctl list_user_permissions {{item.name}}
with_items: rabbitmq_auth_config.admins
- name: make sure guest has been removed
fail: "Guest user still has an account."
when: "'guest' in rabbitmq_users"
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
{%- endfor -%} {%- endfor -%}
[{rabbit, [{rabbit,
[{cluster_nodes, ['{{ hosts|join("\',\'") }}']}]}]. [{cluster_nodes, {['{{ hosts|join("\',\'") }}'], disc}}]}].
#Varibables for rabbitmq #Varibables for rabbitmq
--- ---
rabbitmq_apt_key: "http://www.rabbitmq.com/rabbitmq-signing-key-public.asc"
rabbitmq_repository: "deb http://www.rabbitmq.com/debian/ testing main"
rabbitmq_pkg: "rabbitmq-server" rabbitmq_pkg: "rabbitmq-server"
rabbitmq_config_dir: "/etc/rabbitmq" rabbitmq_config_dir: "/etc/rabbitmq"
rabbitmq_cookie_dir: "/var/lib/rabbitmq" rabbitmq_cookie_dir: "/var/lib/rabbitmq"
rabbitmq_cookie_location: "{{rabbitmq_cookie_dir}}/.erlang.cookie" rabbitmq_cookie_location: "{{rabbitmq_cookie_dir}}/.erlang.cookie"
rabbitmq_mnesia_folder: "{{rabbitmq_cookie_dir}}/mnesia"
rabbitmq_port: 5672 rabbitmq_port: 5672
rabbitmq_auth_config: rabbitmq_auth_config:
erlang_cookie: "YK+MSzXQskeVz6ap1P5zfg==" erlang_cookie: "CHANGE ME"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment