Skip to content

Commit

Permalink
added rabbitmq role
Browse files Browse the repository at this point in the history
  • Loading branch information
jyotipm29 committed Nov 4, 2024
1 parent b5a00cc commit b8bc58c
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
[submodule "galaxy/ansible/roles/galaxy-proftpd"]
path = galaxy/ansible/roles/galaxy-proftpd
url = https://github.com/galaxyproject/ansible-proftpd

[submodule "galaxy/ansible/roles/galaxy-rabbitmq"]
path = galaxy/ansible/roles/galaxy-rabbitmq
url = https://github.com/geerlingguy/ansible-role-rabbitmq
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ The Galaxy Report and Flower Webapps are `htpasswd` protected with username and
RabbitMQ is configured with:
- Admin username: `admin`
- Admin password: `admin`
- Galaxy vhost: `galaxy_internal`
- Galaxy vhost: `galaxy`
- Galaxy username: `galaxy`
- Galaxy password: `galaxy`
- Flower username: `flower`
Expand Down
6 changes: 4 additions & 2 deletions galaxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ RUN groupadd -r postgres -g $GALAXY_POSTGRES_GID \
&& apt-get install nano --no-install-recommends -y \
&& apt-get install git --no-install-recommends -y \
&& apt-get install gridengine-common gridengine-drmaa1.0 --no-install-recommends -y \
&& apt-get install rabbitmq-server --no-install-recommends -y \
&& apt-get install --no-install-recommends -y libswitch-perl supervisor \
&& apt-get purge -y software-properties-common gpg-agent systemd \
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf ~/.cache/ \
Expand Down Expand Up @@ -220,6 +219,9 @@ RUN ansible-playbook /ansible/proftpd_provision.yml \
# Install cvmfs
RUN ansible-playbook /ansible/cvmfs_provision.yml

# Install rabbitmq
RUN ansible-playbook /ansible/rabbitmq_provision.yml

RUN mkdir -p /shed_tools \
&& chown $GALAXY_USER:$GALAXY_USER /shed_tools \
&& ln -s /tool_deps/ $EXPORT_DIR/tool_deps \
Expand Down Expand Up @@ -250,7 +252,7 @@ RUN mkdir -p /shed_tools \
--extra-vars tus_upload_store_path=$GALAXY_CONFIG_TUS_UPLOAD_STORE \
--extra-vars gx_it_proxy_sessions_path=$GALAXY_CONFIG_INTERACTIVETOOLS_MAP \
--extra-vars use_pbkdf2=True \
--tags=galaxyextras --skip-tags=tusd,flower,redis,slurm,condor,proftpd,cvmfs -c local \
--tags=galaxyextras --skip-tags=tusd,flower,redis,slurm,condor,proftpd,cvmfs,rabbitmq -c local \
&& . $GALAXY_VIRTUAL_ENV/bin/activate \
&& pip install WeasyPrint \
&& deactivate \
Expand Down
4 changes: 3 additions & 1 deletion galaxy/ansible/flower_provision.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
- hosts: localhost
connection: local
remote_user: root
vars_files:
- vars/main.yml
vars:
flower_python_package_version: 1.2.0
flower_custom_logging: false
flower_install: true
flower_conf_dir: /etc/flower
flower_bind_address: 0.0.0.0
flower_port: 5555
flower_broker_api: http://flower:flower@localhost:5671/api/ # URL of broker (RabbitMQ Management) API
flower_broker_api: "http://{{ rabbitmq_flower_username }}:{{ rabbitmq_flower_password }}@localhost:{{ rabbitmq_management_port }}/api/" # URL of broker (RabbitMQ Management) API
flower_persistent: true
flower_proxy_prefix: /flower
flower_ui_users: []
Expand Down
28 changes: 28 additions & 0 deletions galaxy/ansible/rabbitmq_provision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- hosts: localhost
connection: local
remote_user: root
vars_files:
- vars/main.yml
vars:
rabbitmq_version: 4.0.3
rabbitmq_apt_repository: "deb [signed-by=/etc/apt/trusted.gpg.d/rabbitmq-9F4587F226208342.gpg] https://ppa1.rabbitmq.com/rabbitmq/rabbitmq-server/deb/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main"
rabbitmq_apt_gpg_url: https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key
erlang_apt_repository: "deb [signed-by=/etc/apt/trusted.gpg.d/erlang-E495BB49CC4BBE5B.gpg] https://ppa1.rabbitmq.com/rabbitmq/rabbitmq-erlang/deb/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main"
erlang_apt_gpg_url: https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key
roles:
- role: galaxy-rabbitmq
tasks:
- name: Enable rabbitmq management plugin
rabbitmq_plugin:
name: rabbitmq_management
broker_state: offline
state: enabled

