add rabbitmq role
This commit is contained in:
parent
a948debbf8
commit
3a14992832
28
roles/rabbitmq/defaults/main.yaml
Normal file
28
roles/rabbitmq/defaults/main.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
rabbitmq_package_name: rabbitmq-server
|
||||||
|
rabbitmq_package_state: present
|
||||||
|
|
||||||
|
rabbitmq_service_name: rabbitmq-server
|
||||||
|
rabbitmq_service_state: started
|
||||||
|
rabbitmq_service_enabled: true
|
||||||
|
|
||||||
|
rabbitmq_plugins_enabled:
|
||||||
|
- rabbitmq_management
|
||||||
|
- rabbitmq_prometheus
|
||||||
|
|
||||||
|
rabbitmq_etc_path: /etc/rabbitmq
|
||||||
|
rabbitmq_var_path: /var/lib/rabbitmq
|
||||||
|
rabbitmq_config_path: "{{ rabbitmq_etc_path }}/rabbitmq.conf"
|
||||||
|
|
||||||
|
rabbitmq_erlang_cookie_path: "{{ rabbitmq_var_path }}/.erlang.cookie"
|
||||||
|
rabbitmq_erlang_cookie_onwer: rabbitmq
|
||||||
|
rabbitmq_erlang_cookie_group: rabbitmq
|
||||||
|
rabbitmq_erlang_cookie_mode: "0400"
|
||||||
|
rabbitmq_erlang_cookie: ""
|
||||||
|
|
||||||
|
rabbitmq_loopback_users:
|
||||||
|
|
||||||
|
# rabbitmq_cluster_formation_peer_discovery_backend: classic_config
|
||||||
|
# rabbitmq_cluster_formation_classic_config_nodes: []
|
||||||
|
|
||||||
|
rabbitmq_vm_memory_high_watermark_relative:
|
12
roles/rabbitmq/handlers/main.yaml
Normal file
12
roles/rabbitmq/handlers/main.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
- name: reload rabbitmq
|
||||||
|
service:
|
||||||
|
name: "{{ rabbitmq_service_name }}"
|
||||||
|
state: reloaded
|
||||||
|
when: rabbitmq_service_enabled
|
||||||
|
|
||||||
|
- name: restart rabbitmq
|
||||||
|
service:
|
||||||
|
name: "{{ rabbitmq_service_name }}"
|
||||||
|
state: restarted
|
||||||
|
when: rabbitmq_service_enabled
|
26
roles/rabbitmq/tasks/RedHat.yaml
Normal file
26
roles/rabbitmq/tasks/RedHat.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
- name: add erlang yum repo
|
||||||
|
yum_repository:
|
||||||
|
name: rabbitmq_erlang
|
||||||
|
baseurl: https://packagecloud.io/rabbitmq/erlang/el/$releasever/$basearch
|
||||||
|
repo_gpgcheck: yes
|
||||||
|
gpgcheck: no
|
||||||
|
enabled: yes
|
||||||
|
gpgkey: https://packagecloud.io/rabbitmq/erlang/gpgkey
|
||||||
|
sslverify: yes
|
||||||
|
sslcacert: /etc/pki/tls/certs/ca-bundle.crt
|
||||||
|
metadata_expire: "300"
|
||||||
|
description: RabbitMQ Erlang Yum repo
|
||||||
|
|
||||||
|
- name: add rabbitmq yum repo
|
||||||
|
yum_repository:
|
||||||
|
name: rabbitmq_rabbitmq-server
|
||||||
|
baseurl: https://packagecloud.io/rabbitmq/rabbitmq-server/el/$releasever/$basearch
|
||||||
|
repo_gpgcheck: true
|
||||||
|
gpgcheck: false
|
||||||
|
enabled: true
|
||||||
|
gpgkey: https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
|
||||||
|
sslverify: true
|
||||||
|
sslcacert: /etc/pki/tls/certs/ca-bundle.crt
|
||||||
|
metadata_expire: "300"
|
||||||
|
description: RabbitMQ Yum repo
|
28
roles/rabbitmq/tasks/configure.yaml
Normal file
28
roles/rabbitmq/tasks/configure.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
- name: configure erlang cookie
|
||||||
|
copy:
|
||||||
|
dest: "{{ rabbitmq_erlang_cookie_path }}"
|
||||||
|
owner: "{{ rabbitmq_erlang_cookie_onwer }}"
|
||||||
|
group: "{{ rabbitmq_erlang_cookie_group }}"
|
||||||
|
mode: "{{ rabbitmq_erlang_cookie_mode }}"
|
||||||
|
content: "{{ rabbitmq_erlang_cookie }}"
|
||||||
|
when: rabbitmq_erlang_cookie | length
|
||||||
|
notify: restart rabbitmq
|
||||||
|
|
||||||
|
- name: configure
|
||||||
|
template:
|
||||||
|
src: rabbitmq.conf.j2
|
||||||
|
dest: "{{ rabbitmq_config_path }}"
|
||||||
|
notify: restart rabbitmq
|
||||||
|
|
||||||
|
- name: register enabled plugins
|
||||||
|
command: rabbitmq-plugins list --enabled --minimal
|
||||||
|
changed_when: false
|
||||||
|
register: rabbitmq_enabled_plugins
|
||||||
|
|
||||||
|
- name: enable plugins
|
||||||
|
command: "rabbitmq-plugins enable {{ item }}"
|
||||||
|
loop: "{{ rabbitmq_plugins_enabled }}"
|
||||||
|
when:
|
||||||
|
- item not in rabbitmq_enabled_plugins.stdout_lines[1:]
|
||||||
|
|
38
roles/rabbitmq/tasks/main.yaml
Normal file
38
roles/rabbitmq/tasks/main.yaml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- name: gather os specific variables
|
||||||
|
include_vars: "{{ lookup('first_found', possible_files) }}"
|
||||||
|
vars:
|
||||||
|
possible_files:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
|
||||||
|
- "{{ ansible_distribution }}.yaml"
|
||||||
|
- "{{ ansible_os_family }}.yaml"
|
||||||
|
- "default.yaml"
|
||||||
|
paths:
|
||||||
|
- vars
|
||||||
|
|
||||||
|
- name: include os specific tasks
|
||||||
|
include_tasks: "{{ lookup('first_found', possible_files) }}"
|
||||||
|
vars:
|
||||||
|
possible_files:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
|
||||||
|
- "{{ ansible_distribution }}.yaml"
|
||||||
|
- "{{ ansible_os_family }}.yaml"
|
||||||
|
- "default.yaml"
|
||||||
|
paths:
|
||||||
|
- tasks
|
||||||
|
|
||||||
|
- name: install
|
||||||
|
package:
|
||||||
|
name: "{{ rabbitmq_package_name }}"
|
||||||
|
state: "{{ rabbitmq_package_state }}"
|
||||||
|
|
||||||
|
- name: configure
|
||||||
|
include: configure.yaml
|
||||||
|
|
||||||
|
- name: manage service
|
||||||
|
service:
|
||||||
|
name: "{{ rabbitmq_service_name }}"
|
||||||
|
state: "{{ rabbitmq_service_state }}"
|
||||||
|
enabled: "{{ rabbitmq_service_enabled }}"
|
16
roles/rabbitmq/templates/rabbitmq.conf.j2
Normal file
16
roles/rabbitmq/templates/rabbitmq.conf.j2
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% if rabbitmq_loopback_users %}
|
||||||
|
loopback_users = {{ rabbitmq_loopback_users }}
|
||||||
|
{% endif %}
|
||||||
|
{% if rabbitmq_vm_memory_high_watermark_relative %}
|
||||||
|
vm_memory_high_watermark.relative = {{ rabbitmq_vm_memory_high_watermark_relative }}
|
||||||
|
{% endif %}
|
||||||
|
{% if rabbitmq_cluster_formation_peer_discovery_backend %}
|
||||||
|
cluster_formation.peer_discovery_backend = {{ rabbitmq_cluster_formation_peer_discovery_backend }}
|
||||||
|
{% endif %}
|
||||||
|
{% if rabbitmq_cluster_formation_classic_config_nodes %}
|
||||||
|
{% for node in rabbitmq_cluster_formation_classic_config_nodes %}
|
||||||
|
cluster_formation.classic_config.nodes.{{ loop.index }} = {{ node }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
0
roles/rabbitmq/vars/default.yaml
Normal file
0
roles/rabbitmq/vars/default.yaml
Normal file
Loading…
Reference in New Issue
Block a user