diff --git a/lib/ansible/modules/packaging/os/rhn_channel.py b/lib/ansible/modules/packaging/os/rhn_channel.py index 7ee5301fa8..e39755a050 100644 --- a/lib/ansible/modules/packaging/os/rhn_channel.py +++ b/lib/ansible/modules/packaging/os/rhn_channel.py @@ -1,26 +1,24 @@ #!/usr/bin/python -# (c) Vincent Van de Kussen -# +# Copyright: (c) Vincent Van de Kussen # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type - ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'core'} - DOCUMENTATION = ''' --- module: rhn_channel short_description: Adds or removes Red Hat software channels description: - - Adds or removes Red Hat software channels + - Adds or removes Red Hat software channels. version_added: "1.1" -author: "Vincent Van der Kussen (@vincentvdk)" +author: +- Vincent Van der Kussen (@vincentvdk) notes: - This module fetches the system id from RHN. - This module doesn't support I(check_mode). @@ -43,11 +41,11 @@ options: required: true user: description: - - RHN/Satellite login + - RHN/Satellite login. required: true password: description: - - RHN/Satellite password + - RHN/Satellite password. required: true ''' @@ -58,14 +56,13 @@ EXAMPLES = ''' url: https://rhn.redhat.com/rpc/api user: rhnuser password: guessme + delegate_to: localhost ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six.moves import xmlrpc_client -# ------------------------------------------------------- # - def get_systemid(client, session, sysname): systems = client.system.listUserSystems(session) for system in systems: @@ -74,21 +71,18 @@ def get_systemid(client, session, sysname): idd = int(idres) return idd -# ------------------------------------------------------- # def subscribe_channels(channelname, client, session, sysname, sys_id): channels = base_channels(client, session, sys_id) channels.append(channelname) return client.system.setChildChannels(session, sys_id, channels) -# ------------------------------------------------------- # def unsubscribe_channels(channelname, client, session, sysname, sys_id): channels = base_channels(client, session, sys_id) channels.remove(channelname) return client.system.setChildChannels(session, sys_id, channels) -# ------------------------------------------------------- # def base_channels(client, session, sys_id): basechan = client.channel.software.listSystemChannels(session, sys_id) @@ -98,19 +92,17 @@ def base_channels(client, session, sys_id): chans = [item['channel_label'] for item in basechan] return chans -# ------------------------------------------------------- # - def main(): module = AnsibleModule( - argument_spec = dict( - state = dict(default='present', choices=['present', 'absent']), - name = dict(required=True), - sysname = dict(required=True), - url = dict(required=True), - user = dict(required=True), - password = dict(required=True, aliases=['pwd'], no_log=True), + argument_spec=dict( + state=dict(type='str', default='present', choices=['present', 'absent']), + name=dict(type='str', required=True), + sysname=dict(type='str', required=True), + url=dict(type='str', required=True), + user=dict(type='str', required=True), + password=dict(type='str', required=True, aliases=['pwd'], no_log=True), ) ) @@ -140,7 +132,7 @@ def main(): module.exit_json(changed=True, msg="Channel %s added" % channelname) if state == 'absent': - if not channelname in chans: + if channelname not in chans: module.exit_json(changed=False, msg="Not subscribed to channel %s." % channelname) else: unsubscribe_channels(channelname, client, session, systname, sys_id) diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 09fba6361d..57fd150639 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -361,7 +361,6 @@ lib/ansible/modules/packaging/os/pkgng.py lib/ansible/modules/packaging/os/pkgutil.py lib/ansible/modules/packaging/os/portage.py lib/ansible/modules/packaging/os/portinstall.py -lib/ansible/modules/packaging/os/rhn_channel.py lib/ansible/modules/packaging/os/rpm_key.py lib/ansible/modules/packaging/os/sorcery.py lib/ansible/modules/packaging/os/svr4pkg.py