marcobellaccini.ansible_rabbitmq_minimalistic

ansible-rabbitmq-minimalistic

============================= Build Status

A simple and effective Ansible role for setting up RabbitMQ with clustering capabilities.

This role is designed for Debian 10 but may work on other versions and distributions. Please let me know if it does.

Role Variables

By default, you can check the role's defaults in this file. To customize your RabbitMQ setup, you can create and upload your own rabbitmq.conf file to the servers.

To generate and deploy this custom rabbitmq.conf, define the variable rabbitmq_conf_template like this:

rabbitmq_conf_template: "path/to/rabbitmq.conf.j2"

Make sure the path is relative to the playbook directory.

This allows you to easily set up a RabbitMQ cluster by using the server variable cluster_formation.classic_config.nodes in your rabbitmq.conf.

For instance, your rabbitmq.conf.j2 template can look like this:

{% for host in ansible_play_hosts_all %}
cluster_formation.classic_config.nodes.{{ loop.index }} = rabbit@{{ hostvars[host]['inventory_hostname'] }}
{% endfor %}

To enable clustering, all hosts must share the same erlang cookie. You can set this up using the rabbitmq_erlang_cookie variable (consider using Ansible Vault for security).

When clustering, remember to add serial: 1 in your playbook to avoid issues when forming the cluster.

You can also enable RabbitMQ plugins by specifying a template for an enabled_plugins file:

rabbitmq_enabled_plugins_template: "path/to/enabled_plugins.j2"

Again, ensure the path is relative to the playbook directory.

For added variables, check Role Defaults.

This role is designed to be straightforward; for more advanced configurations, consider using Ansible RabbitMQ Modules.

Example Playbook

- hosts: msgservers
  serial: 1  # Required for RabbitMQ clustering
  roles:
     - ansible-rabbitmq-minimalistic
  vars:
    rabbitmq_conf_template: "my_rabbit_conf/rabbitmq.conf.j2"  # Optional
    rabbitmq_enabled_plugins_template: "my_rabbit_conf/enabled_plugins.j2"  # Optional
    rabbitmq_erlang_cookie: "XXXXXXXXXXXXXXXXXXXX"  # Required for clustering. NOTE: Use Ansible Vault for security!

License

Apache License 2.0

Author Information

Marco Bellaccini - marco.bellaccini[at!]gmail.com

Find me on GitHub

Informazioni sul progetto

Minimalistic, yet powerful and clustering-enabled RabbitMQ Ansible role.

Installa
ansible-galaxy install marcobellaccini.ansible_rabbitmq_minimalistic
Licenza
apache-2.0
Download
88
Proprietario
Infrastructure, security and automation at RAI - Italian national public broadcasting company. Personal account.