Skip to content

Commit

Permalink
Refactor configure-module action to use 'always-bcc' rule type for re…
Browse files Browse the repository at this point in the history
…lay and set BCC address using IP address
  • Loading branch information
stephdl committed Apr 25, 2024
1 parent fae8fe3 commit d55e874
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions imageroot/actions/configure-module/90add-relay-rule
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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={
Expand All @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion imageroot/actions/destroy-module/20destroy
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""
Expand Down

0 comments on commit d55e874

Please sign in to comment.