diff options
author | Paul Bonaud <paul.bonaud@fretlink.com> | 2018-12-20 18:25:54 +0100 |
---|---|---|
committer | Paul Bonaud <paul.bonaud@fretlink.com> | 2018-12-20 18:58:02 +0100 |
commit | 18be22a714897afa9da5db7e59bc02f606d6d6d7 (patch) | |
tree | 3ed0736da3c695bdadad8bc99e358d9f12c5cd57 | |
parent | 84d38251e016aebeb6fc72a5c76a486f0542212b (diff) | |
download | ansible-rabbitmq-18be22a714897afa9da5db7e59bc02f606d6d6d7.tar.gz ansible-rabbitmq-18be22a714897afa9da5db7e59bc02f606d6d6d7.tar.zst ansible-rabbitmq-18be22a714897afa9da5db7e59bc02f606d6d6d7.zip |
vhosts: give full permissions to default guest administrator
-rw-r--r-- | tasks/rabbitmq_vhosts.yml | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tasks/rabbitmq_vhosts.yml b/tasks/rabbitmq_vhosts.yml index 790ac18..a02af62 100644 --- a/tasks/rabbitmq_vhosts.yml +++ b/tasks/rabbitmq_vhosts.yml | |||
@@ -1,7 +1,25 @@ | |||
1 | --- | 1 | --- |
2 | - name: Create vhosts | 2 | - name: rabbitmq_extra_vhosts | Create vhosts |
3 | rabbitmq_vhost: | 3 | rabbitmq_vhost: |
4 | name: "{{ item['name'] }}" | 4 | name: "{{ item['name'] }}" |
5 | state: "{{ item['state'] }}" | 5 | state: "{{ item['state'] }}" |
6 | with_items: "{{ rabbitmq_extra_vhosts }}" | 6 | with_items: "{{ rabbitmq_extra_vhosts }}" |
7 | run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" | 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 | ||