Skip to content

Instantly share code, notes, and snippets.

@steveWinter
Created June 18, 2021 00:56
Show Gist options
  • Save steveWinter/212062e9d672420afe791321d88f63c6 to your computer and use it in GitHub Desktop.
Save steveWinter/212062e9d672420afe791321d88f63c6 to your computer and use it in GitHub Desktop.
---
- name: Ensure prerequsites are installed
apt:
name: [
'curl',
'gnupg',
'debian-keyring',
'debian-archive-keyring',
'apt-transport-https',
]
state: latest
update_cache: yes
tags:
- rabbitmq
- name: Add RabbitMQ code signing key
apt_key:
keyserver: hkps://keys.openpgp.org
id: "0x0A9AF2115F4687BD29803A206B73A36E6026DFCA"
state: present
tags:
- rabbitmq
- name: Add Erlang repo key
apt_key:
url: https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
state: present
tags:
- rabbitmq
- name: Add RabbitMQ repo key
apt_key:
url: https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key
state: present
tags:
- rabbitmq
- name: Add erlang repository
apt_repository:
repo: "deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu {{ ansible_distribution_release }} main"
state: present
tags:
- rabbitmq
- name: Add erlang src repository
apt_repository:
repo: "deb-src https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu {{ ansible_distribution_release }} main"
state: present
tags:
- rabbitmq
- name: Add RabbitMQ repository
apt_repository:
repo: "deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu {{ ansible_distribution_release }} main"
state: present
tags:
- rabbitmq
- name: Add RabbitMQ src repository
apt_repository:
repo: "deb-src https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu {{ ansible_distribution_release }} main"
state: present
tags:
- rabbitmq
- name: Copy the erlang preference file
copy:
src: erlang
dest: /etc/apt/preferences.d/erlang
tags:
- rabbitmq
- name: Install erlang packages
apt:
name: [
'erlang-base',
'erlang-asn1',
'erlang-crypto',
'erlang-eldap',
'erlang-ftp',
'erlang-inets',
'erlang-mnesia',
'erlang-os-mon',
'erlang-parsetools',
'erlang-public-key',
'erlang-runtime-tools',
'erlang-snmp',
'erlang-ssl',
'erlang-syntax-tools',
'erlang-tftp',
'erlang-tools',
'erlang-xmerl'
]
state: latest
update_cache: yes
tags:
- rabbitmq
- name: Install RabbitMQ server
apt:
name: rabbitmq-server
state: fixed
update_cache: yes
tags:
- rabbitmq
- name: Create a folder for the SSL credentials
file:
path: /etc/rabbitmq/ssl
state: directory
owner: rabbitmq
group: root
mode: 0700
tags:
- rabbitmq
- name: Install SSL certificate, including the alpha cert
copy:
content: "{{ ssl_cert }}{{ alpha_ssl_cert }}"
dest: "/etc/rabbitmq/ssl/{{ ssl_cert_filename }}"
owner: rabbitmq
mode: 0600
tags:
- rabbitmq
- rabbitssl
- name: Install SSL ceritficate key
copy:
content: "{{ ssl_key }}"
dest: "/etc/rabbitmq/ssl/{{ ssl_key_filename }}"
owner: rabbitmq
mode: 0600
tags:
- rabbitmq
- rabbitssl
notify:
- restart rabbitmq
- name: Create RabbitMQ configuration file
become: yes
template:
src: rabbitmq.config.j2
dest: /etc/rabbitmq/rabbitmq.config
owner: root
group: root
mode: 0644
notify:
- restart rabbitmq
tags:
- rabbitmq
- name: Enable RabbitMQ Management plugin
rabbitmq_plugin:
names: rabbitmq_management
state: enabled
notify:
- restart rabbitmq
tags:
- rabbitmq
- name: Ensure RabbitMQ service is started and enabled on boot
become: yes
service:
name: rabbitmq-server
state: started
enabled: yes
tags:
- rabbitmq
- name: Setup RabbitMQ user
rabbitmq_user:
user: "{{ rabbitmq_user }}"
password: "{{ rabbitmq_password }}"
vhost: "{{ rabbitmq_vhost }}"
configure_priv: .*
read_priv: .*
write_priv: .*
state: present
tags:
- rabbitmq
- name: Setup RabbitMQ administrator
rabbitmq_user:
user: "{{ rabbitmq_administrator }}"
password: "{{ rabbitmq_admin_password }}"
vhost: "{{ rabbitmq_vhost }}"
configure_priv: .*
read_priv: .*
write_priv: .*
tags: administrator,management
state: present
tags:
- rabbitmq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment