Ansible 如果需要修改或修改任何内容,请使用更改检测更改WebSphere for HCL连接中的MailSession
我想修改WAS中HCL连接6.5/7的默认Ansible 如果需要修改或修改任何内容,请使用更改检测更改WebSphere for HCL连接中的MailSession,ansible,websphere,jython,ibm-connections,hcl-connections,Ansible,Websphere,Jython,Ibm Connections,Hcl Connections,我想修改WAS中HCL连接6.5/7的默认lcnotification邮件会话。由于Ansible会自动执行此操作,因此我希望检测所需的设置是否仍然存在或需要设置—包括在修改任何内容时对节点进行完全同步。我正在琢磨如何正确地检测这一点,因为无论是AdminConfig.modify还是AdminConfig.save都不能告诉我是否有任何更改 因此,我尝试获取MailSession对象,并检查我要设置的每个属性是否匹配: properties = [ ["mailTranspo
lcnotification
邮件会话。由于Ansible会自动执行此操作,因此我希望检测所需的设置是否仍然存在或需要设置—包括在修改任何内容时对节点进行完全同步。我正在琢磨如何正确地检测这一点,因为无论是AdminConfig.modify
还是AdminConfig.save
都不能告诉我是否有任何更改
因此,我尝试获取MailSession
对象,并检查我要设置的每个属性是否匹配:
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()
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
在Ansible调用中,我使用changed\u when
检查stdout中是否存在not maching
。这无法正常工作,因为返回的是星号而不是mailTransportPassword
-因此我无法检查它是否匹配:
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()
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
我看不出有什么好办法来解决这个问题。是否有其他(甚至更干净的)方法来查看是否有任何内容被修改,是否需要进行完全的重新同步?我查看了节点的同步状态,似乎was正确地检测到是否有需要同步的更改。所以我正在写我的属性并检查同步节点。如果它不同步,则某些内容已更改->我们需要进行完全同步。如果
Modified
打印到标准输出,Ansible可以将任务标记为已更改
AdminConfig.modify(session, properties)
AdminConfig.save()
node = AdminControl.completeObjectName('type=NodeSync,*')
isSynced = AdminControl.invoke(node, 'isNodeSynchronized')
print node + "\n\tIs synced: " + isSynced
# Nasty, but the old included Python of WAS still can't handle boolean values
if isSynced == "false":
# For the change detection
print "Modified, starting full sync"
import shared
shared.synchAllNodes()
我被你的问题弄糊涂了;您说过您希望
changed\u当出现输出字符串不匹配时:
触发,然后您说了一些关于密码混淆星号的内容。你的问题到底是什么?w.r.t.星号,根据我的经验,任何轻量级编码(base64、rot13、.reverse()
,…)都会绕过简单的密码混淆方案,如果这就是你遇到的问题with@mdaniel我想检测是否需要进行任何更改以将此转发给Ansible,并在需要时进行完全同步。为了存档此文件,我尝试将我要设置的所有属性与WAS上已设置的属性进行比较-如果任何属性不匹配,我就知道要应用更改。这种方法适用于除密码外的所有情况,因为密码是屏蔽的。但与此同时,我找到了另一个解决方案,这对我来说似乎更清楚(见我的答案)