mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
Fix exit_json usage: really call client.auth.logout
This commit is contained in:
parent
b556def4d3
commit
f9404b0d85
1 changed files with 15 additions and 15 deletions
|
@ -131,22 +131,22 @@ def main():
|
||||||
# get channels for system
|
# get channels for system
|
||||||
chans = base_channels(client, session, sys_id)
|
chans = base_channels(client, session, sys_id)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if state == 'present':
|
||||||
|
if channelname in chans:
|
||||||
|
module.exit_json(changed=False, msg="Channel %s already exists" % channelname)
|
||||||
|
else:
|
||||||
|
subscribe_channels(channelname, client, session, systname, sys_id)
|
||||||
|
module.exit_json(changed=True, msg="Channel %s added" % channelname)
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'absent':
|
||||||
if channelname in chans:
|
if not channelname in chans:
|
||||||
module.exit_json(changed=False, msg="Channel %s already exists" % channelname)
|
module.exit_json(changed=False, msg="Not subscribed to channel %s." % channelname)
|
||||||
else:
|
else:
|
||||||
subscribe_channels(channelname, client, session, systname, sys_id)
|
unsubscribe_channels(channelname, client, session, systname, sys_id)
|
||||||
module.exit_json(changed=True, msg="Channel %s added" % channelname)
|
module.exit_json(changed=True, msg="Channel %s removed" % channelname)
|
||||||
|
finally:
|
||||||
if state == 'absent':
|
client.auth.logout(session)
|
||||||
if not channelname in chans:
|
|
||||||
module.exit_json(changed=False, msg="Not subscribed to channel %s." % channelname)
|
|
||||||
else:
|
|
||||||
unsubscribe_channels(channelname, client, session, systname, sys_id)
|
|
||||||
module.exit_json(changed=True, msg="Channel %s removed" % channelname)
|
|
||||||
|
|
||||||
client.auth.logout(session)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue