From 3e778d3f8f8c15181afc647a75f9825726bf687e Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 13 Feb 2019 18:39:26 -0800 Subject: [PATCH] Fix pycodestyle E117 issues. --- contrib/inventory/azure_rm.py | 16 +++---- contrib/vault/azure_vault.py | 14 +++--- lib/ansible/executor/task_queue_manager.py | 6 +-- lib/ansible/module_utils/azure_rm_common.py | 24 +++++----- .../common/dict_transformations.py | 2 +- .../module_utils/facts/hardware/linux.py | 12 ++--- lib/ansible/module_utils/network/aci/mso.py | 2 +- .../amazon/aws_application_scaling_policy.py | 2 +- .../cloud/amazon/cloudfront_distribution.py | 2 +- .../cloudfront_origin_access_identity.py | 2 +- .../cloud/amazon/cloudwatchlogs_log_group.py | 16 +++---- .../modules/cloud/azure/azure_rm_webapp.py | 2 +- .../cloud/azure/azure_rm_webappslot.py | 2 +- .../cloud/vmware/vmware_guest_boot_manager.py | 2 +- .../modules/cloud/vultr/vultr_os_facts.py | 2 +- .../modules/database/mongodb/mongodb_shard.py | 2 +- .../database/postgresql/postgresql_idx.py | 6 +-- lib/ansible/modules/net_tools/ip_netns.py | 2 +- .../modules/network/dellos6/dellos6_config.py | 14 +++--- lib/ansible/modules/network/ios/ios_ntp.py | 2 +- lib/ansible/modules/network/ios/ios_vrf.py | 48 +++++++++---------- .../modules/network/meraki/meraki_admin.py | 2 +- .../network/meraki/meraki_mr_l3_firewall.py | 10 ++-- .../network/meraki/meraki_mx_l3_firewall.py | 8 ++-- .../modules/network/meraki/meraki_snmp.py | 2 +- .../network/netvisor/pn_snmp_community.py | 2 +- .../modules/network/nxos/nxos_evpn_vni.py | 14 +++--- .../network/nxos/nxos_igmp_interface.py | 18 +++---- .../modules/network/onyx/onyx_config.py | 2 +- .../modules/network/ovs/openvswitch_db.py | 2 +- lib/ansible/modules/notification/mail.py | 2 +- lib/ansible/modules/packaging/os/dnf.py | 2 +- .../modules/storage/emc/emc_vnx_sg_member.py | 8 ++-- .../netapp/na_elementsw_snapshot_schedule.py | 18 +++---- .../storage/netapp/na_elementsw_volume.py | 4 +- .../netapp/na_elementsw_volume_clone.py | 4 +- .../storage/netapp/na_ontap_command.py | 12 ++--- lib/ansible/parsing/dataloader.py | 4 +- lib/ansible/plugins/doc_fragments/gcp.py | 4 +- lib/ansible/plugins/inventory/foreman.py | 2 +- 40 files changed, 150 insertions(+), 150 deletions(-) diff --git a/contrib/inventory/azure_rm.py b/contrib/inventory/azure_rm.py index ba758b7e39..a83558cd49 100755 --- a/contrib/inventory/azure_rm.py +++ b/contrib/inventory/azure_rm.py @@ -354,13 +354,13 @@ class AzureRM(object): self.credentials.get('client_id') is not None and \ self.credentials.get('tenant') is not None: - self.azure_credentials = self.acquire_token_with_username_password( - self._adfs_authority_url, - self._resource, - self.credentials['ad_user'], - self.credentials['password'], - self.credentials['client_id'], - self.credentials['tenant']) + self.azure_credentials = self.acquire_token_with_username_password( + self._adfs_authority_url, + self._resource, + self.credentials['ad_user'], + self.credentials['password'], + self.credentials['client_id'], + self.credentials['tenant']) elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None: tenant = self.credentials.get('tenant') @@ -813,7 +813,7 @@ class AzureInventory(object): sys.exit("Error: fetching instanceview for host {0} - {1}".format(name, str(exc))) return next((s.code.replace('PowerState/', '') - for s in vm.instance_view.statuses if s.code.startswith('PowerState')), None) + for s in vm.instance_view.statuses if s.code.startswith('PowerState')), None) def _add_host(self, vars): diff --git a/contrib/vault/azure_vault.py b/contrib/vault/azure_vault.py index 0be05c5a98..8c118cc0fc 100755 --- a/contrib/vault/azure_vault.py +++ b/contrib/vault/azure_vault.py @@ -262,13 +262,13 @@ class AzureRM(object): self.credentials.get('client_id') is not None and \ self.credentials.get('tenant') is not None: - self.azure_credentials = self.acquire_token_with_username_password( - self._adfs_authority_url, - self._resource, - self.credentials['ad_user'], - self.credentials['password'], - self.credentials['client_id'], - self.credentials['tenant']) + self.azure_credentials = self.acquire_token_with_username_password( + self._adfs_authority_url, + self._resource, + self.credentials['ad_user'], + self.credentials['password'], + self.credentials['client_id'], + self.credentials['tenant']) elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None: tenant = self.credentials.get('tenant') diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 72138322f3..fe3bdab24c 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -162,9 +162,9 @@ class TaskQueueManager: try: callback_obj.set_options() except AttributeError: - display.deprecated("%s callback, does not support setting 'options', it will work for now, " - " but this will be required in the future and should be updated, " - " see the 2.4 porting guide for details." % callback_obj._load_name, version="2.9") + display.deprecated("%s callback, does not support setting 'options', it will work for now, " + " but this will be required in the future and should be updated, " + " see the 2.4 porting guide for details." % callback_obj._load_name, version="2.9") self._callback_plugins.append(callback_obj) self._callbacks_loaded = True diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index c0200252b7..d7d6ba0f90 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -1026,24 +1026,24 @@ class AzureRMAuth(object): elif self.credentials.get('client_id') is not None and \ self.credentials.get('secret') is not None and \ self.credentials.get('tenant') is not None: - self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'], - secret=self.credentials['secret'], - tenant=self.credentials['tenant'], - cloud_environment=self._cloud_environment, - verify=self._cert_validation_mode == 'validate') + self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'], + secret=self.credentials['secret'], + tenant=self.credentials['tenant'], + cloud_environment=self._cloud_environment, + verify=self._cert_validation_mode == 'validate') elif self.credentials.get('ad_user') is not None and \ self.credentials.get('password') is not None and \ self.credentials.get('client_id') is not None and \ self.credentials.get('tenant') is not None: - self.azure_credentials = self.acquire_token_with_username_password( - self._adfs_authority_url, - self._resource, - self.credentials['ad_user'], - self.credentials['password'], - self.credentials['client_id'], - self.credentials['tenant']) + self.azure_credentials = self.acquire_token_with_username_password( + self._adfs_authority_url, + self._resource, + self.credentials['ad_user'], + self.credentials['password'], + self.credentials['client_id'], + self.credentials['tenant']) elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None: tenant = self.credentials.get('tenant') diff --git a/lib/ansible/module_utils/common/dict_transformations.py b/lib/ansible/module_utils/common/dict_transformations.py index 26ecbcf51f..6d5d8e61f0 100644 --- a/lib/ansible/module_utils/common/dict_transformations.py +++ b/lib/ansible/module_utils/common/dict_transformations.py @@ -117,7 +117,7 @@ def dict_merge(a, b): result = deepcopy(a) for k, v in b.items(): if k in result and isinstance(result[k], dict): - result[k] = dict_merge(result[k], v) + result[k] = dict_merge(result[k], v) else: result[k] = deepcopy(v) return result diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py index 6e51c03037..192f757def 100644 --- a/lib/ansible/module_utils/facts/hardware/linux.py +++ b/lib/ansible/module_utils/facts/hardware/linux.py @@ -448,14 +448,14 @@ class LinuxHardware(Hardware): def get_mount_info(self, mount, device, uuids): - mount_size = get_mount_size(mount) + mount_size = get_mount_size(mount) - # _udevadm_uuid is a fallback for versions of lsblk <= 2.23 that don't have --paths - # see _run_lsblk() above - # https://github.com/ansible/ansible/issues/36077 - uuid = uuids.get(device, self._udevadm_uuid(device)) + # _udevadm_uuid is a fallback for versions of lsblk <= 2.23 that don't have --paths + # see _run_lsblk() above + # https://github.com/ansible/ansible/issues/36077 + uuid = uuids.get(device, self._udevadm_uuid(device)) - return mount_size, uuid + return mount_size, uuid def get_mount_facts(self): diff --git a/lib/ansible/module_utils/network/aci/mso.py b/lib/ansible/module_utils/network/aci/mso.py index a19a23f9e2..1d3f4783dc 100644 --- a/lib/ansible/module_utils/network/aci/mso.py +++ b/lib/ansible/module_utils/network/aci/mso.py @@ -356,7 +356,7 @@ class MSOModule(object): if not t: self.module.fail_json(msg="Tenant '%s' is not valid tenant name." % tenant) if 'id' not in t: - self.module.fail_json(msg="Tenant lookup failed for tenant '%s': %s" % (tenant, t)) + self.module.fail_json(msg="Tenant lookup failed for tenant '%s': %s" % (tenant, t)) return t['id'] def lookup_users(self, users): diff --git a/lib/ansible/modules/cloud/amazon/aws_application_scaling_policy.py b/lib/ansible/modules/cloud/amazon/aws_application_scaling_policy.py index a8b6c91a70..348c4df541 100644 --- a/lib/ansible/modules/cloud/amazon/aws_application_scaling_policy.py +++ b/lib/ansible/modules/cloud/amazon/aws_application_scaling_policy.py @@ -315,7 +315,7 @@ def create_scalable_target(connection, module): ScalableDimension=module.params.get('scalable_dimension') ) except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - module.fail_json_aws(e, msg="Failed to describe scalable targets") + module.fail_json_aws(e, msg="Failed to describe scalable targets") # Scalable target registration will occur if: # 1. There is no scalable target registered for this service diff --git a/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py b/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py index 89c1a25f26..e770b6f0bb 100644 --- a/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py +++ b/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py @@ -1411,7 +1411,7 @@ class CloudFrontValidationManager(object): Comment=comment)) oai = client.create_cloud_front_origin_access_identity(**cfoai_config)['CloudFrontOriginAccessIdentity']['Id'] except Exception as e: - self.module.fail_json_aws(e, msg="Couldn't create Origin Access Identity for id %s" % origin['id']) + self.module.fail_json_aws(e, msg="Couldn't create Origin Access Identity for id %s" % origin['id']) return "origin-access-identity/cloudfront/%s" % oai def validate_origin(self, client, existing_config, origin, default_origin_path): diff --git a/lib/ansible/modules/cloud/amazon/cloudfront_origin_access_identity.py b/lib/ansible/modules/cloud/amazon/cloudfront_origin_access_identity.py index 15607c272e..33f95e6a0f 100644 --- a/lib/ansible/modules/cloud/amazon/cloudfront_origin_access_identity.py +++ b/lib/ansible/modules/cloud/amazon/cloudfront_origin_access_identity.py @@ -147,7 +147,7 @@ class CloudFrontOriginAccessIdentityServiceManager(object): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(self.module, boto3=True) self.client = boto3_conn(self.module, conn_type='client', resource=resource, region=region, endpoint=ec2_url, **aws_connect_kwargs) except (ClientError, BotoCoreError) as e: - self.module.fail_json_aws(e, msg="Unable to establish connection.") + self.module.fail_json_aws(e, msg="Unable to establish connection.") def create_origin_access_identity(self, caller_reference, comment): try: diff --git a/lib/ansible/modules/cloud/amazon/cloudwatchlogs_log_group.py b/lib/ansible/modules/cloud/amazon/cloudwatchlogs_log_group.py index 69b6bfe84f..14df90204d 100644 --- a/lib/ansible/modules/cloud/amazon/cloudwatchlogs_log_group.py +++ b/lib/ansible/modules/cloud/amazon/cloudwatchlogs_log_group.py @@ -242,14 +242,14 @@ def main(): if state == 'present': if found_log_group and module.params['overwrite'] is True: - changed = True - delete_log_group(client=logs, log_group_name=module.params['log_group_name'], module=module) - found_log_group = create_log_group(client=logs, - log_group_name=module.params['log_group_name'], - kms_key_id=module.params['kms_key_id'], - tags=module.params['tags'], - retention=module.params['retention'], - module=module) + changed = True + delete_log_group(client=logs, log_group_name=module.params['log_group_name'], module=module) + found_log_group = create_log_group(client=logs, + log_group_name=module.params['log_group_name'], + kms_key_id=module.params['kms_key_id'], + tags=module.params['tags'], + retention=module.params['retention'], + module=module) elif not found_log_group: changed = True found_log_group = create_log_group(client=logs, diff --git a/lib/ansible/modules/cloud/azure/azure_rm_webapp.py b/lib/ansible/modules/cloud/azure/azure_rm_webapp.py index f34f80775c..3228814b41 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_webapp.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_webapp.py @@ -783,7 +783,7 @@ class AzureRMWebApps(AzureRMModuleBase): if self.site_config.get(fx_version): if not getattr(existing_config, fx_version) or \ getattr(existing_config, fx_version).upper() != self.site_config.get(fx_version).upper(): - return True + return True return False diff --git a/lib/ansible/modules/cloud/azure/azure_rm_webappslot.py b/lib/ansible/modules/cloud/azure/azure_rm_webappslot.py index 8153bdee9f..901a865ccb 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_webappslot.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_webappslot.py @@ -671,7 +671,7 @@ class AzureRMWebAppSlots(AzureRMModuleBase): if self.site_config.get(fx_version): if not getattr(existing_config, fx_version) or \ getattr(existing_config, fx_version).upper() != self.site_config.get(fx_version).upper(): - return True + return True if self.auto_swap_slot_name is False and existing_config.auto_swap_slot_name is not None: return True diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py b/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py index 6780be37a5..a138adac2f 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py @@ -263,7 +263,7 @@ class VmBootManager(PyVmomi): if self.params.get('secure_boot_enabled') and \ self.params.get('boot_firmware') is None and \ self.vm.config.firmware == 'bios': - self.module.fail_json(msg="EFI secure boot cannot be enabled when boot_firmware = bios. VM's boot_firmware currently set to bios") + self.module.fail_json(msg="EFI secure boot cannot be enabled when boot_firmware = bios. VM's boot_firmware currently set to bios") kwargs.update({'efiSecureBootEnabled': self.params.get('secure_boot_enabled')}) change_needed = True diff --git a/lib/ansible/modules/cloud/vultr/vultr_os_facts.py b/lib/ansible/modules/cloud/vultr/vultr_os_facts.py index 0002510f5a..339753fbd9 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_os_facts.py +++ b/lib/ansible/modules/cloud/vultr/vultr_os_facts.py @@ -100,7 +100,7 @@ class AnsibleVultrOSFacts(Vultr): def parse_oses_list(oses_list): - return [os for id, os in oses_list.items()] + return [os for id, os in oses_list.items()] def main(): diff --git a/lib/ansible/modules/database/mongodb/mongodb_shard.py b/lib/ansible/modules/database/mongodb/mongodb_shard.py index fd49b5c86e..0a7973d3a4 100644 --- a/lib/ansible/modules/database/mongodb/mongodb_shard.py +++ b/lib/ansible/modules/database/mongodb/mongodb_shard.py @@ -190,7 +190,7 @@ def shard_find(client, shard): else: s = shard for shard in client["config"].shards.find({"_id": s}): - return shard + return shard return False diff --git a/lib/ansible/modules/database/postgresql/postgresql_idx.py b/lib/ansible/modules/database/postgresql/postgresql_idx.py index 92cd971791..0c9ad917c5 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_idx.py +++ b/lib/ansible/modules/database/postgresql/postgresql_idx.py @@ -349,9 +349,9 @@ def main(): msg='psycopg2 must be at least 2.4.3 in order to user the ssl_rootcert parameter') if module.check_mode and concurrent: - module.fail_json(msg="Cannot concurrently create or drop index %s " - "inside the transaction block. The check is possible " - "in not concurrent mode only" % idxname) + module.fail_json(msg="Cannot concurrently create or drop index %s " + "inside the transaction block. The check is possible " + "in not concurrent mode only" % idxname) try: db_connection = psycopg2.connect(**kw) diff --git a/lib/ansible/modules/net_tools/ip_netns.py b/lib/ansible/modules/net_tools/ip_netns.py index 9eda57cf99..f24b8d3703 100644 --- a/lib/ansible/modules/net_tools/ip_netns.py +++ b/lib/ansible/modules/net_tools/ip_netns.py @@ -101,7 +101,7 @@ class Namespace(object): changed = False if self.state == 'present' and self.exists(): - changed = True + changed = True elif self.state == 'absent' and self.exists(): changed = True diff --git a/lib/ansible/modules/network/dellos6/dellos6_config.py b/lib/ansible/modules/network/dellos6/dellos6_config.py index 3c07bf54e1..21ec6bbca0 100644 --- a/lib/ansible/modules/network/dellos6/dellos6_config.py +++ b/lib/ansible/modules/network/dellos6/dellos6_config.py @@ -319,14 +319,14 @@ def main(): if module.params['save']: result['changed'] = True if not module.check_mode: - cmd = {'command': 'copy running-config startup-config', - 'prompt': r'\(y/n\)\s?$', 'answer': 'y'} - run_commands(module, [cmd]) - result['saved'] = True + cmd = {'command': 'copy running-config startup-config', + 'prompt': r'\(y/n\)\s?$', 'answer': 'y'} + run_commands(module, [cmd]) + result['saved'] = True else: - module.warn('Skipping command `copy running-config startup-config`' - 'due to check_mode. Configuration not copied to ' - 'non-volatile storage') + module.warn('Skipping command `copy running-config startup-config`' + 'due to check_mode. Configuration not copied to ' + 'non-volatile storage') module.exit_json(**result) diff --git a/lib/ansible/modules/network/ios/ios_ntp.py b/lib/ansible/modules/network/ios/ios_ntp.py index 5de3f0ef1e..92efc13a73 100644 --- a/lib/ansible/modules/network/ios/ios_ntp.py +++ b/lib/ansible/modules/network/ios/ios_ntp.py @@ -144,7 +144,7 @@ def parse_key_id(line, dest): def parse_auth(dest): if dest == 'authenticate': - return dest + return dest def map_config_to_obj(module): diff --git a/lib/ansible/modules/network/ios/ios_vrf.py b/lib/ansible/modules/network/ios/ios_vrf.py index f65f24bf39..2f545d5134 100644 --- a/lib/ansible/modules/network/ios/ios_vrf.py +++ b/lib/ansible/modules/network/ios/ios_vrf.py @@ -332,40 +332,40 @@ def map_obj_to_commands(updates, module): add_command_to_vrf(want['name'], cmd, commands) if needs_update(want, have, 'route_import_ipv4'): - cmd = 'address-family ipv4' - add_command_to_vrf(want['name'], cmd, commands) - for route in want['route_import_ipv4']: - cmd = 'route-target import %s' % route - add_command_to_vrf(want['name'], cmd, commands) - cmd = 'exit-address-family' + cmd = 'address-family ipv4' + add_command_to_vrf(want['name'], cmd, commands) + for route in want['route_import_ipv4']: + cmd = 'route-target import %s' % route add_command_to_vrf(want['name'], cmd, commands) + cmd = 'exit-address-family' + add_command_to_vrf(want['name'], cmd, commands) if needs_update(want, have, 'route_export_ipv4'): - cmd = 'address-family ipv4' - add_command_to_vrf(want['name'], cmd, commands) - for route in want['route_export_ipv4']: - cmd = 'route-target export %s' % route - add_command_to_vrf(want['name'], cmd, commands) - cmd = 'exit-address-family' + cmd = 'address-family ipv4' + add_command_to_vrf(want['name'], cmd, commands) + for route in want['route_export_ipv4']: + cmd = 'route-target export %s' % route add_command_to_vrf(want['name'], cmd, commands) + cmd = 'exit-address-family' + add_command_to_vrf(want['name'], cmd, commands) if needs_update(want, have, 'route_import_ipv6'): - cmd = 'address-family ipv6' - add_command_to_vrf(want['name'], cmd, commands) - for route in want['route_import_ipv6']: - cmd = 'route-target import %s' % route - add_command_to_vrf(want['name'], cmd, commands) - cmd = 'exit-address-family' + cmd = 'address-family ipv6' + add_command_to_vrf(want['name'], cmd, commands) + for route in want['route_import_ipv6']: + cmd = 'route-target import %s' % route add_command_to_vrf(want['name'], cmd, commands) + cmd = 'exit-address-family' + add_command_to_vrf(want['name'], cmd, commands) if needs_update(want, have, 'route_export_ipv6'): - cmd = 'address-family ipv6' - add_command_to_vrf(want['name'], cmd, commands) - for route in want['route_export_ipv6']: - cmd = 'route-target export %s' % route - add_command_to_vrf(want['name'], cmd, commands) - cmd = 'exit-address-family' + cmd = 'address-family ipv6' + add_command_to_vrf(want['name'], cmd, commands) + for route in want['route_export_ipv6']: + cmd = 'route-target export %s' % route add_command_to_vrf(want['name'], cmd, commands) + cmd = 'exit-address-family' + add_command_to_vrf(want['name'], cmd, commands) if want['interfaces'] is not None: # handle the deletes diff --git a/lib/ansible/modules/network/meraki/meraki_admin.py b/lib/ansible/modules/network/meraki/meraki_admin.py index 20ebbd571a..a63c1804d1 100644 --- a/lib/ansible/modules/network/meraki/meraki_admin.py +++ b/lib/ansible/modules/network/meraki/meraki_admin.py @@ -209,7 +209,7 @@ def get_admin_id(meraki, data, name=None, email=None): admin_id = a['id'] elif meraki.params['email']: if meraki.params['email'] == a['email']: - return a['id'] + return a['id'] if admin_id is None: meraki.fail_json(msg='No admin_id found') return admin_id diff --git a/lib/ansible/modules/network/meraki/meraki_mr_l3_firewall.py b/lib/ansible/modules/network/meraki/meraki_mr_l3_firewall.py index 4d1afbc089..dec2fd3338 100644 --- a/lib/ansible/modules/network/meraki/meraki_mr_l3_firewall.py +++ b/lib/ansible/modules/network/meraki/meraki_mr_l3_firewall.py @@ -144,11 +144,11 @@ def assemble_payload(meraki): def get_rules(meraki, net_id, number): - path = meraki.construct_path('get_all', net_id=net_id) - path = path + number + '/l3FirewallRules' - response = meraki.request(path, method='GET') - if meraki.status == 200: - return response + path = meraki.construct_path('get_all', net_id=net_id) + path = path + number + '/l3FirewallRules' + response = meraki.request(path, method='GET') + if meraki.status == 200: + return response def get_ssid_number(name, data): diff --git a/lib/ansible/modules/network/meraki/meraki_mx_l3_firewall.py b/lib/ansible/modules/network/meraki/meraki_mx_l3_firewall.py index 0414489b10..0f293786c9 100644 --- a/lib/ansible/modules/network/meraki/meraki_mx_l3_firewall.py +++ b/lib/ansible/modules/network/meraki/meraki_mx_l3_firewall.py @@ -211,10 +211,10 @@ def assemble_payload(meraki): def get_rules(meraki, net_id): - path = meraki.construct_path('get_all', net_id=net_id) - response = meraki.request(path, method='GET') - if meraki.status == 200: - return response + path = meraki.construct_path('get_all', net_id=net_id) + response = meraki.request(path, method='GET') + if meraki.status == 200: + return response def main(): diff --git a/lib/ansible/modules/network/meraki/meraki_snmp.py b/lib/ansible/modules/network/meraki/meraki_snmp.py index da238f01c0..b3536298e2 100644 --- a/lib/ansible/modules/network/meraki/meraki_snmp.py +++ b/lib/ansible/modules/network/meraki/meraki_snmp.py @@ -181,7 +181,7 @@ def set_snmp(meraki, org_id): meraki.params['v3_auth_pass'] is None or meraki.params['v3_priv_mode'] is None or meraki.params['v3_priv_pass'] is None): - meraki.fail_json(msg='v3_auth_mode, v3_auth_pass, v3_priv_mode, and v3_auth_pass are required') + meraki.fail_json(msg='v3_auth_mode, v3_auth_pass, v3_priv_mode, and v3_auth_pass are required') payload = {'v3Enabled': meraki.params['v3_enabled'], 'v3AuthMode': meraki.params['v3_auth_mode'].upper(), 'v3AuthPass': meraki.params['v3_auth_pass'], diff --git a/lib/ansible/modules/network/netvisor/pn_snmp_community.py b/lib/ansible/modules/network/netvisor/pn_snmp_community.py index 6ea3d9a57f..ab17869ffb 100644 --- a/lib/ansible/modules/network/netvisor/pn_snmp_community.py +++ b/lib/ansible/modules/network/netvisor/pn_snmp_community.py @@ -168,7 +168,7 @@ def main(): cli += ' %s community-string %s ' % (command, comm_str) if command != 'snmp-community-delete' and community_type: - cli += ' community-type ' + community_type + cli += ' community-type ' + community_type run_cli(module, cli, state_map) diff --git a/lib/ansible/modules/network/nxos/nxos_evpn_vni.py b/lib/ansible/modules/network/nxos/nxos_evpn_vni.py index 12172a9306..6ca4706f65 100644 --- a/lib/ansible/modules/network/nxos/nxos_evpn_vni.py +++ b/lib/ansible/modules/network/nxos/nxos_evpn_vni.py @@ -272,13 +272,13 @@ def main(): commands, parents = state_absent(module, existing, proposed) if commands: - candidate = CustomNetworkConfig(indent=3) - candidate.add(commands, parents=parents) - candidate = candidate.items_text() - if not module.check_mode: - load_config(module, candidate) - results['changed'] = True - results['commands'] = candidate + candidate = CustomNetworkConfig(indent=3) + candidate.add(commands, parents=parents) + candidate = candidate.items_text() + if not module.check_mode: + load_config(module, candidate) + results['changed'] = True + results['commands'] = candidate else: results['commands'] = [] module.exit_json(**results) diff --git a/lib/ansible/modules/network/nxos/nxos_igmp_interface.py b/lib/ansible/modules/network/nxos/nxos_igmp_interface.py index fc01f9a31d..f46c1b13db 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp_interface.py @@ -383,15 +383,15 @@ def config_igmp_interface(delta, existing, existing_oif_prefix_source): commands.append(CMDS.get('oif_prefix').format(pf)) if existing_oif_prefix_source: for each in existing_oif_prefix_source: - # remove stale prefix/sources - pf = each['prefix'] - src = '' - if 'source' in each.keys(): - src = each['source'] - if src: - commands.append('no ' + CMDS.get('oif_prefix_source').format(pf, src)) - else: - commands.append('no ' + CMDS.get('oif_prefix').format(pf)) + # remove stale prefix/sources + pf = each['prefix'] + src = '' + if 'source' in each.keys(): + src = each['source'] + if src: + commands.append('no ' + CMDS.get('oif_prefix_source').format(pf, src)) + else: + commands.append('no ' + CMDS.get('oif_prefix').format(pf)) elif key == 'oif_routemap': if value == 'default': if existing.get(key): diff --git a/lib/ansible/modules/network/onyx/onyx_config.py b/lib/ansible/modules/network/onyx/onyx_config.py index fc5a3fd102..ae6958252e 100644 --- a/lib/ansible/modules/network/onyx/onyx_config.py +++ b/lib/ansible/modules/network/onyx/onyx_config.py @@ -196,7 +196,7 @@ def run(module, result): result['updates'] = total_commands if module.params['save']: - total_commands.append('configuration write') + total_commands.append('configuration write') if total_commands: result['changed'] = True if not module.check_mode: diff --git a/lib/ansible/modules/network/ovs/openvswitch_db.py b/lib/ansible/modules/network/ovs/openvswitch_db.py index 0d54bf1b7c..5a4c794d52 100644 --- a/lib/ansible/modules/network/ovs/openvswitch_db.py +++ b/lib/ansible/modules/network/ovs/openvswitch_db.py @@ -170,7 +170,7 @@ def map_config_to_obj(module): obj['key'] = module.params['key'] obj['value'] = col_value_to_dict[module.params['key']] else: - obj['value'] = str(col_value.strip()) + obj['value'] = str(col_value.strip()) return obj diff --git a/lib/ansible/modules/notification/mail.py b/lib/ansible/modules/notification/mail.py index 56094b8db3..057f826bf6 100644 --- a/lib/ansible/modules/notification/mail.py +++ b/lib/ansible/modules/notification/mail.py @@ -291,7 +291,7 @@ def main(): try: smtp.ehlo() except smtplib.SMTPException as e: - module.fail_json(rc=1, msg='Helo failed for host %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc()) + module.fail_json(rc=1, msg='Helo failed for host %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc()) if int(code) > 0: if not secure_state and secure in ('starttls', 'try'): diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index 3d91bc7ab1..b08d34ff8c 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -837,7 +837,7 @@ class DnfModule(YumDnf): if self.allow_downgrade: self.base.package_install(pkg) else: - self.base.package_install(pkg) + self.base.package_install(pkg) except Exception as e: self.module.fail_json( msg="Error occured attempting remote rpm operation: {0}".format(to_native(e)), diff --git a/lib/ansible/modules/storage/emc/emc_vnx_sg_member.py b/lib/ansible/modules/storage/emc/emc_vnx_sg_member.py index 8418c0c221..452d0a3411 100644 --- a/lib/ansible/modules/storage/emc/emc_vnx_sg_member.py +++ b/lib/ansible/modules/storage/emc/emc_vnx_sg_member.py @@ -159,11 +159,11 @@ def run_module(): '{1} '.format(alu, to_native(e)), **result) else: - module.fail_json(msg='No such storage group named ' - '{0}'.format(module.params['name']), - **result) + module.fail_json(msg='No such storage group named ' + '{0}'.format(module.params['name']), + **result) except VNXCredentialError as e: - module.fail_json(msg='{0}'.format(to_native(e)), **result) + module.fail_json(msg='{0}'.format(to_native(e)), **result) module.exit_json(**result) diff --git a/lib/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.py b/lib/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.py index 0ad7091e08..c8c8bbe4a1 100644 --- a/lib/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.py +++ b/lib/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.py @@ -490,15 +490,15 @@ class ElementSWSnapShotSchedule(object): if schedule_detail.frequency.days != temp_frequency.days or \ schedule_detail.frequency.hours != temp_frequency.hours or \ schedule_detail.frequency.minutes != temp_frequency.minutes: - update_schedule = True - changed = True + update_schedule = True + changed = True elif self.schedule_type == "DaysOfMonthFrequency": # Check if there is any change in schedule.frequency, If schedule_type is days_of_month if len(schedule_detail.frequency.monthdays) != len(temp_frequency.monthdays) or \ schedule_detail.frequency.hours != temp_frequency.hours or \ schedule_detail.frequency.minutes != temp_frequency.minutes: - update_schedule = True - changed = True + update_schedule = True + changed = True elif len(schedule_detail.frequency.monthdays) == len(temp_frequency.monthdays): actual_frequency_monthday = schedule_detail.frequency.monthdays temp_frequency_monthday = temp_frequency.monthdays @@ -511,15 +511,15 @@ class ElementSWSnapShotSchedule(object): if len(schedule_detail.frequency.weekdays) != len(temp_frequency.weekdays) or \ schedule_detail.frequency.hours != temp_frequency.hours or \ schedule_detail.frequency.minutes != temp_frequency.minutes: - update_schedule = True - changed = True + update_schedule = True + changed = True elif len(schedule_detail.frequency.weekdays) == len(temp_frequency.weekdays): actual_frequency_weekdays = schedule_detail.frequency.weekdays temp_frequency_weekdays = temp_frequency.weekdays if len([actual_weekday for actual_weekday, temp_weekday in - zip(actual_frequency_weekdays, temp_frequency_weekdays) if actual_weekday != temp_weekday]) != 0: - update_schedule = True - changed = True + zip(actual_frequency_weekdays, temp_frequency_weekdays) if actual_weekday != temp_weekday]) != 0: + update_schedule = True + changed = True else: update_schedule = True changed = True diff --git a/lib/ansible/modules/storage/netapp/na_elementsw_volume.py b/lib/ansible/modules/storage/netapp/na_elementsw_volume.py index 6b25cca109..2d1b1c9d97 100644 --- a/lib/ansible/modules/storage/netapp/na_elementsw_volume.py +++ b/lib/ansible/modules/storage/netapp/na_elementsw_volume.py @@ -340,8 +340,8 @@ class ElementOSVolume(object): volume_qos = volume_detail.qos.__dict__ if volume_qos['min_iops'] != self.qos['minIOPS'] or volume_qos['max_iops'] != self.qos['maxIOPS'] \ or volume_qos['burst_iops'] != self.qos['burstIOPS']: - update_volume = True - changed = True + update_volume = True + changed = True else: # If check fails, do nothing pass diff --git a/lib/ansible/modules/storage/netapp/na_elementsw_volume_clone.py b/lib/ansible/modules/storage/netapp/na_elementsw_volume_clone.py index c7e23652dc..b55609d4d0 100644 --- a/lib/ansible/modules/storage/netapp/na_elementsw_volume_clone.py +++ b/lib/ansible/modules/storage/netapp/na_elementsw_volume_clone.py @@ -233,7 +233,7 @@ class ElementOSVolumeClone(object): result_message = "" if self.get_account_id() is None: - self.module.fail_json(msg="Account id not found: %s" % (self.account_id)) + self.module.fail_json(msg="Account id not found: %s" % (self.account_id)) # there is only one state. other operations # are part of the volume module @@ -245,7 +245,7 @@ class ElementOSVolumeClone(object): if self.get_src_volume_id() is not None: # check for a valid snapshot if self.src_snapshot_id and not self.get_snapshot_id(): - self.module.fail_json(msg="Snapshot id not found: %s" % (self.src_snapshot_id)) + self.module.fail_json(msg="Snapshot id not found: %s" % (self.src_snapshot_id)) # change required changed = True else: diff --git a/lib/ansible/modules/storage/netapp/na_ontap_command.py b/lib/ansible/modules/storage/netapp/na_ontap_command.py index 8ddf252857..38466a5101 100644 --- a/lib/ansible/modules/storage/netapp/na_ontap_command.py +++ b/lib/ansible/modules/storage/netapp/na_ontap_command.py @@ -94,12 +94,12 @@ class NetAppONTAPCommand(object): def main(): - """ - Execute action from playbook - """ - command = NetAppONTAPCommand() - command.apply() + """ + Execute action from playbook + """ + command = NetAppONTAPCommand() + command.apply() if __name__ == '__main__': - main() + main() diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index 24c5d7ee0f..3189413bbe 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -294,8 +294,8 @@ class DataLoader: # if path is in role and 'tasks' not there already, add it into the search if (is_role or self._is_role(path)) and b_mydir.endswith(b'tasks'): - search.append(os.path.join(os.path.dirname(b_mydir), b_dirname, b_source)) - search.append(os.path.join(b_mydir, b_source)) + search.append(os.path.join(os.path.dirname(b_mydir), b_dirname, b_source)) + search.append(os.path.join(b_mydir, b_source)) else: # don't add dirname if user already is using it in source if b_source.split(b'/')[0] != dirname: diff --git a/lib/ansible/plugins/doc_fragments/gcp.py b/lib/ansible/plugins/doc_fragments/gcp.py index e736e5d4de..0dee1fcad3 100644 --- a/lib/ansible/plugins/doc_fragments/gcp.py +++ b/lib/ansible/plugins/doc_fragments/gcp.py @@ -3,8 +3,8 @@ class ModuleDocFragment(object): - # GCP doc fragment. - DOCUMENTATION = ''' + # GCP doc fragment. + DOCUMENTATION = ''' options: project: description: diff --git a/lib/ansible/plugins/inventory/foreman.py b/lib/ansible/plugins/inventory/foreman.py index 19662f7913..db9beef846 100644 --- a/lib/ansible/plugins/inventory/foreman.py +++ b/lib/ansible/plugins/inventory/foreman.py @@ -75,7 +75,7 @@ try: if LooseVersion(requests.__version__) < LooseVersion('1.1.0'): raise ImportError except ImportError: - raise AnsibleError('This script requires python-requests 1.1 as a minimum version') + raise AnsibleError('This script requires python-requests 1.1 as a minimum version') from requests.auth import HTTPBasicAuth