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 os.environ['MODULE_ID']
  • Loading branch information
stephdl committed Apr 26, 2024
1 parent 65057ed commit 6760482
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions imageroot/actions/configure-module/90add-relay-rule
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,37 @@ if providers:
})
agent.assert_exp(response['exit_code'] == 0)
else:
# 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@"+os.environ['MODULE_ID'],
"host": ip_address,
"port": int(os.environ['TCP_PORT_ARCHIVE']),
"mandatory_tls": False,
"username": "",
"password": "",
"enabled": True})
agent.assert_exp(response['exit_code'] == 0)
# we need to set bcc address for the mail server
response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={
"bcc": "archive@"+os.environ['MODULE_ID']
})
agent.assert_exp(response['exit_code'] == 0)
try:
response = agent.tasks.run(f"module/{mail_id}", action='alter-relay-rule', data={
"rule_type": "always-bcc",
"rule_subject": "archive@"+os.environ['MODULE_ID'],
"host": ip_address,
"port": int(os.environ['TCP_PORT_ARCHIVE']),
"mandatory_tls": False,
"username": "",
"password": "",
"enabled": True})
agent.assert_exp(response['exit_code'] == 0)
# we need to set bcc address for the mail server
response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={
"bcc": "archive@"+os.environ['MODULE_ID']
})
agent.assert_exp(response['exit_code'] == 0)
except:
response = agent.tasks.run(f"module/{mail_id}", action='add-relay-rule', data={
"rule_type": "always-bcc",
"rule_subject": "archive@"+os.environ['MODULE_ID'],
"host": ip_address,
"port": int(os.environ['TCP_PORT_ARCHIVE']),
"mandatory_tls": False,
"username": "",
"password": "",
"enabled": True})
agent.assert_exp(response['exit_code'] == 0)
# we need to set bcc address for the mail server
response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={
"bcc": "archive@"+os.environ['MODULE_ID']
})
agent.assert_exp(response['exit_code'] == 0)

agent.set_env("MAIL_SERVER", data["mail_server"])

0 comments on commit 6760482

Please sign in to comment.