Commit 4b69defb by Feanil Patel

A working rabbitmq role.

The role finally bring up the rabbit nodes in cluster mode and
adds/removes users correctly.
parent a9a8b5d6
--- ---
# Tasks related to setting up the rabbitmq machines # Tasks related to setting up the rabbitmq machines
- name: create a rabbitmq group
group: name=rabbitmq
- name: install rabbitmq - name: create a rabbitmq user
apt: pkg={{rabbitmq_pkg}} state=present user: name=rabbitmq group=rabbitmq
# Defaulting to /var/lib/rabbitmq
- name: crate cookie 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
template: src=erlang.cookie.j2 dest={{rabbitmq_cookie_location}} owner=rabbitmq group=rabbitmq mode=0400
# Defaulting to /etc/rabbitmq
- name: create rabbitmq directory - name: create rabbitmq 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
template: src=rabbitmq-env.conf.j2 dest={{rabbitmq_config_dir}}/rabbitmq-env.conf owner=root group=root mode=0644
- 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
- name: add rabbitmq environment configuration - name: install rabbitmq
template: src=rabbitmq-env.conf.j2 dest={{rabbitmq_config_dir}}/rabbitmq-env.conf owner=root group=root mode=0644 apt: pkg={{rabbitmq_pkg}} state=present
- name: crate cookie directory - name: stop rabbit cluster
file: path={{rabbitmq_cookie_dir}} owner=rabbitmq group=rabbitmq mode=0755 state=directory service: name="rabbitmq-server" state=stopped
- name: add rabbitmq erlang cookie # For some reason this needs to be run from the shell. Running it via the
template: src=erlang.cookie.j2 dest={{rabbitmq_cookie_location}} owner=rabbitmq group=rabbitmq mode=0400 # 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
shell: executable=/bin/bash service rabbitmq-server start
tags:
- testit
- name: remove guest user
rabbitmq_user: user="guest" state=absent
ignore_errors: True
- name: add admin users
rabbitmq_user: user='{{item.name}}' password='{{item.password}}' tags="administrator" state=present
with_items: rabbitmq_auth_config.admins
when: "'admins' in rabbitmq_auth_config"
ignore_errors: True
# Verify user changes
- name: get rabbit user list - name: get rabbit user list
command: rabbitmqctl list_users command: rabbitmqctl list_users
register: rabbitmq_users register: rabbitmq_users
- name: start rabbit cluster - name: check all expected users exist.
service: name="rabbitmq-server" state=restarted command: rabbitmqctl list_user_permissions {{item.name}}
with_items: rabbitmq_auth_config.admins
- name: delete guest user - name: make sure guest has been removed
command: rabbitmqctl delete_user guest fail: "Guest user still has an account."
when: rabbitmq_users.stdout.contains("guest") when: "'guest' in rabbitmq_users"
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