ansible-ops-management/role-rocky-rabbitmq.yml

105 lines
2.9 KiB
YAML

---
# Stands up a RabbitMQ Cluster
- name: Configure RabbitMQ
hosts: rabbitmq_{{ rabbitmq_env }}
become: true
vars_files:
# vars/vaults/encpass.yml
- vars/common.yml
- "vars/rabbitmq/{{ rabbitmq_cluster_tag }}/rabbitmq.yml"
- "vars/rabbitmq/{{ rabbitmq_cluster_tag }}rlp/rabbitmq_vhost.yml"
- "vars/rabbitmq/{{ rabbitmq_cluster_tag }}rlp/rabbitmq_users.yml"
# This is to try to avoid the handler issue in pre/post tasks
handlers:
- import_tasks: handlers/main.yml
pre_tasks:
- name: Check if ansible cannot be run here
stat:
path: /etc/no-ansible
register: no_ansible
- name: Verify if we can run ansible
ansible.builtin.assert:
that:
- "not no_ansible.stat.exists"
success_msg: "We are able to run on this node"
fail_msg: "/etc/no-ansible exists - skipping run on this node"
- name: Verify if we are Rocky Linux 9 or higher
ansible.builtin.assert:
that:
- ansible_distribution_major_version|int >= 9
- ansible_distribution | lower == "rocky"
success_msg: "We are on a supported system"
fail_msg: "Only Rocky Linux versions 9 or higher are supported."
- name: Verify that rabbitmq cluster name is defined
ansible.builtin.assert:
that:
- rabbitmq_cluster_name|mandatory
success_msg: "Cluster name is {{ rabbitmq_cluster_name }}"
fail_msg: "Cluster name is not defined"
# We have separate passwords per rabbitmq env
- name: Import rabbitmq passwords
ansible.builtin.include_vars:
file: "vars/vaults/rabbitmq_{{ rabbitmq_env }}.yml"
# The extras repos has epel-release provided
- name: Enable the EPEL repository
ansible.builtin.dnf:
name: epel-release
state: present
notify:
- enable_crb
tags:
- packages
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Install centos rabbitmq
yum:
name: centos-release-rabbitmq-39
state: present
tags:
- packages
roles:
- role: rockylinux.ipagetcert
state: present
when: rabbitmq_private
tasks:
- name: Run rabbitmq installation
ansible.builtin.import_tasks: "tasks/rabbitmq/rabbitmq.yml"
tags:
- rabbitmq_cluster
- name: Run rabbitmq vhosts
ansible.builtin.import_tasks: "tasks/rabbitmq/vhost.yml"
tags:
- vhosts
- name: Run rabbitmq users
ansible.builtin.import_tasks: "tasks/rabbitmq/users.yml"
tags:
- users
- name: Run rabbitmq topics
ansible.builtin.import_tasks: "tasks/rabbitmq/topics.yml"
tags:
- topics
post_tasks:
- name: Touching run file that ansible has ran here
ansible.builtin.file:
path: /var/log/ansible.run
state: touch
mode: '0644'
owner: root
group: root
...