- name: Copy startup script for rabbitmq
template: src=rabbitmq.sh.j2 dest=/usr/local/bin/rabbitmq.sh

- name: Install rabbitmq users configuration script
template: src=configure_rabbitmq_users.yml.j2 dest=/usr/local/bin/configure_rabbitmq_users.yml

- name: Purge systemd and perform cleanup
shell: apt purge -y systemd && apt-get autoremove -y && apt-get clean
1 change: 1 addition & 0 deletions galaxy/ansible/roles/galaxy-rabbitmq
Submodule galaxy-rabbitmq added at be4e26
46 changes: 46 additions & 0 deletions galaxy/ansible/templates/configure_rabbitmq_users.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- hosts: localhost
connection: local
become: yes
tasks:
- name: Delete 'guest' user
rabbitmq_user:
name: guest
state: absent

- name: Add 'admin' user
rabbitmq_user:
user: {{ rabbitmq_admin_username }}
password: {{ rabbitmq_admin_password }}
vhost: /
configure_priv: .*
read_priv: .*
write_priv: .*
tags: administrator
state: present

- name: Add vhost for galaxy
rabbitmq_vhost:
vhost: {{ rabbitmq_galaxy_vhost }}
state: present

- name: Add 'galaxy' user
rabbitmq_user:
user: {{ rabbitmq_galaxy_username }}
password: {{ rabbitmq_galaxy_password }}
vhost: {{ rabbitmq_galaxy_vhost }}
configure_priv: .*
read_priv: .*
write_priv: .*
state: present

- name: Add 'flower' user
rabbitmq_user:
user: {{ rabbitmq_flower_username }}
password: {{ rabbitmq_flower_password }}
vhost: {{ rabbitmq_galaxy_vhost }}
configure_priv: .*
read_priv: .*
write_priv: .*
tags: administrator
state: present
21 changes: 21 additions & 0 deletions galaxy/ansible/templates/rabbitmq.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# call "rabbitmqctl stop" when exiting
# taken from https://gist.github.com/caioariede/342a583f75467509ad42
mkdir -p /var/run/rabbitmq && chown rabbitmq:rabbitmq /var/run/rabbitmq && chmod 755 /var/run/rabbitmq
RABBITMQ_ENV=/usr/lib/rabbitmq/bin/rabbitmq-env
RABBITMQ_SCRIPTS_DIR=$(dirname "$RABBITMQ_ENV")
. /usr/lib/rabbitmq/bin/rabbitmq-env
trap "{ echo Stopping rabbitmq; rabbitmqctl stop; exit 0; }" TERM

echo Starting rabbitmq
rabbitmq-server &

# from docs: When Bash receives a signal for which a
# trap has been set while waiting for a command to
# complete, the trap will not be executed until the
# command completes.
#
# This is why we use & and wait here. Idea taken from:
# http://veithen.github.io/2014/11/16/sigterm-propagation.html
PID=$!
wait $PID
10 changes: 10 additions & 0 deletions galaxy/ansible/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ cvmfs_keys:
mAG1ceyBFowj/r3iJTa+Jcif2uAmZxg+cHkZG5KzATykF82UH1ojUzREMMDcPJi2
dQIDAQAB
-----END PUBLIC KEY-----
rabbitmq_port: "5672"
rabbitmq_management_port: "15672"
rabbitmq_admin_username: admin
rabbitmq_admin_password: admin
rabbitmq_galaxy_vhost: galaxy
rabbitmq_galaxy_username: galaxy
rabbitmq_galaxy_password: galaxy
rabbitmq_flower_username: flower
rabbitmq_flower_password: flower
2 changes: 1 addition & 1 deletion galaxy/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function start_gravity {
if [[ $NONUSE != *"rabbitmq"* ]]
then
# Set AMQP internal connection for Galaxy
export GALAXY_CONFIG_AMQP_INTERNAL_CONNECTION="pyamqp://galaxy:galaxy@localhost:5672/galaxy_internal"
export GALAXY_CONFIG_AMQP_INTERNAL_CONNECTION="pyamqp://galaxy:galaxy@localhost:5672/galaxy"
fi

# Start galaxy services using gravity
Expand Down

0 comments on commit b8bc58c

Please sign in to comment.