Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
c6d21053
Commit
c6d21053
authored
Jul 07, 2016
by
Arbab Nazar
Committed by
GitHub
Jul 07, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3187 from edx/arbab/rabbitmq-rewrite
use YAML syntax for ansible tasks
parents
7e880a66
f78a3817
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
88 deletions
+123
-88
playbooks/roles/rabbitmq/tasks/main.yml
+123
-88
No files found.
playbooks/roles/rabbitmq/tasks/main.yml
View file @
c6d21053
...
@@ -3,136 +3,169 @@
...
@@ -3,136 +3,169 @@
# 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 python-software-properties if debian
apt
:
pkg={{ ",".join(rabbitmq_debian_pkgs) }} state=present
apt
:
name
:
"
{{
item
}}"
-
name
:
fetch the rabbitmq server deb
state
:
present
get_url
:
>
with_items
:
"
{{
rabbitmq_debian_pkgs
}}"
url={{ rabbitmq_pkg_url }}
dest=/var/tmp/{{ rabbitmq_pkg_url|basename }}
-
name
:
Fetch the rabbitmq server deb
get_url
:
-
name
:
check if rabbit is installed
url
:
"
{{
rabbitmq_pkg_url
}}"
shell
:
>
dest
:
"
/var/tmp/{{
rabbitmq_pkg_url
|
basename
}}"
dpkg -s rabbitmq-server >/dev/null 2>&1 || echo "not installed"
-
name
:
Check if rabbit is installed
shell
:
'
dpkg
-s
rabbitmq-server
>/dev/null
2>&1
||
echo
"not
installed"'
register
:
is_installed
register
:
is_installed
-
name
:
i
nstall rabbit package using gdebi
-
name
:
I
nstall rabbit package using gdebi
shell
:
>
shell
:
"
gdebi
--n
{{
rabbitmq_pkg_url|basename
}}"
gdebi --n {{ rabbitmq_pkg_url|basename }}
args
:
chdir
=
/var/tmp
chdir
:
/var/tmp
when
:
is_installed.stdout is defined and is_installed.stdout == "not installed"
when
:
is_installed.stdout is defined and is_installed.stdout == "not installed"
-
name
:
stop rabbit cluster
-
name
:
Stop rabbit cluster
service
:
name=rabbitmq-server state=stopped
service
:
name
:
rabbitmq-server
state
:
stopped
#
i
n case there are lingering processes, ignore errors
#
I
n case there are lingering processes, ignore errors
# silently
# silently
-
name
:
s
end sigterm to any running rabbitmq processes
-
name
:
S
end sigterm to any running rabbitmq processes
shell
:
pkill -u rabbitmq ||
true
shell
:
"
pkill
-u
rabbitmq
||
true"
# Create the rabbitmq directories
-
name
:
Create rabbitmq edx directories
-
name
:
create rabbitmq edx directories
file
:
file
:
path
={{ item }}
path
:
"
{{
item
}}"
owner
={{ rabbitmq_user }}
owner
:
"
{{
rabbitmq_user
}}"
mode
=0755
mode
:
"
0755"
state
=
directory
state
:
directory
with_items
:
with_items
:
-
"
{{
rabbitmq_app_dir
}}"
-
"
{{
rabbitmq_app_dir
}}"
-
"
{{
rabbitmq_log_dir
}}"
-
"
{{
rabbitmq_log_dir
}}"
-
name
:
a
dd queue monitoring script
-
name
:
A
dd queue monitoring script
template
:
template
:
src
=
"edx/app/rabbitmq/log-rabbitmq-queues.sh.j2"
src
:
"
edx/app/rabbitmq/log-rabbitmq-queues.sh.j2"
dest
=
"{{ rabbitmq_app_dir }}/log-rabbitmq-queues.sh"
dest
:
"
{{
rabbitmq_app_dir
}}/log-rabbitmq-queues.sh"
owner
=
"{{ rabbitmq_user }}"
owner
:
"
{{
rabbitmq_user
}}"
group
=
"{{ rabbitmq_group }}"
group
:
"
{{
rabbitmq_group
}}"
mode
=0755
mode
:
"
0755"
-
name
:
s
et up a cron job to run the script
-
name
:
S
et up a cron job to run the script
cron
:
cron
:
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"
# Defaulting to /var/lib/rabbitmq
# Defaulting to /var/lib/rabbitmq
-
name
:
create cookie directory
-
name
:
Create cookie directory
file
:
>
file
:
path={{ rabbitmq_cookie_dir }}
path
:
"
{{
rabbitmq_cookie_dir
}}"
owner=rabbitmq group=rabbitmq mode=0755 state=directory
state
:
directory
owner
:
rabbitmq
-
name
:
add rabbitmq erlang cookie
group
:
rabbitmq
template
:
>
mode
:
"
0755"
src=erlang.cookie.j2 dest={{ rabbitmq_cookie_location }}
owner=rabbitmq group=rabbitmq mode=0400
-
name
:
Add rabbitmq erlang cookie
template
:
src
:
"
erlang.cookie.j2"
dest
:
"
{{
rabbitmq_cookie_location
}}"
owner
:
rabbitmq
group
:
rabbitmq
mode
:
"
0400"
register
:
erlang_cookie
register
:
erlang_cookie
# Defaulting to /etc/rabbitmq
# Defaulting to /etc/rabbitmq
-
name
:
create rabbitmq config directory
-
name
:
Create rabbitmq config directory
file
:
>
file
:
path={{ rabbitmq_config_dir }}
path
:
"
{{
rabbitmq_config_dir
}}"
owner=root group=root mode=0755 state=directory
state
:
directory
owner
:
root
-
name
:
add rabbitmq environment configuration
group
:
root
template
:
>
mode
:
"
0755"
src=rabbitmq-env.conf.j2 dest={{ rabbitmq_config_dir }}/rabbitmq-env.conf
owner=root group=root mode=0644
-
name
:
Add rabbitmq environment configuration
template
:
-
name
:
add rabbitmq cluster configuration
src
:
"
rabbitmq-env.conf.j2"
template
:
>
dest
:
"
{{
rabbitmq_config_dir
}}/rabbitmq-env.conf"
src=etc/rabbitmq/rabbitmq.config.j2
owner
:
root
dest={{ rabbitmq_config_dir }}/rabbitmq.config
group
:
root
owner=root group=root mode=0644
mode
:
"
0644"
-
name
:
Add rabbitmq cluster configuration
template
:
src
:
"
etc/rabbitmq/rabbitmq.config.j2"
dest
:
"
{{
rabbitmq_config_dir
}}/rabbitmq.config"
owner
:
root
group
:
root
mode
:
"
0644"
register
:
cluster_configuration
register
:
cluster_configuration
-
name
:
i
nstall plugins
-
name
:
I
nstall plugins
rabbitmq_plugin
:
rabbitmq_plugin
:
names={{",".join(rabbitmq_plugins)}} state=enabled
names
:
"
{{
item
}}"
state
:
enabled
with_items
:
"
{{
rabbitmq_plugins
}}"
# 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
# that can conflict with the clustering information.
# that can conflict with the clustering information.
-
name
:
remove mnesia configuration
-
name
:
Remove mnesia configuration
file
:
path={{ rabbitmq_mnesia_folder }} state=absent
file
:
path
:
"
{{
rabbitmq_mnesia_folder
}}"
state
:
absent
when
:
erlang_cookie.changed or cluster_configuration.changed or rabbitmq_refresh
when
:
erlang_cookie.changed or cluster_configuration.changed or rabbitmq_refresh
-
name
:
start rabbit nodes
-
name
:
Start rabbit nodes
service
:
name=rabbitmq-server state=restarted
service
:
name
:
rabbitmq-server
state
:
started
-
name
:
wait for rabbit to start
-
name
:
Wait for rabbit to start
wait_for
:
port={{ rabbitmq_management_port }} delay=2
wait_for
:
port
:
"
{{
rabbitmq_management_port
}}"
delay
:
2
-
name
:
remove guest user
-
name
:
Remove guest user
rabbitmq_user
:
user="guest" state=absent
rabbitmq_user
:
user
:
"
guest"
state
:
absent
tags
:
tags
:
-
users
-
users
-
maintenance
-
maintenance
-
name
:
add vhosts
-
name
:
Add vhosts
rabbitmq_vhost
:
name={{ item }} state=present
rabbitmq_vhost
:
with_items
:
RABBITMQ_VHOSTS
name
:
"
{{
item
}}"
state
:
present
with_items
:
"
{{
RABBITMQ_VHOSTS
}}"
tags
:
tags
:
-
vhosts
-
vhosts
-
maintenance
-
maintenance
-
name
:
add admin users
-
name
:
Add admin users
rabbitmq_user
:
>
rabbitmq_user
:
user='{{item[0].name}}' password='{{item[0].password}}'
user
:
"
{{
item[0].name
}}"
read_priv='.*' write_priv='.*'
password
:
"
{{
item[0].password
}}"
configure_priv='.*' tags="administrator" state=present
read_priv
:
'
.*'
vhost={{ item[1] }}
write_priv
:
'
.*'
configure_priv
:
'
.*'
tags
:
"
administrator"
state
:
present
vhost
:
"
{{
item[1]
}}"
with_nested
:
with_nested
:
-
"
{{rabbitmq_auth_config.admins}}"
-
"
{{rabbitmq_auth_config.admins}}"
-
RABBITMQ_VHOSTS
-
"
{{
RABBITMQ_VHOSTS
}}"
when
:
"
'admins'
in
rabbitmq_auth_config"
when
:
"
'admins'
in
rabbitmq_auth_config"
tags
:
tags
:
-
users
-
users
-
maintenance
-
maintenance
-
name
:
m
ake queues mirrored
-
name
:
M
ake queues mirrored
shell
:
>
shell
:
>
/usr/sbin/rabbitmqctl -p {{ item }} set_policy HA "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
/usr/sbin/rabbitmqctl -p {{ item }} set_policy HA "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
when
:
RABBITMQ_CLUSTERED_HOSTS|length > 1
when
:
RABBITMQ_CLUSTERED_HOSTS|length > 1
with_items
:
RABBITMQ_VHOSTS
with_items
:
"
{{
RABBITMQ_VHOSTS
}}"
tags
:
tags
:
-
ha
-
ha
-
maintenance
-
maintenance
...
@@ -140,12 +173,14 @@
...
@@ -140,12 +173,14 @@
#
#
# Depends upon the management plugin
# Depends upon the management plugin
#
#
-
name
:
install admin tools
-
name
:
Install admin tools
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"
-
name
:
ensure rabbitmqadmin attributes
-
name
:
Ensure rabbitmqadmin attributes
file
:
>
file
:
path=/usr/local/bin/rabbitmqadmin owner=root
path
:
"
/usr/local/bin/rabbitmqadmin"
group=root mode=0655
owner
:
root
group
:
root
mode
:
"
0655"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment