From: Paul Bonaud Date: Thu, 20 Dec 2018 17:25:54 +0000 (+0100) Subject: vhosts: give full permissions to default guest administrator X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=18be22a714897afa9da5db7e59bc02f606d6d6d7;p=github%2Ffretlink%2Fansible-rabbitmq.git vhosts: give full permissions to default guest administrator --- 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 @@ --- -- name: Create vhosts +- name: rabbitmq_extra_vhosts | Create vhosts rabbitmq_vhost: name: "{{ item['name'] }}" state: "{{ item['state'] }}" with_items: "{{ rabbitmq_extra_vhosts }}" run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" + register: rabbitmq_created_vhosts + +- name: rabbitmq_extra_vhosts | Check guest administrator is present + command: rabbitmqctl -q list_users + become: true + run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" + when: rabbitmq_created_vhosts.changed + changed_when: false + register: rabbitmq_existing_users + +- name: rabbitmq_extra_vhosts | Give access to new vhosts to guest administrator + command: "rabbitmqctl -q set_permissions -p {{ item['name'] }} guest '.*' '.*' '.*'" + become: true + run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" + with_items: "{{ rabbitmq_created_vhosts.results|selectattr('changed')|list }}" + when: + - item['state'] == 'present' + - rabbitmq_existing_users.stdout_lines | map('regex_search', '^guest\\s\\[.*administrator.*\\]$') | list | difference([None]) | length > 0