I want to modify the default lcnotification
mail session of HCL Connections 6.5/7 in WAS. Since this is automated with Ansible, I'd like to detect if the desired settings are still there or need to be set - including a full sync of the nodes in case anything was modified. I'm struggeling how to detect this properly, since neither AdminConfig.modify
nor AdminConfig.save
tell me if anything was changed or not.
So I tried to fetch the MailSession
object and check if each of my properties I'd like to set matches:
properties = [
["mailTransportHost", "{{ mail_host }}"],
["mailTransportUser", "{{ mail_user }}"],
["mailTransportPassword", "{{ mail_pw }}"],
["mailFrom", "{{ mail_sender }}"],
["debug", "{{ mail_debug | lower }}"]
]
session = AdminConfig.list('MailSession', 'lcnotification*')
existing = AdminConfig.showall(session)
isModified = 0
for line in existing.splitlines():
noBrackets = line[1:-1]
firstSpace = noBrackets.index(" ")
key = noBrackets[0:firstSpace]
val = noBrackets[firstSpace:].strip()
# print key + " -> " + val
for prop in properties:
propKey = prop[0]
propVal = prop[1]
if propKey == key and val != propVal:
print(propKey + " not maching:\n\tPresent: " + val + "\n\tWanted: " +
propVal)
isModified = 1
if isModified:
AdminConfig.modify(session, properties)
AdminConfig.save()
import shared
shared.synchAllNodes()
In the Ansible call, I use changed_when
to check if not maching
is present in stdout. This doesn't work properly, because WAS return stars instead of the mailTransportPassword
- so I cannot check if it matches:
stdout: |-
WASX7209I: Connected to process "dmgr" on node CnxCell-dmgr using SOAP connector; The type of process is: DeploymentManager
mailTransportPassword not maching:
Present: *****
Wanted: dummypw
Syncronizing nodeCnxNode01
-----------------------------------------------------------------------------------------
Full Resyncronization completed
I see no clean way to fix this. Is there another (maybe even cleaner) way, to see if anything was modified and a full re-synchronisation needs to be done?
I had a look at the synchronisation state of the node and it seems that WAS detects correctly if there are changes which needs to be synced. So I'm writing my properties and check the sync node. If it is out of sync, something was changed -> We need to do a full sync. If
Modified
is printed to stdout, Ansible can mark the task as changed.