Skip to content

Commit

Permalink
Using new RabbitMQ config format (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanadeau authored Nov 20, 2019
1 parent 7071d04 commit 917890b
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See:
Set the `rabbitmq_version` variable to define the version of RabbitMQ to install.

```yaml
rabbitmq_version: '3.7.7'
rabbitmq_version: '3.8.1'
```
## Users
Expand Down Expand Up @@ -115,16 +115,21 @@ rabbitmq_plugins_disabled:

See:

- [Pico Trading - Config Encoder Macros](https://github.com/picotrading/config-encoder-macros)
- [RabbitMQ - Configuration File](https://www.rabbitmq.com/configure.html#configuration-file)
- [RabbitMQ - Configuration](https://www.rabbitmq.com/configure.html)

Set the `rabbitmq_config` variable to define the configuration.

```yaml
rabbitmq_config:
- rabbit:
- tcp_listeners:
- "'0.0.0.0'": 5671
listeners.tcp.default: 5672
```

Set the `rabbitmq_env` variable to define the environment variables. Note that the keys should not contain the
"RABBITMQ_" prefix.

```yaml
rabbitmq_env:
DIST_PORT: 25672
```

## Cluster
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rabbitmq_users:
rabbitmq_users_absent:
- guest

rabbitmq_version: '3.7.7'
rabbitmq_version: '3.8.1'
rabbitmq_vhosts: []
rabbitmq_vhosts_absent: []

Expand Down
16 changes: 14 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
---
- name: ensure old config file does not exist
file:
path: /etc/rabbitmq/rabbitmq.config
state: absent
notify: restart rabbitmq-server
- name: configure rabbitmq
template:
src: rabbitmq.config.j2
dest: /etc/rabbitmq/rabbitmq.config
src: rabbitmq.conf.j2
dest: /etc/rabbitmq/rabbitmq.conf
notify: restart rabbitmq-server
when: rabbitmq_config is defined
- name: configure rabbitmq environment
template:
src: rabbitmq-env.conf.j2
dest: /etc/rabbitmq/rabbitmq-env.conf
notify: restart rabbitmq-server
when: rabbitmq_env is defined
4 changes: 3 additions & 1 deletion tasks/install-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
repo_gpgcheck: '{{ rabbitmq_yum_repo_gpgcheck }}'
gpgkey: '{{ rabbitmq_yum_repo_gpgkey | default(omit, true) }}'
- name: Install RabbitMQ
package:
yum:
name: rabbitmq-server-{{ rabbitmq_version }}
state: present
update_cache: true
notify: restart rabbitmq-server
4 changes: 2 additions & 2 deletions tasks/rabbitmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- name: include rabbitmq installation tasks
include: install-{{ ansible_os_family }}.yml

- include: plugins.yml

- include: configure.yml

- include: configure-cluster.yml
Expand All @@ -17,7 +19,5 @@

- include: users.yml

- include: plugins.yml

- include: cluster.yml
when: rabbitmq_cluster|bool and rabbitmq_nodename != rabbitmq_cluster_master
Empty file.
20 changes: 0 additions & 20 deletions templates/config-encoder-macros/LICENSE.md

This file was deleted.

92 changes: 0 additions & 92 deletions templates/config-encoder-macros/macros/erlang_encode_macro.j2

This file was deleted.

5 changes: 5 additions & 0 deletions templates/rabbitmq-env.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ ansible_managed | comment }}

{% for item in (rabbitmq_env | dict2items | sort(attribute='key')) %}
{{ item.key }}={{ item.value | to_json }}
{% endfor %}
5 changes: 5 additions & 0 deletions templates/rabbitmq.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ ansible_managed | comment }}

{% for item in (rabbitmq_config | dict2items | sort(attribute='key')) %}
{{ item.key }} = {{ item.value | to_json | replace('"', '') }}
{% endfor %}
9 changes: 0 additions & 9 deletions templates/rabbitmq.config.j2

This file was deleted.

0 comments on commit 917890b

Please sign in to comment.