ansible-role-rabbitmq/tasks/users.yml
2022-03-27 20:04:38 -07:00

90 lines
2.2 KiB
YAML

---
# No guest users
- name: Remove guest user
community.rabbitmq.rabbitmq_user:
user: guest
state: absent
tags:
- rabbitmq_cluster
# Add the admin user
- name: Create the admin user for our vhosts
community.rabbitmq.rabbitmq_user:
user: rockyadmin
password: "{{ rabbitmq_admin_password }}"
vhost: "{{ item }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
tags: administrator
when: "'rabbitmq001' in inventory_hostname"
with_items:
- /
- pubsub
- public_pubsub
tags:
- rabbitmq_cluster
- name: Drop the admin password in a file for admin operations
ansible.builtin.copy:
dest: /root/.rabbitmqpass
content: "{{ rabbitmq_admin_password }}"
mode: '0600'
owner: root
group: root
tags:
- rabbitmq_cluster
# Create a monitoring user as long as the vars are set
- name: Create monitoring user
community.rabbitmq.rabbitmq_user:
user: "{{ rabbitmq_monitoring_username }}"
password: "{{ rabbitmq_monitoring_password }}"
update_password: always
permissions:
- vhost: /
configure_priv: "^$"
read_priv: "^$"
write_priv: "^$"
- vhost: pubsub
configure_priv: "^$"
read_priv: "^$"
write_priv: "^$"
- vhost: public_pubsub
configure_priv: "^$"
read_priv: "^$"
write_priv: "^$"
tags: monitoring
when:
- "'rabbitmq001' in inventory_hostname"
- rabbitmq_monitoring_username is defined
- rabbitmq_monitoring_password is defined
# Add MBS
- name: Create MBS User
community.rabbitmq.rabbitmq_user:
user: "mbs"
password: "{{ rabbitmq_mbs_password }}"
update_password: always
vhost: mbs
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
when:
- "'rabbitmq001' in inventory_hostname"
- rabbitmq_mbs_password is defined
# Add distrobuild
- name: Create distrobuild User
community.rabbitmq.rabbitmq_user:
user: "distrobuild"
password: "{{ rabbitmq_mbs_password }}"
update_password: always
vhost: distrobuild
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
when:
- "'rabbitmq001' in inventory_hostname"
- rabbitmq_distrobuild_password is defined