aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLarry Smith Jr <mrlesmithjr@gmail.com>2018-12-20 14:44:45 -0500
committerGitHub <noreply@github.com>2018-12-20 14:44:45 -0500
commitf6c833a9ce9369e7a37d6cc6707422d5cf00b56d (patch)
tree3ed0736da3c695bdadad8bc99e358d9f12c5cd57
parentd58696271f166b50faa2705fdda6337c1ffb493c (diff)
parent18be22a714897afa9da5db7e59bc02f606d6d6d7 (diff)
downloadansible-rabbitmq-f6c833a9ce9369e7a37d6cc6707422d5cf00b56d.tar.gz
ansible-rabbitmq-f6c833a9ce9369e7a37d6cc6707422d5cf00b56d.tar.zst
ansible-rabbitmq-f6c833a9ce9369e7a37d6cc6707422d5cf00b56d.zip
Merge pull request #21 from paulrbr-fl/adding-vhost-mngt
vhosts: Adding rabbitmq vhosts creation
-rw-r--r--defaults/main.yml5
-rw-r--r--tasks/main.yml3
-rw-r--r--tasks/rabbitmq_vhosts.yml25
3 files changed, 33 insertions, 0 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index f3d2c20..f7138a7 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -58,6 +58,11 @@ rabbitmq_redhat_package: "rabbitmq-server-{{ rabbitmq_redhat_version }}-1.noarch
58rabbitmq_redhat_url: "http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}" 58rabbitmq_redhat_url: "http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}"
59rabbitmq_redhat_version: 3.6.1 59rabbitmq_redhat_version: 3.6.1
60 60
61# Define extra vhosts to be created
62rabbitmq_extra_vhosts: []
63# - name: /
64# state: present
65
61# Define admin user to create in order to login to WebUI 66# Define admin user to create in order to login to WebUI
62rabbitmq_users: 67rabbitmq_users:
63 - name: rabbitmqadmin 68 - name: rabbitmqadmin
diff --git a/tasks/main.yml b/tasks/main.yml
index 1ef08f0..a9dc4d2 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -26,6 +26,9 @@
26 rabbitmq_enable_clustering and 26 rabbitmq_enable_clustering and
27 not clustered['stat']['exists'] 27 not clustered['stat']['exists']
28 28
29- include: rabbitmq_vhosts.yml
30 when: rabbitmq_extra_vhosts is defined
31
29- include: rabbitmq_ha_config.yml 32- include: rabbitmq_ha_config.yml
30 when: > 33 when: >
31 rabbitmq_config_ha and 34 rabbitmq_config_ha and
diff --git a/tasks/rabbitmq_vhosts.yml b/tasks/rabbitmq_vhosts.yml
new file mode 100644
index 0000000..a02af62
--- /dev/null
+++ b/tasks/rabbitmq_vhosts.yml
@@ -0,0 +1,25 @@
1---
2- name: rabbitmq_extra_vhosts | Create vhosts
3 rabbitmq_vhost:
4 name: "{{ item['name'] }}"
5 state: "{{ item['state'] }}"
6 with_items: "{{ rabbitmq_extra_vhosts }}"
7 run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}"
8 register: rabbitmq_created_vhosts
9
10- name: rabbitmq_extra_vhosts | Check guest administrator is present
11 command: rabbitmqctl -q list_users
12 become: true
13 run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}"
14 when: rabbitmq_created_vhosts.changed
15 changed_when: false
16 register: rabbitmq_existing_users
17
18- name: rabbitmq_extra_vhosts | Give access to new vhosts to guest administrator
19 command: "rabbitmqctl -q set_permissions -p {{ item['name'] }} guest '.*' '.*' '.*'"
20 become: true
21 run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}"
22 with_items: "{{ rabbitmq_created_vhosts.results|selectattr('changed')|list }}"
23 when:
24 - item['state'] == 'present'
25 - rabbitmq_existing_users.stdout_lines | map('regex_search', '^guest\\s\\[.*administrator.*\\]$') | list | difference([None]) | length > 0