From f9404b0d85912569cb1916015a895fc37a100122 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Sat, 15 Jul 2017 03:42:53 +0200 Subject: [PATCH] Fix exit_json usage: really call client.auth.logout --- .../modules/packaging/os/rhn_channel.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/ansible/modules/packaging/os/rhn_channel.py b/lib/ansible/modules/packaging/os/rhn_channel.py index 3c9c8588bfe..a64f9942051 100644 --- a/lib/ansible/modules/packaging/os/rhn_channel.py +++ b/lib/ansible/modules/packaging/os/rhn_channel.py @@ -131,22 +131,22 @@ def main(): # get channels for system chans = base_channels(client, session, sys_id) - - 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 == 'absent': - 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) + 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 == 'absent': + 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) + finally: + client.auth.logout(session) if __name__ == '__main__':