forked from mtusi2026/mtusi2026lab7
lab7
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
env = dict(x.split('=',1) for x in pathlib.Path('.env').read_text().splitlines() if '=' in x and not x.startswith('#'))
|
||||
|
||||
def run(*args):
|
||||
subprocess.run(['docker','compose','exec','-T','broker','rabbitmqctl',*args],check=True)
|
||||
|
||||
users = subprocess.check_output(
|
||||
['docker','compose','exec','-T','broker','rabbitmqctl','list_users'],
|
||||
text=True
|
||||
)
|
||||
|
||||
if 'messenger_worker' not in users:
|
||||
run('add_user','messenger_worker',env['BROKER_WORKER_PASSWORD'])
|
||||
else:
|
||||
run('change_password','messenger_worker',env['BROKER_WORKER_PASSWORD'])
|
||||
|
||||
run('set_permissions','-p','/','messenger_worker',
|
||||
r'^attachment\.jobs$',
|
||||
r'^(attachment\.jobs|amq\.default)$',
|
||||
r'^attachment\.jobs$')
|
||||
|
||||
print('PASS: RabbitMQ roles configured')
|
||||
Reference in New Issue
Block a user