diff --git a/hooks/rabbitmq_server_relations.py b/hooks/rabbitmq_server_relations.py index c5b40763..0b13aeb8 100755 --- a/hooks/rabbitmq_server_relations.py +++ b/hooks/rabbitmq_server_relations.py @@ -123,14 +123,18 @@ def amqp_changed(relation_id=None, remote_unit=None): utils.relation_set(**relation_settings) else: # resync pass on slave - settings = hookenv.relation_get(rid=relation_id, unit=remote_unit) - if 'password' in settings: - write_file(rabbit.LIB_PATH+settings['username']+'.passwd', settings['password'], - rabbit.RABBIT_USER, rabbit.RABBIT_USER, 0660) - else: - # still not set, wait - utils.juju_log('INFO', 'Service password still not set. Relation not ready') - sys.exit(0) + services_password = {} + for r_id in (utils.relation_ids('cluster') or []): + for unit in utils.relation_list(r_id): + # get current passwords + services_password = hookenv.relation_get('services_password', rid=r_id, unit=unit) + if services_password is not None: + services_password = json.loads(base64.b64decode(services_password)) + if len(services_password.keys())>0: + break + # iterate over all services and copy passwords + for key, value in services_password.items(): + write_file(rabbit.LIB_PATH+key, value, rabbit.RABBIT_USER, rabbit.RABBIT_USER, 0660) def cluster_joined():