Hello,
I’m working on a rabbitmqAnsible role and I have to write the task dedicated to users creation and configuration.
I defined the following variable in my playbook:
vars:
- rabbitmq_resources:
- type_resource: “vhost”
name: “/test”
node: “rabbit@host1ansible” - type_resource: “vhost”
name: “/other”
node: “rabbit@host1ansible” - type_resource: “user”
name: “rabbitmqadmin”
password: “rabbitmqadmin”
permissions: - vhost: “/test”
configure_priv: “."
read_priv: ".”
write_priv: “.*” - vhost: “/other”
configure_priv: “."
read_priv: ".”
write_priv: “.*”
tags: “administrator”
state: present
Then I want to write the task code dedicated to user processing:
- name: Creating RabbitMQ users
rabbitmq_user:
name: “{{ item.name|mandatory }}”
permissions:
vhost: “{{ item.value.vhost }}”
configure_priv: “{{ item.value.configure_priv }}”
read_priv: “{{ item.value.read_priv }}”
write_priv: “{{ item.value.write_priv }}”
tags: “{{ item.tags }}”
state: present
with_subelements: - “{{ rabbitmq_resources }}”
- type_resource
- permissions
when: item.type_resource == “user”
The syntax above generates a message “subelements lookup expects a list of two or three items, the optional third item must be a dict with flags skip_missing”.
I tested various loop syntaxes (with_items, with_subelements, with_dict) but I’m still unable to find the right one.
Help will be appreciated.
Thank’s
Dan