diff --git a/imageroot/actions/configure-module/90add-relay-rule b/imageroot/actions/configure-module/90add-relay-rule index 7af4c91..5771c52 100755 --- a/imageroot/actions/configure-module/90add-relay-rule +++ b/imageroot/actions/configure-module/90add-relay-rule @@ -31,7 +31,7 @@ if providers: # first configuration, we add the relay rule response = agent.tasks.run(f"module/{mail_id}", action='add-relay-rule', data={ "rule_type": "always-bcc", - "rule_subject": "archive@"+data["host"], + "rule_subject": "archive@"+ip_address, "host": ip_address, "port": int(os.environ['TCP_PORT_ARCHIVE']), "mandatory_tls": False, @@ -52,7 +52,7 @@ if providers: if providers_old: mail_id_old = providers_old[0]["module_id"] response = agent.tasks.run(f"module/{mail_id_old}", action='remove-relay-rule', data={ - "rule_subject": "archive@"+data["host"]}) + "rule_subject": "archive@"+ip_address}) agent.assert_exp(response['exit_code'] == 0) # we need to remove bcc address for the mail server response = agent.tasks.run(f"module/{mail_id_old}", action='set-always-bcc', data={ @@ -62,7 +62,7 @@ if providers: # add the new relay rule response = agent.tasks.run(f"module/{mail_id}", action='add-relay-rule', data={ "rule_type": "always-bcc", - "rule_subject": "archive@"+data["host"], + "rule_subject": "archive@"+ip_address, "host": ip_address, "port": int(os.environ['TCP_PORT_ARCHIVE']), "mandatory_tls": False, @@ -79,7 +79,7 @@ if providers: # same mail server, we just update the relay rule response = agent.tasks.run(f"module/{mail_id}", action='alter-relay-rule', data={ "rule_type": "always-bcc", - "rule_subject": "archive@"+data["host"], + "rule_subject": "archive@"+ip_address, "host": ip_address, "port": int(os.environ['TCP_PORT_ARCHIVE']), "mandatory_tls": False, diff --git a/imageroot/actions/destroy-module/20destroy b/imageroot/actions/destroy-module/20destroy index 358ed4b..bcca213 100755 --- a/imageroot/actions/destroy-module/20destroy +++ b/imageroot/actions/destroy-module/20destroy @@ -36,10 +36,13 @@ rdb = agent.redis_connect() providers_old = agent.list_service_providers(rdb, 'imap', 'tcp', { 'module_uuid': os.environ.get("MAIL_SERVER") }) +node_id = os.environ["NODE_ID"] +ip_address = rdb.hget(f'node/{node_id}/vpn', 'ip_address') + if providers_old: mail_id_old = providers_old[0]["module_id"] response = agent.tasks.run(f"module/{mail_id_old}", action='remove-relay-rule', data={ - "rule_subject": "archive@"+os.environ.get("TRAEFIK_HOST")}) + "rule_subject": "archive@"+ip_address}) # we need to set bcc address for the mail server response = agent.tasks.run(f"module/{mail_id_old}", action='set-always-bcc', data={ "bcc": ""