library/roles/rabbitmq: Role that installs a rabbitmq instance.

This commit is contained in:
Andrea Dell'Amico 2016-06-30 16:09:26 +02:00
parent 14901f5aab
commit f84c070906
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,26 @@
---
rabbitmq_enabled: True
rabbitmq_repo: 'deb http://www.rabbitmq.com/debian/ testing main'
rabbitmq_repo_key: https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
rabbitmq_pkg_state: present
rabbitmq_server_pkg:
- rabbitmq-server
rabbitmq_enabled_plugins: 'amqp_client,rabbitmq_amqp1_0,rabbitmq_management,rabbitmq_management_agent,rabbitmq_management_visualiser,rabbitmq_mqtt,rabbitmq_stomp,webmachine'
rabbitmq_disabled_plugins: ''
rabbitmq_default_f: /etc/default/rabbitmq-server
rabbitmq_fileno: 4096
rabbitmq_admin_u: r_admin
#
#
# 4369 (epmd), 25672 (Erlang distribution)
# 5672, 5671 (AMQP 0-9-1 without and with TLS)
# 15672 (if management plugin is enabled)
# 61613, 61614 (if STOMP is enabled)
# 1883, 8883 (if MQTT is enabled)
#

View File

@ -0,0 +1,5 @@
---
- name: rabbitmq restart
service: name=rabbitmq-server state=restarted
when: rabbitmq_enabled

34
rabbitmq/tasks/main.yml Normal file
View File

@ -0,0 +1,34 @@
---
- block:
- name: Install the rabbitMQ repository key
apt_key: url='{{ rabbitmq_repo_key }}' state=present
- name: Install the rabbitMQ PPA
apt_repository: repo='{{ rabbitmq_repo }}' state=present
- name: Install the rabbitMQ package
apt: pkg={{ item }} state={{ rabbitmq_pkg_state }} update_cache=yes
with_items: '{{ rabbitmq_server_pkg }}'
- name: Set the rabbitMQ max files
lineinfile: name={{ rabbitmq_default_f }} regexp="^ulimit" line="ulimit -n {{ rabbitmq_fileno }}"
notify: rabbitmq restart
- name: Enable some rabbitMQ plugins
rabbitmq_plugin: names={{ rabbitmq_enabled_plugins }} state=enabled
- name: Disable some rabbitMQ plugins
rabbitmq_plugin: names={{ rabbitmq_disabled_plugins | default('') }} state=disabled
- name: Create an admin user
rabbitmq_user: user={{ rabbitmq_admin_u }} password={{ rabbitmq_admin_pwd | default('changemeASAP') }} tags=administrator vhost=/ configure_priv=.* read_priv=.* write_priv=.* state=present
- name: Start and enable the rabbitMQ service
service: name=rabbitmq-server state=started enabled=yes
when: rabbitmq_enabled
- name: Stop and disable the rabbitMQ service
service: name=rabbitmq-server state=stopped enabled=no
when: not rabbitmq_enabled
tags: rabbitmq