Commit 124e4a41 by Kevin Falcone Committed by GitHub

Merge pull request #3297 from edx/e0d/upgrade-rabbit-rebase

E0d/upgrade rabbit rebase
parents c72e0ef9 3233e000
- Role: rabbitmq
- Upgraded to 3.6.9
- Switched to a PPA rather than a .deb hosted in S3
- Note that you generally cannot upgrade RabbitMQ live in place https://www.rabbitmq.com/clustering.html
this is particularly true coming from 3.2 to 3.6. We are using the shovel plugin to move tasks across clusters
but their documentation covers different scenarios.
- Role: edxapp - Role: edxapp
- Set preload_app to False in gunicorn config for LMS and Studio. - Set preload_app to False in gunicorn config for LMS and Studio.
- Role: analytics_api - Role: analytics_api
......
FROM edxops/precise-common:latest FROM edxops/xenial-common:latest
MAINTAINER edxops MAINTAINER edxops
USER root
ADD . /edx/app/edx_ansible/edx_ansible ADD . /edx/app/edx_ansible/edx_ansible
COPY docker/build/rabbitmq/ansible_overrides.yml /
COPY docker/build/rabbitmq/run_rabbitmq.sh /
RUN chmod +x /run_rabbitmq.sh
WORKDIR /edx/app/edx_ansible/edx_ansible/docker/plays WORKDIR /edx/app/edx_ansible/edx_ansible/docker/plays
# Role is currently untagged RUN /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook rabbitmq.yml \
RUN /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook rabbitmq.yml -c local \ -i '127.0.0.1,' -c local \
-i '127.0.0.1,' -t 'install,manage:app-users' \
-e@/ansible_overrides.yml
USER rabbitmq WORKDIR /edx/app
# TBD what we want to run rabbit under
EXPOSE 15672 5672 EXPOSE 15672 5672
CMD ["/run_rabbitmq.sh"]
#!/bin/bash
ulimit -n 1024
exec rabbitmq-server $@
\ No newline at end of file
{
"test-pull":
{
"AUTH": [
"lms",
"password"
],
"CONNECTIONS": 2,
"HANDLERS": [
{
"CODEJAIL": {
"name": "demo",
"python_bin": "/edx/app/xqwatcher/venvs/demo/bin/python",
"user": "demo"
},
"HANDLER": "xqueue_watcher.jailedgrader.JailedGrader",
"KWARGS": {
"grader_root": "../data/edx-demo-course/graders/"
}
}
],
"SERVER": "http://xqueue.edx"
}
}
...@@ -108,6 +108,7 @@ common_redhat_pkgs: ...@@ -108,6 +108,7 @@ common_redhat_pkgs:
- unzip - unzip
- acl - acl
common_debian_pkgs: common_debian_pkgs:
- apt-transport-https
- ntp - ntp
- acl - acl
- lynx-cur - lynx-cur
......
#Variables for rabbitmq
--- ---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
# Defaults for role rabbitmq
#
#Setting this to false means we will not check your rabbit version.
#It is not safe to upgrade rabbit in place except for certain minor versions.
CHECK_RABBIT_VERSION: true
rabbitmq_app_dir: "{{ COMMON_APP_DIR }}/rabbitmq" rabbitmq_app_dir: "{{ COMMON_APP_DIR }}/rabbitmq"
rabbitmq_data_dir: "{{ COMMON_DATA_DIR }}/rabbitmq" rabbitmq_data_dir: "{{ COMMON_DATA_DIR }}/rabbitmq"
...@@ -31,20 +45,18 @@ RABBITMQ_CLUSTERED_HOSTS: [] ...@@ -31,20 +45,18 @@ RABBITMQ_CLUSTERED_HOSTS: []
# https://www.rabbitmq.com/production-checklist.html # https://www.rabbitmq.com/production-checklist.html
RABBITMQ_VM_MEMORY_HIGH_WATERMARK: 0.4 RABBITMQ_VM_MEMORY_HIGH_WATERMARK: 0.4
RABBITMQ_VERSION: 3.6.9-1
# Internal role variables below this line # Internal role variables below this line
# option to force deletion of the mnesia dir # option to force deletion of the mnesia dir
rabbitmq_refresh: false rabbitmq_refresh: false
# We mirror the deb package for rabbitmq-server because rabbitmq_repo: "deb https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ {{ ansible_distribution_release }} main"
# nodes need to be running the same version rabbitmq_repo_key: "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey"
rabbitmq_pkg_url: "http://files.edx.org/rabbitmq_packages/rabbitmq-server_3.2.3-1_all.deb"
rabbitmq_pkg: "rabbitmq-server"
rabbitmq_debian_pkgs: rabbitmq_debian_pkgs:
- python-software-properties - "apt-transport-https"
# for installing the deb package with
# dependencies
- gdebi
rabbitmq_config_dir: "/etc/rabbitmq" rabbitmq_config_dir: "/etc/rabbitmq"
rabbitmq_cookie_dir: "/var/lib/rabbitmq" rabbitmq_cookie_dir: "/var/lib/rabbitmq"
......
...@@ -2,37 +2,81 @@ ...@@ -2,37 +2,81 @@
# It is recommended that this role be played with serial set to 1 because # It is recommended that this role be played with serial set to 1 because
# There is a bug with initializing multiple nodes in the HA cluster at once # There is a bug with initializing multiple nodes in the HA cluster at once
# http://rabbitmq.1065348.n5.nabble.com/Rabbitmq-boot-failure-with-quot-tables-not-present-quot-td24494.html # http://rabbitmq.1065348.n5.nabble.com/Rabbitmq-boot-failure-with-quot-tables-not-present-quot-td24494.html
#
- name: Install python-software-properties if debian - name: install packages needed by rabbit
apt: apt:
name: "{{ item }}" name: "{{ item }}"
state: present state: present
install_recommends: yes
force: yes
update_cache: yes
with_items: "{{ rabbitmq_debian_pkgs }}" with_items: "{{ rabbitmq_debian_pkgs }}"
tags:
- install
- install:app-requirements
- name: Fetch the rabbitmq server deb - name: trust rabbit's packagecloud repository
get_url: apt_key:
url: "{{ rabbitmq_pkg_url }}" url: "{{ rabbitmq_repo_key }}"
dest: "/var/tmp/{{ rabbitmq_pkg_url | basename }}" state: present
tags:
- "install"
- "install:app-requirements"
- name: Check if rabbit is installed - name: add rabbit's packagecloud repository
shell: 'dpkg -s rabbitmq-server >/dev/null 2>&1 || echo "not installed"' apt_repository:
register: is_installed repo: "{{ rabbitmq_repo }}"
state: present
update_cache: yes
tags:
- "install"
- "install:app-requirements"
- name: Install rabbit package using gdebi # If we don't set pipefail first, `||` will be looking at the exit code of the last command in the pipe
shell: "gdebi --n {{ rabbitmq_pkg_url|basename }}" - name: Check if rabbit is installed
shell: |
set -o pipefail
dpkg -s rabbitmq-server | grep Version | sed -r 's/.*: (.*)/\1/' || echo 'not installed'
args: args:
chdir: /var/tmp executable: /bin/bash
when: is_installed.stdout is defined and is_installed.stdout == "not installed" register: installed_version
tags:
- "install"
- "install:app-requirements"
- name: Fail if wrong rabbit version is installed
fail: Expected rabbitmq version {{ RABBITMQ_VERSION }}, found {{ installed_version.stdout }}
when: CHECK_RABBIT_VERSION and installed_version.stdout is defined and installed_version.stdout not in [RABBITMQ_VERSION, 'not installed']
tags:
- "install"
- "install:app-requirements"
- name: Install rabbit package
apt:
name: "rabbitmq-server={{ RABBITMQ_VERSION }}"
state: present
force: yes
update_cache: yes
when: installed_version.stdout is defined and installed_version.stdout == "not installed"
tags:
- "install"
- "install:app-requirements"
- name: Stop rabbit cluster - name: Stop rabbit cluster
service: service:
name: rabbitmq-server name: rabbitmq-server
state: stopped state: stopped
tags:
- "install"
- "install:app-configuration"
# In case there are lingering processes, ignore errors # In case there are lingering processes, ignore errors
# silently # silently
- name: Send sigterm to any running rabbitmq processes - name: Send sigterm to any running rabbitmq processes
shell: "pkill -u rabbitmq || true" shell: "pkill -u rabbitmq || true"
tags:
- "install"
- "install:app-configuration"
- name: Create rabbitmq edx directories - name: Create rabbitmq edx directories
file: file:
...@@ -43,6 +87,9 @@ ...@@ -43,6 +87,9 @@
with_items: with_items:
- "{{ rabbitmq_app_dir }}" - "{{ rabbitmq_app_dir }}"
- "{{ rabbitmq_log_dir }}" - "{{ rabbitmq_log_dir }}"
tags:
- "install"
- "install:app-configuration"
- name: Add queue monitoring script - name: Add queue monitoring script
template: template:
...@@ -52,6 +99,8 @@ ...@@ -52,6 +99,8 @@
group: "{{ rabbitmq_group }}" group: "{{ rabbitmq_group }}"
mode: "0755" mode: "0755"
tags: tags:
- "install"
- "install:app-configuration"
- "monitoring" - "monitoring"
- name: Add RabbitMQ memory usage script - name: Add RabbitMQ memory usage script
...@@ -62,6 +111,8 @@ ...@@ -62,6 +111,8 @@
group: "{{ rabbitmq_group }}" group: "{{ rabbitmq_group }}"
mode: "0775" mode: "0775"
tags: tags:
- "install"
- "install:app-configuration"
- "monitoring" - "monitoring"
- name: Set up a cron job to run queue script - name: Set up a cron job to run queue script
...@@ -69,6 +120,8 @@ ...@@ -69,6 +120,8 @@
name: "log-queue-lenghts" name: "log-queue-lenghts"
job: "{{ rabbitmq_app_dir }}/log-rabbitmq-queues.sh >/dev/null 2>&1" job: "{{ rabbitmq_app_dir }}/log-rabbitmq-queues.sh >/dev/null 2>&1"
tags: tags:
- "install"
- "install:app-configuration"
- "monitoring" - "monitoring"
- name: Set up a cron job to run the script - name: Set up a cron job to run the script
...@@ -76,6 +129,8 @@ ...@@ -76,6 +129,8 @@
name: "log-rabbitmq-memory-usage" name: "log-rabbitmq-memory-usage"
job: "{{ rabbitmq_app_dir }}/log-rabbitmq-memory.sh >/dev/null 2>&1" job: "{{ rabbitmq_app_dir }}/log-rabbitmq-memory.sh >/dev/null 2>&1"
tags: tags:
- "install"
- "install:app-configuration"
- "monitoring" - "monitoring"
- name: install logrotate configuration - name: install logrotate configuration
...@@ -84,7 +139,7 @@ ...@@ -84,7 +139,7 @@
dest: /etc/logrotate.d/rabbitmq dest: /etc/logrotate.d/rabbitmq
tags: tags:
- "install" - "install"
- "install:configuration" - "install:app-configuration"
- "logrotate" - "logrotate"
# Defaulting to /var/lib/rabbitmq # Defaulting to /var/lib/rabbitmq
...@@ -95,6 +150,9 @@ ...@@ -95,6 +150,9 @@
owner: rabbitmq owner: rabbitmq
group: rabbitmq group: rabbitmq
mode: "0755" mode: "0755"
tags:
- "install"
- "install:app-configuration"
- name: Add rabbitmq erlang cookie - name: Add rabbitmq erlang cookie
template: template:
...@@ -104,6 +162,9 @@ ...@@ -104,6 +162,9 @@
group: rabbitmq group: rabbitmq
mode: "0400" mode: "0400"
register: erlang_cookie register: erlang_cookie
tags:
- "install"
- "install:app-configuration"
# Defaulting to /etc/rabbitmq # Defaulting to /etc/rabbitmq
- name: Create rabbitmq config directory - name: Create rabbitmq config directory
...@@ -113,6 +174,9 @@ ...@@ -113,6 +174,9 @@
owner: root owner: root
group: root group: root
mode: "0755" mode: "0755"
tags:
- "install"
- "install:app-configuration"
- name: Add rabbitmq environment configuration - name: Add rabbitmq environment configuration
template: template:
...@@ -121,6 +185,9 @@ ...@@ -121,6 +185,9 @@
owner: root owner: root
group: root group: root
mode: "0644" mode: "0644"
tags:
- "install"
- "install:app-configuration"
- name: Add rabbitmq cluster configuration - name: Add rabbitmq cluster configuration
template: template:
...@@ -130,12 +197,18 @@ ...@@ -130,12 +197,18 @@
group: root group: root
mode: "0644" mode: "0644"
register: cluster_configuration register: cluster_configuration
tags:
- "install"
- "install:app-configuration"
- name: Install plugins - name: Install plugins
rabbitmq_plugin: rabbitmq_plugin:
names: "{{ item }}" names: "{{ item }}"
state: enabled state: enabled
with_items: "{{ rabbitmq_plugins }}" with_items: "{{ rabbitmq_plugins }}"
tags:
- "install"
- "install:app-configuration"
# When rabbitmq starts up it creates a folder of metadata at '/var/lib/rabbitmq/mnesia'. # When rabbitmq starts up it creates a folder of metadata at '/var/lib/rabbitmq/mnesia'.
# This folder should be deleted before clustering is setup because it retains data # This folder should be deleted before clustering is setup because it retains data
...@@ -145,16 +218,25 @@ ...@@ -145,16 +218,25 @@
path: "{{ rabbitmq_mnesia_folder }}" path: "{{ rabbitmq_mnesia_folder }}"
state: absent state: absent
when: erlang_cookie.changed or cluster_configuration.changed or rabbitmq_refresh when: erlang_cookie.changed or cluster_configuration.changed or rabbitmq_refresh
tags:
- "install"
- "install:app-configuration"
- name: Start rabbit nodes - name: Start rabbit nodes
service: service:
name: rabbitmq-server name: rabbitmq-server
state: started state: started
tags:
- "install"
- "install:app-configuration"
- name: Wait for rabbit to start - name: Wait for rabbit to start
wait_for: wait_for:
port: "{{ rabbitmq_management_port }}" port: "{{ rabbitmq_management_port }}"
delay: 2 delay: 2
tags:
- "install"
- "install:app-configuration"
- name: Remove guest user - name: Remove guest user
rabbitmq_user: rabbitmq_user:
...@@ -163,6 +245,8 @@ ...@@ -163,6 +245,8 @@
tags: tags:
- users - users
- maintenance - maintenance
- "manage"
- "manage:app-users"
- name: Add vhosts - name: Add vhosts
rabbitmq_vhost: rabbitmq_vhost:
...@@ -172,6 +256,8 @@ ...@@ -172,6 +256,8 @@
tags: tags:
- vhosts - vhosts
- maintenance - maintenance
- "install"
- "install:app-configuration"
- name: Add admin users - name: Add admin users
rabbitmq_user: rabbitmq_user:
...@@ -190,14 +276,25 @@ ...@@ -190,14 +276,25 @@
tags: tags:
- users - users
- maintenance - maintenance
- "manage"
- "manage:app-users"
- name: Make queues mirrored - name: Make queues mirrored
shell: "/usr/sbin/rabbitmqctl -p {{ item }} set_policy HA \"\" '{\"ha-mode\":\"all\",\"ha-sync-mode\":\"automatic\"}'" rabbitmq_policy:
when: RABBITMQ_CLUSTERED_HOSTS|length > 1 name: HA
pattern: .*
vhost: "{{ item }}"
args:
tags:
ha-mode: all
ha-sync-mode: automatic
with_items: "{{ RABBITMQ_VHOSTS }}" with_items: "{{ RABBITMQ_VHOSTS }}"
when: RABBITMQ_CLUSTERED_HOSTS|length > 1
tags: tags:
- ha - ha
- maintenance - maintenance
- "install"
- "install:app-configuration"
# #
# Depends upon the management plugin # Depends upon the management plugin
...@@ -206,6 +303,9 @@ ...@@ -206,6 +303,9 @@
get_url: get_url:
url: "http://localhost:{{ rabbitmq_management_port }}/cli/rabbitmqadmin" url: "http://localhost:{{ rabbitmq_management_port }}/cli/rabbitmqadmin"
dest: "/usr/local/bin/rabbitmqadmin" dest: "/usr/local/bin/rabbitmqadmin"
tags:
- "install"
- "install:app-configuration"
- name: Ensure rabbitmqadmin attributes - name: Ensure rabbitmqadmin attributes
file: file:
...@@ -213,3 +313,6 @@ ...@@ -213,3 +313,6 @@
owner: root owner: root
group: root group: root
mode: "0655" mode: "0655"
tags:
- "install"
- "install:app-configuration"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment