← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/packaging.set-rabbitmq-creds into lp:~maas-maintainers/maas/packaging

 

Raphaël Badin has proposed merging lp:~rvb/maas/packaging.set-rabbitmq-creds into lp:~maas-maintainers/maas/packaging.

Commit message:
Add method in debian/maas.postinst to create the RabbitMQ user used by workers and update BROKER_URL in /etc/maas/maas_local_settings.py.

Requested reviews:
  MAAS Maintainers (maas-maintainers)
Related bugs:
  Bug #1050492 in maas (Ubuntu): "MAAS uses the 'guest' account to communicate with RabbitMQ"
  https://bugs.launchpad.net/ubuntu/+source/maas/+bug/1050492

For more details, see:
https://code.launchpad.net/~rvb/maas/packaging.set-rabbitmq-creds/+merge/125248

Add method in debian/maas.postinst to create the RabbitMQ user used by workers and update BROKER_URL in /etc/maas/maas_local_settings.py.
-- 
https://code.launchpad.net/~rvb/maas/packaging.set-rabbitmq-creds/+merge/125248
Your team MAAS Maintainers is requested to review the proposed merge of lp:~rvb/maas/packaging.set-rabbitmq-creds into lp:~maas-maintainers/maas/packaging.
=== modified file 'debian/maas.install'
--- debian/maas.install	2012-09-19 19:00:45 +0000
+++ debian/maas.install	2012-09-20 13:38:21 +0000
@@ -11,6 +11,9 @@
 # Install MAAS local settings
 debian/tmp/etc/maas/maas_local_settings.py
 
+# Install MAAS local celery settings
+debian/tmp/etc/maas/maas_local_celerysettings.py
+
 # Install WSGI
 debian/tmp/usr/share/maas/wsgi.py
 

=== modified file 'debian/maas.links'
--- debian/maas.links	2012-06-28 20:41:16 +0000
+++ debian/maas.links	2012-09-20 13:38:21 +0000
@@ -1,2 +1,3 @@
 etc/maas/maas_local_settings.py usr/share/maas/maas_local_settings.py
+etc/maas/maas_local_celerysettings.py usr/share/maas/maas_local_celerysettings.py
 etc/maas/celeryconfig.py usr/share/maas/celeryconfig.py

=== modified file 'debian/maas.postinst'
--- debian/maas.postinst	2012-09-19 19:00:45 +0000
+++ debian/maas.postinst	2012-09-20 13:38:21 +0000
@@ -77,6 +77,30 @@
 	fi
 }
 
+configure_maas_workers_rabbitmq_user() {
+	local workers_user="maas_workers"
+	local workers_pass=
+	local workers_vhost="/maas_workers"
+	local amqp_host="localhost"
+	local amqp_port="5672"
+	workers_pass="$(pwgen -s 20)"
+	if [ -x /usr/sbin/rabbitmqctl ]; then
+		if ! rabbitmqctl list_users | grep -qs "$workers_user"; then
+			rabbitmqctl add_user "$workers_user" "$workers_pass" || true
+			rabbitmqctl add_vhost "$workers_vhost" || true
+			rabbitmqctl set_permissions -p "$workers_vhost" "$workers_user" ".*" ".*" ".*" || true
+		else
+			rabbitmqctl change_password "$workers_user" "$workers_pass" || true
+		fi
+	fi
+
+	if grep -qs "^BROKER_URL\ \= '[a-zA-Z0-9]\{0,\}'$" /etc/maas/maas_local_celerysettings.py; then
+		local broker_url="amqp://$workers_user:$workers_pass@$amqp_host:$amqp_port/$workers_vhost"
+		sed -i "s/^BROKER_URL\ \= '[a-zA-Z0-9]\{0,\}'$/BROKER_URL = '"$broker_url"'/" \
+                       /etc/maas/maas_local_celerysettings.py
+	fi
+}
+
 configure_maas_database() {
 	local dbc_dbpass="$1"
 	if grep -qs "^\ \{1,\} 'PASSWORD': '[a-zA-Z0-9]\{0,\}',$" /etc/maas/maas_local_settings.py; then
@@ -182,6 +206,13 @@
 	configure_maas_txlongpoll_rabbitmq_user
 
 	#########################################################
+	########## Configure worker rabbitmq config ###########
+	#########################################################
+
+	# Handle celery/rabbitmq publishing
+	configure_maas_workers_rabbitmq_user
+
+	#########################################################
 	######## add maas.conf to tgt conf.d ####################
 	#########################################################
 	configure_maas_tgt