diff --git a/contrib/inventory/abiquo.py b/contrib/inventory/abiquo.py index 04f7d4e60df..0b5533bb6bb 100755 --- a/contrib/inventory/abiquo.py +++ b/contrib/inventory/abiquo.py @@ -142,7 +142,7 @@ def generate_inv_from_api(enterprise_entity,config): break else: vm_nic = None - + vm_state = True # From abiquo.ini: Only adding to inventory VMs deployed if ((config.getboolean('defaults', 'deployed_only') == True) and (vmcollection['state'] == 'NOT_ALLOCATED')): diff --git a/contrib/inventory/apache-libcloud.py b/contrib/inventory/apache-libcloud.py index f7d64c257c2..fd020caae8a 100755 --- a/contrib/inventory/apache-libcloud.py +++ b/contrib/inventory/apache-libcloud.py @@ -145,7 +145,7 @@ class LibcloudInventory(object): self.cache_path_cache = cache_path + "/ansible-libcloud.cache" self.cache_path_index = cache_path + "/ansible-libcloud.index" self.cache_max_age = config.getint('cache', 'cache_max_age') - + def parse_cli_args(self): ''' @@ -225,7 +225,7 @@ class LibcloudInventory(object): # Inventory: Group by key pair if node.extra['key_name']: self.push(self.inventory, self.to_safe('key_' + node.extra['key_name']), dest) - + # Inventory: Group by security group, quick thing to handle single sg if node.extra['security_group']: self.push(self.inventory, self.to_safe('sg_' + node.extra['security_group'][0]), dest) diff --git a/contrib/inventory/consul_io.py b/contrib/inventory/consul_io.py index 2f226e7b50e..40b3d35eba4 100755 --- a/contrib/inventory/consul_io.py +++ b/contrib/inventory/consul_io.py @@ -289,7 +289,7 @@ class ConsulInventory(object): and the node name add each entry in the dictionary to the the node's metadata ''' node = node_data['Node'] - if self.config.has_config('kv_metadata'): + if self.config.has_config('kv_metadata'): key = "%s/%s/%s" % (self.config.kv_metadata, self.current_dc, node['Node']) index, metadata = self.consul_api.kv.get(key) if metadata and metadata['Value']: @@ -305,7 +305,7 @@ class ConsulInventory(object): kv_groups config value and the node name add the node address to each group found ''' node = node_data['Node'] - if self.config.has_config('kv_groups'): + if self.config.has_config('kv_groups'): key = "%s/%s/%s" % (self.config.kv_groups, self.current_dc, node['Node']) index, groups = self.consul_api.kv.get(key) if groups and groups['Value']: diff --git a/contrib/inventory/fleet.py b/contrib/inventory/fleet.py index 788e1a5f511..4db4ea199cc 100755 --- a/contrib/inventory/fleet.py +++ b/contrib/inventory/fleet.py @@ -77,7 +77,7 @@ def get_a_ssh_config(box_name): if options.list: ssh_config = get_ssh_config() hosts = { 'coreos': []} - + for data in ssh_config: hosts['coreos'].append(data['Host']) diff --git a/contrib/inventory/freeipa.py b/contrib/inventory/freeipa.py index 377326c7101..64ede999a43 100755 --- a/contrib/inventory/freeipa.py +++ b/contrib/inventory/freeipa.py @@ -18,7 +18,7 @@ def initialize(): except AttributeError: #FreeIPA < 4.0 compatibility api.Backend.xmlclient.connect() - + return api def list_groups(api): @@ -39,7 +39,7 @@ def list_groups(api): if 'member_host' in hostgroup: members = [host for host in hostgroup['member_host']] if 'memberindirect_host' in hostgroup: - members += (host for host in hostgroup['memberindirect_host']) + members += (host for host in hostgroup['memberindirect_host']) inventory[hostgroup['cn'][0]] = {'hosts': [host for host in members]} for member in members: @@ -48,7 +48,7 @@ def list_groups(api): inventory['_meta'] = {'hostvars': hostvars} inv_string = json.dumps(inventory, indent=1, sort_keys=True) print(inv_string) - + return None def parse_args(): diff --git a/contrib/inventory/spacewalk.py b/contrib/inventory/spacewalk.py index bee92dfb89e..3d0005e5bbe 100755 --- a/contrib/inventory/spacewalk.py +++ b/contrib/inventory/spacewalk.py @@ -220,7 +220,7 @@ elif options.host: print('Problem executing the command "%s inventory": %s' % (SW_REPORT, str(e)), file=sys.stderr) sys.exit(2) - + if options.human: print('Host: %s' % options.host) for k, v in iteritems(host_details): diff --git a/contrib/inventory/stacki.py b/contrib/inventory/stacki.py index 9dbabf85621..db90df7befb 100644 --- a/contrib/inventory/stacki.py +++ b/contrib/inventory/stacki.py @@ -58,7 +58,7 @@ try: import requests except: sys.exit('requests package is required for this inventory script') - + CONFIG_FILES = ['/etc/stacki/stacki.yml', '/etc/ansible/stacki.yml'] diff --git a/hacking/dump_playbook_attributes.py b/hacking/dump_playbook_attributes.py index 8ccd6f752b2..204fe3fd325 100755 --- a/hacking/dump_playbook_attributes.py +++ b/hacking/dump_playbook_attributes.py @@ -3,10 +3,10 @@ import optparse from jinja2 import Environment, FileSystemLoader -from ansible.playbook import Play -from ansible.playbook.block import Block -from ansible.playbook.role import Role -from ansible.playbook.task import Task +from ansible.playbook import Play +from ansible.playbook.block import Block +from ansible.playbook.role import Role +from ansible.playbook.task import Task template_file = 'playbooks_directives.rst.j2' oblist = {} diff --git a/lib/ansible/executor/stats.py b/lib/ansible/executor/stats.py index 989a380be7d..f91874d17a9 100644 --- a/lib/ansible/executor/stats.py +++ b/lib/ansible/executor/stats.py @@ -59,7 +59,7 @@ class AggregateStats: if host is None: host = '_run' - if host not in self.custom: + if host not in self.custom: self.custom[host] = {which: what} else: self.custom[host][which] = what diff --git a/lib/ansible/galaxy/login.py b/lib/ansible/galaxy/login.py index 3dd90c84b10..29b6c094de3 100644 --- a/lib/ansible/galaxy/login.py +++ b/lib/ansible/galaxy/login.py @@ -44,12 +44,12 @@ class GalaxyLogin(object): ''' Class to handle authenticating user with Galaxy API prior to performing CUD operations ''' GITHUB_AUTH = 'https://api.github.com/authorizations' - + def __init__(self, galaxy, github_token=None): self.galaxy = galaxy self.github_username = None self.github_password = None - + if github_token == None: self.get_credentials() @@ -61,7 +61,7 @@ class GalaxyLogin(object): display.display("The password will not be displayed." + u'\n\n', screen_only=True) display.display("Use " + stringc("--github-token",'yellow') + " if you do not want to enter your password." + u'\n\n', screen_only=True) - + try: self.github_username = raw_input("Github Username: ") except: diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py index da6743bd81d..9883abdc8ed 100644 --- a/lib/ansible/galaxy/role.py +++ b/lib/ansible/galaxy/role.py @@ -208,7 +208,7 @@ class GalaxyRole(object): # create tar file from scm url tmp_file = RoleRequirement.scm_archive_role(**self.spec) elif self.src: - if os.path.isfile(self.src): + if os.path.isfile(self.src): # installing a local tar.gz local_file = True tmp_file = self.src diff --git a/lib/ansible/galaxy/token.py b/lib/ansible/galaxy/token.py index 4346dc8760a..742c7b39f06 100644 --- a/lib/ansible/galaxy/token.py +++ b/lib/ansible/galaxy/token.py @@ -42,7 +42,7 @@ class GalaxyToken(object): self.config = yaml.safe_load(self.__open_config_for_read()) if not self.config: self.config = {} - + def __open_config_for_read(self): if os.path.isfile(self.file): display.vvv('Opened %s' % self.file) @@ -57,11 +57,11 @@ class GalaxyToken(object): def set(self, token): self.config['token'] = token self.save() - + def get(self): return self.config.get('token', None) - + def save(self): with open(self.file,'w') as f: yaml.safe_dump(self.config,f,default_flow_style=False) - + diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index 78ba496d5ac..d646da93b03 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -333,7 +333,7 @@ class AzureRMModuleBase(object): def _get_credentials(self, params): # Get authentication credentials. # Precedence: module parameters-> environment variables-> default profile in ~/.azure/credentials. - + self.log('Getting credentials') arg_credentials = dict() @@ -345,11 +345,11 @@ class AzureRMModuleBase(object): self.log('Retrieving credentials with profile parameter.') credentials = self._get_profile(arg_credentials['profile']) return credentials - + if arg_credentials['subscription_id']: self.log('Received credentials from parameters.') return arg_credentials - + # try environment env_credentials = self._get_env_credentials() if env_credentials: diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 8cd4fff9548..72c775c1119 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -368,7 +368,7 @@ class Facts(object): self.facts['service_mgr'] = proc_1_map.get(proc_1, proc_1) # start with the easy ones - elif self.facts['distribution'] == 'MacOSX': + elif self.facts['distribution'] == 'MacOSX': #FIXME: find way to query executable, version matching is not ideal if LooseVersion(platform.mac_ver()[0]) >= LooseVersion('10.4'): self.facts['service_mgr'] = 'launchd' @@ -2155,7 +2155,7 @@ class AIX(Hardware): rc, out, err = self.module.run_command(cmd) if rc == 0 and out: pp_size = re.search(r'PP SIZE:\s+(\d+\s+\S+)',out).group(1) - for n in re.finditer(r'(\S+)\s+(\w+)\s+(\d+)\s+(\d+).*',m.group(0)): + for n in re.finditer(r'(\S+)\s+(\w+)\s+(\d+)\s+(\d+).*',m.group(0)): pv_info = { 'pv_name': n.group(1), 'pv_state': n.group(2), 'total_pps': n.group(3), diff --git a/lib/ansible/module_utils/redhat.py b/lib/ansible/module_utils/redhat.py index 905990cf433..ed2a92956f5 100644 --- a/lib/ansible/module_utils/redhat.py +++ b/lib/ansible/module_utils/redhat.py @@ -127,7 +127,7 @@ class Rhsm(RegistrationBase): for k,v in kwargs.items(): if re.search(r'^(system|rhsm)_', k): args.append('--%s=%s' % (k.replace('_','.'), v)) - + self.module.run_command(args, check_rc=True) @property diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index d1020c5cfd2..888e7183c8d 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -644,7 +644,7 @@ def replace(connection, module): instances = props['instances'] if replace_instances: instances = replace_instances - + #check if min_size/max_size/desired capacity have been specified and if not use ASG values if min_size is None: min_size = as_group.min_size @@ -674,7 +674,7 @@ def replace(connection, module): if not old_instances: changed = False return(changed, props) - + # set temporary settings and wait for them to be reached # This should get overwritten if the number of instances left is less than the batch size. @@ -827,7 +827,7 @@ def wait_for_term_inst(connection, module, term_instances): lifecycle = instance_facts[i]['lifecycle_state'] health = instance_facts[i]['health_status'] log.debug("Instance {0} has state of {1},{2}".format(i,lifecycle,health )) - if lifecycle == 'Terminating' or health == 'Unhealthy': + if lifecycle == 'Terminating' or health == 'Unhealthy': count += 1 time.sleep(10) diff --git a/lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py b/lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py index a8a74926cdd..631a07a9a5b 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py +++ b/lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py @@ -148,7 +148,7 @@ class Ec2CustomerGatewayManager: CustomerGatewayId=gw_id ) return response - + def ensure_cgw_present(self, bgp_asn, ip_address): response = self.ec2.create_customer_gateway( DryRun=False, diff --git a/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py b/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py index c4857f6a3cd..710331fe809 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py @@ -215,7 +215,7 @@ class ElbInformation(object): elb_array.append(existing_lb) else: elb_array = all_elbs - + return list(map(self._get_elb_info, elb_array)) def main(): diff --git a/lib/ansible/modules/cloud/amazon/ec2_tag.py b/lib/ansible/modules/cloud/amazon/ec2_tag.py index 7655dd5c36a..13653d31118 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_tag.py +++ b/lib/ansible/modules/cloud/amazon/ec2_tag.py @@ -143,14 +143,14 @@ def main(): resource = module.params.get('resource') tags = module.params.get('tags') state = module.params.get('state') - + ec2 = ec2_connect(module) - + # We need a comparison here so that we can accurately report back changed status. # Need to expand the gettags return format and compare with "tags" and then tag or detag as appropriate. filters = {'resource-id' : resource} gettags = ec2.get_all_tags(filters=filters) - + dictadd = {} dictremove = {} baddict = {} @@ -170,7 +170,7 @@ def main(): tagger = ec2.create_tags(resource, dictadd) gettags = ec2.get_all_tags(filters=filters) module.exit_json(msg="Tags %s created for resource %s." % (dictadd,resource), changed=True) - + if state == 'absent': if not tags: module.fail_json(msg="tags argument is required when state is absent") diff --git a/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py index d471fef31c4..ba5350789a7 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py @@ -97,7 +97,7 @@ def get_volume_info(volume): }, 'tags': volume.tags } - + return volume_info def list_ec2_volumes(connection, module): diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options.py index 4caee644519..15baf151429 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options.py @@ -289,7 +289,7 @@ def main(): changed = False new_options = collections.defaultdict(lambda: None) - + region, ec2_url, boto_params = get_aws_connection_info(module) connection = connect_to_aws(boto.vpc, region, **boto_params) @@ -378,9 +378,9 @@ def main(): # and remove old ones if that was requested if params['delete_old'] and existing_options: remove_dhcp_options_by_id(connection, existing_options.id) - + module.exit_json(changed=changed, new_options=new_options, dhcp_options_id=dhcp_option.id) - + from ansible.module_utils.basic import * from ansible.module_utils.ec2 import * diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py index 14e1c4920f5..1915fd813e4 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py @@ -72,7 +72,7 @@ def get_vpc_info(vpc): classic_link = vpc.classic_link_enabled except AttributeError: classic_link = False - + vpc_info = { 'id': vpc.id, 'instance_tenancy': vpc.instance_tenancy, 'classic_link_enabled': classic_link, diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py index 6e378dc2711..d6e92e112de 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py @@ -133,7 +133,7 @@ def list_virtual_gateways(client, module): snaked_vgws = [camel_dict_to_snake_dict(get_virtual_gateway_info(vgw)) for vgw in all_virtual_gateways['VpnGateways']] - + module.exit_json(virtual_gateways=snaked_vgws) diff --git a/lib/ansible/modules/cloud/amazon/iam.py b/lib/ansible/modules/cloud/amazon/iam.py index 79a3e346221..907c96af796 100644 --- a/lib/ansible/modules/cloud/amazon/iam.py +++ b/lib/ansible/modules/cloud/amazon/iam.py @@ -457,7 +457,7 @@ def delete_group(module=None, iam=None, name=None): iam.delete_group_policy(name, policy) try: iam.delete_group(name) - except boto.exception.BotoServerError as err: + except boto.exception.BotoServerError as err: error_msg = boto_exception(err) if ('must detach all policies first') in error_msg: module.fail_json(changed=changed, msg="All inline polices have been removed. Though it appears" diff --git a/lib/ansible/modules/cloud/amazon/rds.py b/lib/ansible/modules/cloud/amazon/rds.py index d12593f3201..04f6516b825 100644 --- a/lib/ansible/modules/cloud/amazon/rds.py +++ b/lib/ansible/modules/cloud/amazon/rds.py @@ -280,7 +280,7 @@ EXAMPLES = ''' command: reboot instance_name: database wait: yes - + # Restore a Postgres db instance from a snapshot, wait for it to become available again, and # then modify it to add your security group. Also, display the new endpoint. # Note that the "publicly_accessible" option is allowed here just as it is in the AWS CLI @@ -298,7 +298,7 @@ EXAMPLES = ''' tags: Name: pg1_test_name_tag register: rds - + - local_action: module: rds command: modify @@ -844,7 +844,7 @@ def promote_db_instance(module, conn): valid_vars = ['backup_retention', 'backup_window'] params = validate_parameters(required_vars, valid_vars, module) instance_name = module.params.get('instance_name') - + result = conn.get_db_instance(instance_name) if not result: module.fail_json(msg="DB Instance %s does not exist" % instance_name) diff --git a/lib/ansible/modules/cloud/amazon/rds_subnet_group.py b/lib/ansible/modules/cloud/amazon/rds_subnet_group.py index d5ace785b7e..cf7f7f80389 100644 --- a/lib/ansible/modules/cloud/amazon/rds_subnet_group.py +++ b/lib/ansible/modules/cloud/amazon/rds_subnet_group.py @@ -130,7 +130,7 @@ def main(): except BotoServerError as e: if e.error_code != 'DBSubnetGroupNotFoundFault': module.fail_json(msg = e.error_message) - + if state == 'absent': if exists: conn.delete_db_subnet_group(group_name) diff --git a/lib/ansible/modules/cloud/amazon/route53.py b/lib/ansible/modules/cloud/amazon/route53.py index 6452fefb359..266456e15bc 100644 --- a/lib/ansible/modules/cloud/amazon/route53.py +++ b/lib/ansible/modules/cloud/amazon/route53.py @@ -470,7 +470,7 @@ def main(): if command_in == 'create': if ( weight_in!=None or region_in!=None or failover_in!=None ) and identifier_in==None: module.fail_json(msg= "If you specify failover, region or weight you must also specify identifier") - elif ( weight_in==None and region_in==None and failover_in==None ) and identifier_in!=None: + elif ( weight_in==None and region_in==None and failover_in==None ) and identifier_in!=None: module.fail_json(msg= "You have specified identifier which makes sense only if you specify one of: weight, region or failover.") diff --git a/lib/ansible/modules/cloud/amazon/s3_website.py b/lib/ansible/modules/cloud/amazon/s3_website.py index b8e1503b2d2..d81dcdf0a48 100644 --- a/lib/ansible/modules/cloud/amazon/s3_website.py +++ b/lib/ansible/modules/cloud/amazon/s3_website.py @@ -57,7 +57,7 @@ options: - "Suffix that is appended to a request that is for a directory on the website endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html). The suffix must not include a slash character." required: false default: index.html - + extends_documentation_fragment: - aws - ec2 @@ -76,14 +76,14 @@ EXAMPLES = ''' - s3_website: name: mybucket.com state: absent - + # Configure an s3 bucket as a website with index and error pages - s3_website: name: mybucket.com suffix: home.htm error_key: errors/404.htm state: present - + ''' RETURN = ''' @@ -170,7 +170,7 @@ def _create_website_configuration(suffix, error_key, redirect_all_requests): def enable_or_update_bucket_as_website(client_connection, resource_connection, module): - + bucket_name = module.params.get("name") redirect_all_requests = module.params.get("redirect_all_requests") # If redirect_all_requests is set then don't use the default suffix that has been set @@ -263,7 +263,7 @@ def main(): redirect_all_requests=dict(type='str', required=False) ) ) - + module = AnsibleModule( argument_spec=argument_spec, mutually_exclusive = [ @@ -273,7 +273,7 @@ def main(): if not HAS_BOTO3: module.fail_json(msg='boto3 required for this module') - + region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True) if region: @@ -288,7 +288,7 @@ def main(): enable_or_update_bucket_as_website(client_connection, resource_connection, module) elif state == 'absent': disable_bucket_as_website(client_connection, module) - + from ansible.module_utils.basic import * from ansible.module_utils.ec2 import * diff --git a/lib/ansible/modules/cloud/amazon/sqs_queue.py b/lib/ansible/modules/cloud/amazon/sqs_queue.py index bad72f96bb1..984a761ced7 100644 --- a/lib/ansible/modules/cloud/amazon/sqs_queue.py +++ b/lib/ansible/modules/cloud/amazon/sqs_queue.py @@ -187,7 +187,7 @@ def create_or_update_sqs_queue(connection, module): queue = connection.create_queue(queue_name) update_sqs_queue(queue, **queue_attributes) result['changed'] = True - + if not module.check_mode: result['queue_arn'] = queue.get_attributes('QueueArn')['QueueArn'] result['default_visibility_timeout'] = queue.get_attributes('VisibilityTimeout')['VisibilityTimeout'] @@ -195,7 +195,7 @@ def create_or_update_sqs_queue(connection, module): result['maximum_message_size'] = queue.get_attributes('MaximumMessageSize')['MaximumMessageSize'] result['delivery_delay'] = queue.get_attributes('DelaySeconds')['DelaySeconds'] result['receive_message_wait_time'] = queue.get_attributes('ReceiveMessageWaitTimeSeconds')['ReceiveMessageWaitTimeSeconds'] - + except BotoServerError: result['msg'] = 'Failed to create/update sqs queue due to error: ' + traceback.format_exc() module.fail_json(**result) diff --git a/lib/ansible/modules/cloud/azure/azure.py b/lib/ansible/modules/cloud/azure/azure.py index aca6e719eb7..870533c9ae8 100644 --- a/lib/ansible/modules/cloud/azure/azure.py +++ b/lib/ansible/modules/cloud/azure/azure.py @@ -365,7 +365,7 @@ def create_virtual_machine(module, azure): azure.get_role(name, name, name) except AzureMissingException: # vm does not exist; create it - + if os_type == 'linux': # Create linux configuration disable_ssh_password_authentication = not password @@ -563,7 +563,7 @@ def main(): cloud_service_raw = None if module.params.get('state') == 'absent': (changed, public_dns_name, deployment) = terminate_virtual_machine(module, azure) - + elif module.params.get('state') == 'present': # Changed is always set to true when provisioning new instances if not module.params.get('name'): diff --git a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py index 9ff235fd961..70ae31862dd 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py @@ -372,7 +372,7 @@ class AzureRMStorageBlob(AzureRMModuleBase): self.log('Create container %s' % self.container) tags = None - if not self.blob and self.tags: + if not self.blob and self.tags: # when a blob is present, then tags are assigned at the blob level tags = self.tags diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index 40010df8eba..132df72fd10 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -918,7 +918,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase): interface_dict['properties'] = nic_dict['properties'] # Expand public IPs to include config properties - for interface in result['properties']['networkProfile']['networkInterfaces']: + for interface in result['properties']['networkProfile']['networkInterfaces']: for config in interface['properties']['ipConfigurations']: if config['properties'].get('publicIPAddress'): pipid_dict = azure_id_to_dict(config['properties']['publicIPAddress']['id']) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py index 97494444eea..c5f52283ecb 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py @@ -347,7 +347,7 @@ class AzureRMVirtualNetwork(AzureRMModuleBase): try: poller = self.network_client.virtual_networks.create_or_update(self.resource_group, self.name, vnet) new_vnet = self.get_poller_result(poller) - except Exception as exc: + except Exception as exc: self.fail("Error creating or updating virtual network {0} - {1}".format(self.name, str(exc))) return virtual_network_to_dict(new_vnet) diff --git a/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py b/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py index 2aee631395d..868b6e79355 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py @@ -232,7 +232,7 @@ class AnsibleCloudStackInstanceFacts(AnsibleCloudStack): if not instance: self.module.fail_json(msg="Instance not found: %s" % self.module.params.get('name')) self.facts['cloudstack_instance'] = self.get_result(instance) - return self.facts + return self.facts def get_result(self, instance): diff --git a/lib/ansible/modules/cloud/docker/docker_image.py b/lib/ansible/modules/cloud/docker/docker_image.py index 4643c63ed69..b91ee2096ab 100644 --- a/lib/ansible/modules/cloud/docker/docker_image.py +++ b/lib/ansible/modules/cloud/docker/docker_image.py @@ -293,7 +293,7 @@ class ImageManager(DockerBaseClass): if repo_tag: self.name = repo self.tag = repo_tag - + if self.state in ['present', 'build']: self.present() elif self.state == 'absent': diff --git a/lib/ansible/modules/cloud/docker/docker_service.py b/lib/ansible/modules/cloud/docker/docker_service.py index ee7c35329f4..537d60a3486 100644 --- a/lib/ansible/modules/cloud/docker/docker_service.py +++ b/lib/ansible/modules/cloud/docker/docker_service.py @@ -639,7 +639,7 @@ class ContainerManager(DockerBaseClass): return options def cmd_up(self): - + start_deps = self.dependencies service_names = self.services detached = True @@ -943,7 +943,7 @@ class ContainerManager(DockerBaseClass): short_id=container.short_id )) result['actions'].append(service_res) - + if not self.check_mode and result['changed']: _, fd_name = tempfile.mkstemp(prefix="ansible") try: diff --git a/lib/ansible/modules/cloud/google/gc_storage.py b/lib/ansible/modules/cloud/google/gc_storage.py index 7d78d0c5058..98f0d1480dc 100644 --- a/lib/ansible/modules/cloud/google/gc_storage.py +++ b/lib/ansible/modules/cloud/google/gc_storage.py @@ -165,7 +165,7 @@ def grant_check(module, gs, obj): module.fail_json(msg= str(e)) return True - + def key_check(module, gs, bucket, obj): try: @@ -228,7 +228,7 @@ def delete_key(module, gs, bucket, obj): module.exit_json(msg="Object deleted from bucket ", changed=True) except gs.provider.storage_response_error as e: module.fail_json(msg= str(e)) - + def create_dirkey(module, gs, bucket, obj): try: bucket = gs.lookup(bucket) @@ -325,7 +325,7 @@ def handle_put(module, gs, bucket, obj, overwrite, src, expiration): module.exit_json(msg="WARNING: Checksums do not match. Use overwrite parameter to force upload.", failed=True) else: upload_gsfile(module, gs, bucket, obj, src, expiration) - + if not bucket_rc: create_bucket(module, gs, bucket) upload_gsfile(module, gs, bucket, obj, src, expiration) @@ -333,7 +333,7 @@ def handle_put(module, gs, bucket, obj, overwrite, src, expiration): # If bucket exists but key doesn't, just upload. if bucket_rc and not key_rc: upload_gsfile(module, gs, bucket, obj, src, expiration) - + def handle_delete(module, gs, bucket, obj): if bucket and not obj: if bucket_check(module, gs, bucket): @@ -350,7 +350,7 @@ def handle_delete(module, gs, bucket, obj): module.exit_json(msg="Bucket does not exist.", changed=False) else: module.fail_json(msg="Bucket or Bucket & object parameter is required.", failed=True) - + def handle_create(module, gs, bucket, obj): if bucket and not obj: if bucket_check(module, gs, bucket): @@ -417,7 +417,7 @@ def main(): gs = boto.connect_gs(gs_access_key, gs_secret_key) except boto.exception.NoAuthHandlerFound as e: module.fail_json(msg = str(e)) - + if mode == 'get': if not bucket_check(module, gs, bucket) or not key_check(module, gs, bucket, obj): module.fail_json(msg="Target bucket/key cannot be found", failed=True) @@ -425,7 +425,7 @@ def main(): download_gsfile(module, gs, bucket, obj, dest) else: handle_get(module, gs, bucket, obj, overwrite, dest) - + if mode == 'put': if not path_check(src): module.fail_json(msg="Local object for PUT does not exist", failed=True) @@ -434,10 +434,10 @@ def main(): # Support for deleting an object if we have both params. if mode == 'delete': handle_delete(module, gs, bucket, obj) - + if mode == 'create': handle_create(module, gs, bucket, obj) - + if mode == 'get_url': if bucket and obj: if bucket_check(module, gs, bucket) and key_check(module, gs, bucket, obj): diff --git a/lib/ansible/modules/cloud/google/gcdns_zone.py b/lib/ansible/modules/cloud/google/gcdns_zone.py index 683cb881899..4506bf1bda3 100644 --- a/lib/ansible/modules/cloud/google/gcdns_zone.py +++ b/lib/ansible/modules/cloud/google/gcdns_zone.py @@ -93,7 +93,7 @@ EXAMPLES = ''' # Basic zone creation example. - name: Create a basic zone with the minimum number of parameters. gcdns_zone: zone=example.com - + # Zone removal example. - name: Remove a zone. gcdns_zone: zone=example.com state=absent diff --git a/lib/ansible/modules/cloud/google/gce_img.py b/lib/ansible/modules/cloud/google/gce_img.py index e340808539a..1c14a1421f4 100644 --- a/lib/ansible/modules/cloud/google/gce_img.py +++ b/lib/ansible/modules/cloud/google/gce_img.py @@ -103,7 +103,7 @@ EXAMPLES = ''' - gce_img: name: test-image source: https://storage.googleapis.com/bucket/path/to/image.tgz - + # Alternatively use the gs scheme - gce_img: name: test-image diff --git a/lib/ansible/modules/cloud/google/gcpubsub.py b/lib/ansible/modules/cloud/google/gcpubsub.py index 027629f7407..d0c7b4c39ad 100644 --- a/lib/ansible/modules/cloud/google/gcpubsub.py +++ b/lib/ansible/modules/cloud/google/gcpubsub.py @@ -194,7 +194,7 @@ def publish_messages(message_list, topic): attrs = message['attributes'] batch.publish(bytes(msg), **attrs) return True - + def pull_messages(pull_params, sub): """ :rtype: tuple (output, changed) @@ -203,7 +203,7 @@ def pull_messages(pull_params, sub): max_messages=pull_params.get('max_messages', None) message_ack = pull_params.get('message_ack', 'no') return_immediately = pull_params.get('return_immediately', False) - + output= [] pulled = sub.pull(return_immediately=return_immediately, max_messages=max_messages) @@ -237,7 +237,7 @@ def main(): if not HAS_PYTHON26: module.fail_json( msg="GCE module requires python's 'ast' module, python v2.6+") - + if not HAS_GOOGLE_CLOUD_PUBSUB: module.fail_json(msg="Please install google-cloud-pubsub library.") diff --git a/lib/ansible/modules/cloud/google/gcpubsub_facts.py b/lib/ansible/modules/cloud/google/gcpubsub_facts.py index 08a60841f37..8484b0b3516 100644 --- a/lib/ansible/modules/cloud/google/gcpubsub_facts.py +++ b/lib/ansible/modules/cloud/google/gcpubsub_facts.py @@ -98,7 +98,7 @@ except ImportError as e: def list_func(data, member='name'): """Used for state=list.""" return [getattr(x, member) for x in data] - + def main(): module = AnsibleModule(argument_spec=dict( @@ -112,7 +112,7 @@ def main(): if not HAS_PYTHON26: module.fail_json( msg="GCE module requires python's 'ast' module, python v2.6+") - + if not HAS_GOOGLE_CLOUD_PUBSUB: module.fail_json(msg="Please install google-cloud-pubsub library.") diff --git a/lib/ansible/modules/cloud/linode/linode.py b/lib/ansible/modules/cloud/linode/linode.py index 5b45267446a..393ba0fe66d 100644 --- a/lib/ansible/modules/cloud/linode/linode.py +++ b/lib/ansible/modules/cloud/linode/linode.py @@ -247,7 +247,7 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino # - need linode_id (entity) # - need disk_id for linode_id - create disk from distrib # - need config_id for linode_id - create config (need kernel) - + # Any create step triggers a job that need to be waited for. if not servers: for arg in (name, plan, distribution, datacenter): @@ -424,7 +424,7 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino instance['status'] = 'Restarting' changed = True instances.append(instance) - + elif state in ('absent', 'deleted'): for server in servers: instance = getInstanceDetails(api, server) diff --git a/lib/ansible/modules/cloud/misc/ovirt.py b/lib/ansible/modules/cloud/misc/ovirt.py index af89998258c..048bf34bc4c 100644 --- a/lib/ansible/modules/cloud/misc/ovirt.py +++ b/lib/ansible/modules/cloud/misc/ovirt.py @@ -306,7 +306,7 @@ def create_vm(conn, vmtype, vmname, zone, vmdisk_size, vmcpus, vmnic, vmnetwork, # define network parameters network_net = params.Network(name=vmnetwork) nic_net1 = params.NIC(name=vmnic, network=network_net, interface='virtio') - + try: conn.vms.add(vmparams) except: @@ -502,7 +502,7 @@ def main(): else: vm_stop(c, vmname) module.exit_json(changed=True, msg="VM %s is shutting down" % vmname) - + if state == 'restart': if vm_status(c, vmname) == 'up': vm_restart(c, vmname) diff --git a/lib/ansible/modules/cloud/misc/proxmox_kvm.py b/lib/ansible/modules/cloud/misc/proxmox_kvm.py index 59e778aa333..9397d11ff1a 100644 --- a/lib/ansible/modules/cloud/misc/proxmox_kvm.py +++ b/lib/ansible/modules/cloud/misc/proxmox_kvm.py @@ -1038,7 +1038,7 @@ def main(): time.sleep(1) except Exception as e: module.fail_json(msg="deletion of VM %s failed with exception: %s" % ( vmid, e )) - + elif state == 'current': status = {} try: diff --git a/lib/ansible/modules/cloud/misc/virt_net.py b/lib/ansible/modules/cloud/misc/virt_net.py index 849e44a304e..8e7df65e897 100644 --- a/lib/ansible/modules/cloud/misc/virt_net.py +++ b/lib/ansible/modules/cloud/misc/virt_net.py @@ -421,7 +421,7 @@ class VirtNetwork(object): def create(self, entryid): return self.conn.create(entryid) - + def modify(self, entryid, xml): return self.conn.modify(entryid, xml) diff --git a/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py b/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py index 6d0c715090d..7568d297a69 100644 --- a/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py +++ b/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py @@ -180,7 +180,7 @@ def _add_gateway_router(neutron, module, router_id, network_id): module.fail_json(msg = "Error in adding gateway to router: %s" % e.message) return True -def _remove_gateway_router(neutron, module, router_id): +def _remove_gateway_router(neutron, module, router_id): try: neutron.remove_gateway_router(router_id) except Exception as e: diff --git a/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py b/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py index 09de7dd901b..9af05b1b44a 100644 --- a/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py +++ b/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py @@ -193,7 +193,7 @@ def _get_port_id(neutron, module, router_id, subnet_id): module.fail_json( msg = "Error in listing ports: %s" % e.message) if not ports['ports']: return None - for port in ports['ports']: + for port in ports['ports']: for subnet in port['fixed_ips']: if subnet['subnet_id'] == subnet_id: return port['id'] @@ -209,7 +209,7 @@ def _add_interface_router(neutron, module, router_id, subnet_id): module.fail_json(msg = "Error in adding interface to router: %s" % e.message) return True -def _remove_interface_router(neutron, module, router_id, subnet_id): +def _remove_interface_router(neutron, module, router_id, subnet_id): kwargs = { 'subnet_id': subnet_id } diff --git a/lib/ansible/modules/cloud/openstack/os_zone.py b/lib/ansible/modules/cloud/openstack/os_zone.py index a733d80ab22..51d59ec1955 100644 --- a/lib/ansible/modules/cloud/openstack/os_zone.py +++ b/lib/ansible/modules/cloud/openstack/os_zone.py @@ -205,7 +205,7 @@ def main(): else: if masters is None: masters = [] - + pre_update_zone = zone changed = _system_state_change(state, email, description, ttl, diff --git a/lib/ansible/modules/cloud/packet/packet_device.py b/lib/ansible/modules/cloud/packet/packet_device.py index 7a6501013d0..e1f34b1ed3a 100644 --- a/lib/ansible/modules/cloud/packet/packet_device.py +++ b/lib/ansible/modules/cloud/packet/packet_device.py @@ -346,7 +346,7 @@ def get_hostname_list(module): _msg = ("If you set count>1, you should only specify one hostname " "with the %d formatter, not a list of hostnames.") raise Exception(_msg) - + if (len(hostnames) == 1) and (count > 0): hostname_spec = hostnames[0] count_range = range(count_offset, count_offset + count) @@ -382,7 +382,7 @@ def get_device_id_list(module): raise Exception("You specified too many devices, max is %d" % MAX_DEVICES) return device_ids - + def create_single_device(module, packet_conn, hostname): @@ -430,7 +430,7 @@ def wait_for_ips(module, packet_conn, created_devices): if all_have_public_ip(refreshed): return refreshed time.sleep(5) - + raise Exception("Waiting for IP assignment timed out. Hostnames: %s" % [d.hostname for d in created_devices]) diff --git a/lib/ansible/modules/cloud/packet/packet_sshkey.py b/lib/ansible/modules/cloud/packet/packet_sshkey.py index db822648698..6f362e2bd28 100644 --- a/lib/ansible/modules/cloud/packet/packet_sshkey.py +++ b/lib/ansible/modules/cloud/packet/packet_sshkey.py @@ -204,7 +204,7 @@ def act_on_sshkeys(target_state, module, packet_conn): new_key_response = packet_conn.create_ssh_key( newkey['label'], newkey['key']) changed = True - + matching_sshkeys.append(new_key_response) else: # state is 'absent' => delete mathcing keys diff --git a/lib/ansible/modules/cloud/rackspace/rax_facts.py b/lib/ansible/modules/cloud/rackspace/rax_facts.py index 8c49e8df988..b480fb2bcfc 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_facts.py +++ b/lib/ansible/modules/cloud/rackspace/rax_facts.py @@ -101,9 +101,9 @@ def rax_facts(module, address, name, server_id): servers.append(cs.servers.get(server_id)) except Exception as e: pass - + servers[:] = [server for server in servers if server.status != "DELETED"] - + if len(servers) > 1: module.fail_json(msg='Multiple servers found matching provided ' 'search parameters') diff --git a/lib/ansible/modules/cloud/vmware/vmware_vswitch.py b/lib/ansible/modules/cloud/vmware/vmware_vswitch.py index ef14f2d6bfc..cbe5e371977 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vswitch.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vswitch.py @@ -93,7 +93,7 @@ def find_vswitch_by_name(host, vswitch_name): class VMwareHostVirtualSwitch(object): - + def __init__(self, module): self.host_system = None self.content = None @@ -132,7 +132,7 @@ class VMwareHostVirtualSwitch(object): # Source from # https://github.com/rreubenur/pyvmomi-community-samples/blob/patch-1/samples/create_vswitch.py - + def state_create_vswitch(self): vss_spec = vim.host.VirtualSwitch.Specification() vss_spec.numPorts = self.number_of_ports @@ -146,7 +146,7 @@ class VMwareHostVirtualSwitch(object): def state_destroy_vswitch(self): config = vim.host.NetworkConfig() - + for portgroup in self.host_system.configManager.networkSystem.networkInfo.portgroup: if portgroup.spec.vswitchName == self.vss.name: portgroup_config = vim.host.PortGroup.Config() @@ -158,7 +158,7 @@ class VMwareHostVirtualSwitch(object): portgroup_config.spec.vswitchName = portgroup.spec.vswitchName portgroup_config.spec.policy = vim.host.NetworkPolicy() config.portgroup.append(portgroup_config) - + self.host_system.configManager.networkSystem.UpdateNetworkConfig(config, "modify") self.host_system.configManager.networkSystem.RemoveVirtualSwitch(self.vss.name) self.module.exit_json(changed=True) @@ -170,15 +170,15 @@ class VMwareHostVirtualSwitch(object): host = get_all_objs(self.content, [vim.HostSystem]) if not host: self.module.fail_json(msg="Unable to find host") - + self.host_system = host.keys()[0] self.vss = find_vswitch_by_name(self.host_system, self.switch_name) - + if self.vss is None: return 'absent' else: return 'present' - + def main(): argument_spec = vmware_argument_spec() diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py index e7de7625d42..6bd7405bbe1 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -999,7 +999,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name except (KeyError, ValueError): vsphere_client.disconnect() module.fail_json(msg="Error in '%s' definition. Size needs to be specified as an integer." % disk) - + # Make sure the new disk size is higher than the current value dev = dev_list[disk_num] if disksize < int(dev.capacityInKB): diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_app.py b/lib/ansible/modules/cloud/webfaction/webfaction_app.py index 63c00bd1778..a9670955226 100644 --- a/lib/ansible/modules/cloud/webfaction/webfaction_app.py +++ b/lib/ansible/modules/cloud/webfaction/webfaction_app.py @@ -148,7 +148,7 @@ def main(): existing_app = app_map.get(app_name) result = {} - + # Here's where the real stuff happens if app_state == 'present': diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_db.py b/lib/ansible/modules/cloud/webfaction/webfaction_db.py index 6fe785f76a9..545176c4bf4 100644 --- a/lib/ansible/modules/cloud/webfaction/webfaction_db.py +++ b/lib/ansible/modules/cloud/webfaction/webfaction_db.py @@ -84,7 +84,7 @@ options: EXAMPLES = ''' # This will also create a default DB user with the same # name as the database, and the specified password. - + - name: Create a database webfaction_db: name: "{{webfaction_user}}_db1" @@ -145,7 +145,7 @@ def main(): existing_user = user_map.get(db_name) result = {} - + # Here's where the real stuff happens if db_state == 'present': @@ -175,16 +175,16 @@ def main(): # If this isn't a dry run... if not module.check_mode: - + if not (existing_db or existing_user): module.exit_json(changed = False,) - + if existing_db: # Delete the db if it exists result.update( webfaction.delete_db(session_id, db_name, db_type) ) - + if existing_user: # Delete the default db user if it exists result.update( diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_domain.py b/lib/ansible/modules/cloud/webfaction/webfaction_domain.py index 859209c9ce7..8c145f18cbd 100644 --- a/lib/ansible/modules/cloud/webfaction/webfaction_domain.py +++ b/lib/ansible/modules/cloud/webfaction/webfaction_domain.py @@ -121,7 +121,7 @@ def main(): existing_domain = domain_map.get(domain_name) result = {} - + # Here's where the real stuff happens if domain_state == 'present': diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py b/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py index 2132eeaffbb..84d3763a89e 100644 --- a/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py +++ b/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py @@ -107,7 +107,7 @@ def main(): existing_mailbox = mailbox_name in mailbox_list result = {} - + # Here's where the real stuff happens if site_state == 'present': diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_site.py b/lib/ansible/modules/cloud/webfaction/webfaction_site.py index 08a9b4d76d4..9f415f5f3a1 100644 --- a/lib/ansible/modules/cloud/webfaction/webfaction_site.py +++ b/lib/ansible/modules/cloud/webfaction/webfaction_site.py @@ -53,7 +53,7 @@ options: required: false choices: ['present', 'absent'] default: "present" - + host: description: - The webfaction host on which the site should be created. @@ -141,7 +141,7 @@ def main(): existing_site = site_map.get(site_name) result = {} - + # Here's where the real stuff happens if site_state == 'present': diff --git a/lib/ansible/modules/clustering/consul.py b/lib/ansible/modules/clustering/consul.py index 203704efb97..8618dbbd4ad 100644 --- a/lib/ansible/modules/clustering/consul.py +++ b/lib/ansible/modules/clustering/consul.py @@ -395,7 +395,7 @@ def parse_service(module): module.fail_json( msg="service_name supplied but no service_port, a port is required to configure a service. Did you configure the 'port' argument meaning 'service_port'?") -class ConsulService(): +class ConsulService(): def __init__(self, service_id=None, name=None, address=None, port=-1, tags=None, loaded=None): diff --git a/lib/ansible/modules/crypto/openssl_privatekey.py b/lib/ansible/modules/crypto/openssl_privatekey.py index d643142c653..8f6ea5c70d1 100644 --- a/lib/ansible/modules/crypto/openssl_privatekey.py +++ b/lib/ansible/modules/crypto/openssl_privatekey.py @@ -195,7 +195,7 @@ class PrivateKey(object): } return result - + def main(): diff --git a/lib/ansible/modules/crypto/openssl_publickey.py b/lib/ansible/modules/crypto/openssl_publickey.py index 6ac73dc975e..e6fe182c249 100644 --- a/lib/ansible/modules/crypto/openssl_publickey.py +++ b/lib/ansible/modules/crypto/openssl_publickey.py @@ -163,7 +163,7 @@ class PublicKey(object): } return result - + def main(): diff --git a/lib/ansible/modules/database/misc/elasticsearch_plugin.py b/lib/ansible/modules/database/misc/elasticsearch_plugin.py index 8a165189625..d6ade97f914 100644 --- a/lib/ansible/modules/database/misc/elasticsearch_plugin.py +++ b/lib/ansible/modules/database/misc/elasticsearch_plugin.py @@ -161,7 +161,7 @@ def install_plugin(module, plugin_bin, plugin_name, version, url, proxy_host, pr if rc != 0: reason = parse_error(out) module.fail_json(msg=reason) - + return True, cmd, out, err def remove_plugin(module, plugin_bin, plugin_name): @@ -177,7 +177,7 @@ def remove_plugin(module, plugin_bin, plugin_name): if rc != 0: reason = parse_error(out) module.fail_json(msg=reason) - + return True, cmd, out, err def main(): diff --git a/lib/ansible/modules/database/misc/kibana_plugin.py b/lib/ansible/modules/database/misc/kibana_plugin.py index f3b20386f89..77c87b6c924 100644 --- a/lib/ansible/modules/database/misc/kibana_plugin.py +++ b/lib/ansible/modules/database/misc/kibana_plugin.py @@ -181,7 +181,7 @@ def install_plugin(module, plugin_bin, plugin_name, url, timeout): if rc != 0: reason = parse_error(out) module.fail_json(msg=reason) - + return True, cmd, out, err def remove_plugin(module, plugin_bin, plugin_name): @@ -191,12 +191,12 @@ def remove_plugin(module, plugin_bin, plugin_name): if module.check_mode: return True, cmd, "check mode", "" - + rc, out, err = module.run_command(cmd) if rc != 0: reason = parse_error(out) module.fail_json(msg=reason) - + return True, cmd, out, err def main(): diff --git a/lib/ansible/modules/database/misc/redis.py b/lib/ansible/modules/database/misc/redis.py index f99d025742b..078a46ea206 100644 --- a/lib/ansible/modules/database/misc/redis.py +++ b/lib/ansible/modules/database/misc/redis.py @@ -322,7 +322,7 @@ def main(): e = get_exception() module.fail_json(msg="unable to connect to database: %s" % e) - + try: old_value = r.config_get(name)[name] except Exception: diff --git a/lib/ansible/modules/database/misc/riak.py b/lib/ansible/modules/database/misc/riak.py index af4ec9489f3..e35e08d9252 100644 --- a/lib/ansible/modules/database/misc/riak.py +++ b/lib/ansible/modules/database/misc/riak.py @@ -179,7 +179,7 @@ def main(): ring_size = stats['ring_creation_size'] rc, out, err = module.run_command([riak_bin, 'version'] ) version = out.strip() - + result = dict(node_name=node_name, nodes=nodes, ring_size=ring_size, diff --git a/lib/ansible/modules/database/mssql/mssql_db.py b/lib/ansible/modules/database/mssql/mssql_db.py index 2daf74d011e..cbd9bf03787 100644 --- a/lib/ansible/modules/database/mssql/mssql_db.py +++ b/lib/ansible/modules/database/mssql/mssql_db.py @@ -181,7 +181,7 @@ def main(): login_password = module.params['login_password'] login_host = module.params['login_host'] login_port = module.params['login_port'] - + login_querystring = login_host if login_port != "1433": login_querystring = "%s:%s" % (login_host, login_port) diff --git a/lib/ansible/modules/database/postgresql/postgresql_ext.py b/lib/ansible/modules/database/postgresql/postgresql_ext.py index 51576eb1dc0..f9987868231 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_ext.py +++ b/lib/ansible/modules/database/postgresql/postgresql_ext.py @@ -178,7 +178,7 @@ def main(): else: if state == "absent": changed = ext_delete(cursor, ext) - + elif state == "present": changed = ext_create(cursor, ext) except NotSupportedError: diff --git a/lib/ansible/modules/database/postgresql/postgresql_lang.py b/lib/ansible/modules/database/postgresql/postgresql_lang.py index 91e5732fb3b..650212f1cde 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_lang.py +++ b/lib/ansible/modules/database/postgresql/postgresql_lang.py @@ -253,21 +253,21 @@ def main(): if lang_exists(cursor, lang): lang_trusted = lang_istrusted(cursor, lang) if (lang_trusted and not trust) or (not lang_trusted and trust): - if module.check_mode: + if module.check_mode: changed = True else: changed = lang_altertrust(cursor, lang, trust) else: - if module.check_mode: + if module.check_mode: changed = True else: changed = lang_add(cursor, lang, trust) if force_trust: changed = lang_altertrust(cursor, lang, trust) - + else: if lang_exists(cursor, lang): - if module.check_mode: + if module.check_mode: changed = True kw['lang_dropped'] = True else: diff --git a/lib/ansible/modules/database/postgresql/postgresql_user.py b/lib/ansible/modules/database/postgresql/postgresql_user.py index 5376499fbeb..e2df5a809a0 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_user.py +++ b/lib/ansible/modules/database/postgresql/postgresql_user.py @@ -688,7 +688,7 @@ def main(): module.fail_json(msg=str(e)) else: if user_exists(cursor, user): - if module.check_mode: + if module.check_mode: changed = True kw['user_removed'] = True else: diff --git a/lib/ansible/modules/database/vertica/vertica_configuration.py b/lib/ansible/modules/database/vertica/vertica_configuration.py index c99627a021d..3b018f449ab 100644 --- a/lib/ansible/modules/database/vertica/vertica_configuration.py +++ b/lib/ansible/modules/database/vertica/vertica_configuration.py @@ -116,7 +116,7 @@ def get_configuration_facts(cursor, parameter_name=''): 'current_value': row.current_value, 'default_value': row.default_value} return facts - + def check(configuration_facts, parameter_name, current_value): parameter_key = parameter_name.lower() if current_value and current_value.lower() != configuration_facts[parameter_key]['current_value'].lower(): diff --git a/lib/ansible/modules/database/vertica/vertica_role.py b/lib/ansible/modules/database/vertica/vertica_role.py index aff14581a38..f11efcffaad 100644 --- a/lib/ansible/modules/database/vertica/vertica_role.py +++ b/lib/ansible/modules/database/vertica/vertica_role.py @@ -135,7 +135,7 @@ def update_roles(role_facts, cursor, role, cursor.execute("revoke {0} from {1}".format(assigned_role, role)) for assigned_role in set(required) - set(existing): cursor.execute("grant {0} to {1}".format(assigned_role, role)) - + def check(role_facts, role, assigned_roles): role_key = role.lower() if role_key not in role_facts: diff --git a/lib/ansible/modules/files/patch.py b/lib/ansible/modules/files/patch.py index e8004b8c62d..f09b7b625cf 100644 --- a/lib/ansible/modules/files/patch.py +++ b/lib/ansible/modules/files/patch.py @@ -182,7 +182,7 @@ def main(): # patch need an absolute file name p.src = os.path.abspath(p.src) - + changed = False if not is_already_applied(patch_func, p.src, p.basedir, dest_file=p.dest, binary=p.binary, strip=p.strip): try: diff --git a/lib/ansible/modules/monitoring/boundary_meter.py b/lib/ansible/modules/monitoring/boundary_meter.py index 49b3d954bfe..7ec661e7692 100644 --- a/lib/ansible/modules/monitoring/boundary_meter.py +++ b/lib/ansible/modules/monitoring/boundary_meter.py @@ -121,12 +121,12 @@ def build_url(name, apiid, action, meter_id=None, cert_type=None): elif action == "certificates": return "https://%s/%s/meters/%s/%s.pem" % (api_host, apiid, meter_id, cert_type) elif action == "tags": - return "https://%s/%s/meters/%s/tags" % (api_host, apiid, meter_id) + return "https://%s/%s/meters/%s/tags" % (api_host, apiid, meter_id) elif action == "delete": - return "https://%s/%s/meters/%s" % (api_host, apiid, meter_id) + return "https://%s/%s/meters/%s" % (api_host, apiid, meter_id) def http_request(module, name, apiid, apikey, action, data=None, meter_id=None, cert_type=None): - + if meter_id is None: url = build_url(name, apiid, action) else: diff --git a/lib/ansible/modules/monitoring/newrelic_deployment.py b/lib/ansible/modules/monitoring/newrelic_deployment.py index c8f8703230d..c671bb0d547 100644 --- a/lib/ansible/modules/monitoring/newrelic_deployment.py +++ b/lib/ansible/modules/monitoring/newrelic_deployment.py @@ -123,7 +123,7 @@ def main(): params["application_id"] = module.params["application_id"] else: module.fail_json(msg="you must set one of 'app_name' or 'application_id'") - + for item in [ "changelog", "description", "revision", "user", "appname", "environment" ]: if module.params[item]: params[item] = module.params[item] diff --git a/lib/ansible/modules/monitoring/pagerduty.py b/lib/ansible/modules/monitoring/pagerduty.py index 43d93501c16..0331155a7b6 100644 --- a/lib/ansible/modules/monitoring/pagerduty.py +++ b/lib/ansible/modules/monitoring/pagerduty.py @@ -209,7 +209,7 @@ def create(module, name, user, passwd, token, requester_id, service, hours, minu 'Content-Type' : 'application/json', } request_data = {'maintenance_window': {'start_time': start, 'end_time': end, 'description': desc, 'service_ids': service}} - + if requester_id: request_data['requester_id'] = requester_id else: @@ -235,7 +235,7 @@ def absent(module, name, user, passwd, token, requester_id, service): 'Content-Type' : 'application/json', } request_data = {} - + if requester_id: request_data['requester_id'] = requester_id else: diff --git a/lib/ansible/modules/monitoring/zabbix_host.py b/lib/ansible/modules/monitoring/zabbix_host.py index 08e34c0e6b6..3eef1d0bf1c 100644 --- a/lib/ansible/modules/monitoring/zabbix_host.py +++ b/lib/ansible/modules/monitoring/zabbix_host.py @@ -376,10 +376,10 @@ class Host(object): if host['proxy_hostid'] != proxy_id: return True - + if host['name'] != visible_name: return True - + return False # link or clear template of the host diff --git a/lib/ansible/modules/network/bigswitch/bigmon_chain.py b/lib/ansible/modules/network/bigswitch/bigmon_chain.py index a5ec935301a..6004578afaa 100755 --- a/lib/ansible/modules/network/bigswitch/bigmon_chain.py +++ b/lib/ansible/modules/network/bigswitch/bigmon_chain.py @@ -123,7 +123,7 @@ def chain(module): if state in ('absent') and not config_present: module.exit_json(changed=False) - + if state in ('present'): response = rest.put('chain[name="%s"]' % name, data={'name': name}) if response.status_code == 204: diff --git a/lib/ansible/modules/network/cloudflare_dns.py b/lib/ansible/modules/network/cloudflare_dns.py index 621e92ac1f0..81dda8bba71 100644 --- a/lib/ansible/modules/network/cloudflare_dns.py +++ b/lib/ansible/modules/network/cloudflare_dns.py @@ -391,7 +391,7 @@ class CloudflareAPI(object): error_msg += "; Failed to parse API response: {0}".format(content) # received an error status but no data with details on what failed - if (info['status'] not in [200,304]) and (result is None): + if (info['status'] not in [200,304]) and (result is None): self.module.fail_json(msg=error_msg) if not result['success']: diff --git a/lib/ansible/modules/network/dellos10/dellos10_facts.py b/lib/ansible/modules/network/dellos10/dellos10_facts.py index 679f4e10609..58851d1f009 100644 --- a/lib/ansible/modules/network/dellos10/dellos10_facts.py +++ b/lib/ansible/modules/network/dellos10/dellos10_facts.py @@ -183,14 +183,14 @@ class Default(FactsBase): return sw_name.text else: return "" - + def parse_version(self, data): sw_ver = data.find('./data/system-sw-state/sw-version/sw-version') if sw_ver is not None: return sw_ver.text else: return "" - + def parse_hostname(self, data): match = re.search(r'hostname\s+(\S+)', data, re.M) if match: @@ -224,7 +224,7 @@ class Hardware(FactsBase): self.facts['cpu_arch'] = self.parse_cpu_arch(xml_data) data = self.runner.get_command('show processes memory | grep Total') - + match = self.parse_memory(data) if match: self.facts['memtotal_mb'] = int(match[0]) / 1024 @@ -236,7 +236,7 @@ class Hardware(FactsBase): return cpu_arch.text else: return "" - + def parse_memory(self, data): return re.findall(r'\:\s*(\d+)', data, re.M) @@ -372,7 +372,7 @@ class Interfaces(FactsBase): lldp_facts[name].append(fact) return lldp_facts - + FACT_SUBSETS = dict( default=Default, hardware=Hardware, diff --git a/lib/ansible/modules/network/dellos6/dellos6_facts.py b/lib/ansible/modules/network/dellos6/dellos6_facts.py index 3ab0b2a992b..243e04ad666 100644 --- a/lib/ansible/modules/network/dellos6/dellos6_facts.py +++ b/lib/ansible/modules/network/dellos6/dellos6_facts.py @@ -327,7 +327,7 @@ class Interfaces(FactsBase): return match.group(3) if flag==1: return "null" - + def parse_type(self, key, properties): type_val, type_val_next = properties.split('--------- ------- --------------------- --------------------- --------------') flag=1 diff --git a/lib/ansible/modules/network/dnsmadeeasy.py b/lib/ansible/modules/network/dnsmadeeasy.py index 7650960e434..bba41159b94 100644 --- a/lib/ansible/modules/network/dnsmadeeasy.py +++ b/lib/ansible/modules/network/dnsmadeeasy.py @@ -31,25 +31,25 @@ options: - Account API Key. required: true default: null - + account_secret: description: - Account Secret Key. required: true default: null - + domain: description: - Domain to work with. Can be the domain name (e.g. "mydomain.com") or the numeric ID of the domain in DNS Made Easy (e.g. "839989") for faster resolution. required: true default: null - + record_name: description: - Record name to get/create/delete/update. If record_name is not specified; all records for the domain will be returned in "result" regardless of the state argument. required: false default: null - + record_type: description: - Record type. @@ -63,20 +63,20 @@ options: - "If record_value is not specified; no changes will be made and the record will be returned in 'result' (in other words, this module can be used to fetch a record's current id, type, and ttl)" required: false default: null - + record_ttl: description: - record's "Time to live". Number of seconds the record remains cached in DNS servers. required: false default: 1800 - + state: description: - whether the record should exist or not required: true choices: [ 'present', 'absent' ] default: null - + validate_certs: description: - If C(no), SSL certificates will not be validated. This should only be used @@ -89,7 +89,7 @@ options: notes: - The DNS Made Easy service requires that machines interacting with the API have the proper time and timezone set. Be sure you are within a few seconds of actual time by using NTP. - This module returns record(s) in the "result" element when 'state' is set to 'present'. This value can be be registered and used in your playbooks. - + requirements: [ hashlib, hmac ] author: "Brice Burgess (@briceburg)" ''' @@ -102,7 +102,7 @@ EXAMPLES = ''' domain: my.com state: present register: response - + # create / ensure the presence of a record - dnsmadeeasy: account_key: key @@ -130,7 +130,7 @@ EXAMPLES = ''' state: present record_name: test register: response - + # delete a record / ensure it is absent - dnsmadeeasy: account_key: key diff --git a/lib/ansible/modules/network/eos/eos_eapi.py b/lib/ansible/modules/network/eos/eos_eapi.py index 9a7a4197aeb..d54af2935c5 100644 --- a/lib/ansible/modules/network/eos/eos_eapi.py +++ b/lib/ansible/modules/network/eos/eos_eapi.py @@ -283,7 +283,7 @@ def map_config_to_obj(module): 'state': parse_state(out) } -def map_params_to_obj(module): +def map_params_to_obj(module): obj = { 'http': module.params['http'], 'http_port': module.params['http_port'], @@ -310,7 +310,7 @@ def collect_facts(module, result): for each in out[0]['urls']: intf, url = each.split(' : ') key = str(intf).strip() - if key not in facts['eos_eapi_urls']: + if key not in facts['eos_eapi_urls']: facts['eos_eapi_urls'][key] = list() facts['eos_eapi_urls'][key].append(str(url).strip()) result['ansible_facts'] = facts diff --git a/lib/ansible/modules/network/lldp.py b/lib/ansible/modules/network/lldp.py index f222d765fe9..f10c85acde6 100644 --- a/lib/ansible/modules/network/lldp.py +++ b/lib/ansible/modules/network/lldp.py @@ -38,7 +38,7 @@ EXAMPLES = ''' # Retrieve switch/port information - name: Gather information from lldp lldp: - + - name: Print each switch/port debug: msg: "{{ lldp[item]['chassis']['name'] }} / {{ lldp[item]['port']['ifalias'] }}" @@ -73,7 +73,7 @@ def gather_lldp(): current_dict = current_dict[path_component] current_dict[final] = value return output_dict - + def main(): module = AnsibleModule({}) @@ -84,7 +84,7 @@ def main(): module.exit_json(ansible_facts=data) except TypeError: module.fail_json(msg="lldpctl command failed. is lldpd running?") - + # import module snippets from ansible.module_utils.basic import * diff --git a/lib/ansible/modules/network/nxos/nxos_aaa_server.py b/lib/ansible/modules/network/nxos/nxos_aaa_server.py index 34f732993e7..964854d073f 100644 --- a/lib/ansible/modules/network/nxos/nxos_aaa_server.py +++ b/lib/ansible/modules/network/nxos/nxos_aaa_server.py @@ -492,7 +492,7 @@ def main(): ) module = get_network_module(argument_spec=argument_spec, supports_check_mode=True) - + server_type = module.params['server_type'] global_key = module.params['global_key'] encrypt_type = module.params['encrypt_type'] diff --git a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py index fd023adf9cb..6efe25f6dde 100644 --- a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py +++ b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py @@ -428,7 +428,7 @@ def _match_dict(match_list, key_map): def get_aaa_host_info(module, server_type, address): aaa_host_info = {} command = 'show run | inc {0}-server.host.{1}'.format(server_type, address) - + body = execute_show_command(command, module, command_type='cli_show_ascii') if body: @@ -574,7 +574,7 @@ def main(): results['updates'] = cmds results['changed'] = changed results['end_state'] = end_state - + module.exit_json(**results) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_af.py b/lib/ansible/modules/network/nxos/nxos_bgp_af.py index 11f1a9bfafe..a8ca2cd9930 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_af.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_af.py @@ -612,7 +612,7 @@ def get_custom_string_value(config, arg, module): elif arg.startswith('dampening'): REGEX = re.compile(r'(?:{0}\s)(?P.*)$'.format( PARAM_TO_COMMAND_KEYMAP[arg]), re.M) - if arg == 'dampen_igp_metric' or arg == 'dampening_routemap': + if arg == 'dampen_igp_metric' or arg == 'dampening_routemap': value = '' if PARAM_TO_COMMAND_KEYMAP[arg] in config: value = REGEX.search(config).group('value') diff --git a/lib/ansible/modules/network/nxos/nxos_pim.py b/lib/ansible/modules/network/nxos/nxos_pim.py index 41571522a31..c972705a997 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim.py +++ b/lib/ansible/modules/network/nxos/nxos_pim.py @@ -295,7 +295,7 @@ def main(): supports_check_mode=True) splitted_ssm_range = module.params['ssm_range'].split('.') - if len(splitted_ssm_range) != 4 and module.params['ssm_range'] != 'none': + if len(splitted_ssm_range) != 4 and module.params['ssm_range'] != 'none': module.fail_json(msg="Valid ssm_range values are multicast addresses " "or the keyword 'none'.") diff --git a/lib/ansible/modules/network/nxos/nxos_pim_interface.py b/lib/ansible/modules/network/nxos/nxos_pim_interface.py index 60cabe5b41e..4bf3a586257 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_pim_interface.py @@ -495,10 +495,10 @@ def get_interface_mode(interface, intf_type, module): def get_pim_interface(module, interface): pim_interface = {} command = 'show ip pim interface {0}'.format(interface) - + body = execute_show_command(command, module, command_type='cli_show_ascii', text=True) - + if body: if 'not running' not in body[0]: body = execute_show_command(command, module) @@ -552,7 +552,7 @@ def get_pim_interface(module, interface): return {} command = 'show run interface {0}'.format(interface) - + body = execute_show_command(command, module, command_type='cli_show_ascii') jp_configs = [] diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_location.py b/lib/ansible/modules/network/nxos/nxos_snmp_location.py index e3b90973e72..193e6afb1fd 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_location.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_location.py @@ -378,7 +378,7 @@ def main(): ) module = get_network_module(argument_spec=argument_spec, supports_check_mode=True) - + location = module.params['location'] state = module.params['state'] diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_traps.py b/lib/ansible/modules/network/nxos/nxos_snmp_traps.py index a3a88191ffb..cbc7a501bec 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_traps.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_traps.py @@ -463,7 +463,7 @@ def main(): ) module = get_network_module(argument_spec=argument_spec, supports_check_mode=True) - + group = module.params['group'].lower() state = module.params['state'] diff --git a/lib/ansible/modules/network/wakeonlan.py b/lib/ansible/modules/network/wakeonlan.py index e5a38c20df1..08bd3b5d801 100644 --- a/lib/ansible/modules/network/wakeonlan.py +++ b/lib/ansible/modules/network/wakeonlan.py @@ -97,7 +97,7 @@ def wakeonlan(module, mac, broadcast, port): int(mac, 16) except ValueError: module.fail_json(msg="Incorrect MAC address format: %s" % mac_orig) - + # Create payload for magic packet data = '' padding = ''.join(['FFFFFFFFFFFF', mac * 20]) diff --git a/lib/ansible/modules/notification/flowdock.py b/lib/ansible/modules/notification/flowdock.py index e0584295afa..2d133f9ded3 100644 --- a/lib/ansible/modules/notification/flowdock.py +++ b/lib/ansible/modules/notification/flowdock.py @@ -142,7 +142,7 @@ def main(): url = "https://api.flowdock.com/v1/messages/team_inbox/%s" % (token) else: url = "https://api.flowdock.com/v1/messages/chat/%s" % (token) - + params = {} # required params diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index 5637680cd9a..796ef979c8a 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -782,7 +782,7 @@ def get_cache(module): else: module.fail_json(msg=str(e)) return cache - + def main(): module = AnsibleModule( diff --git a/lib/ansible/modules/packaging/os/apt_rpm.py b/lib/ansible/modules/packaging/os/apt_rpm.py index fe7a78990fd..e0d0e2ca50f 100755 --- a/lib/ansible/modules/packaging/os/apt_rpm.py +++ b/lib/ansible/modules/packaging/os/apt_rpm.py @@ -110,7 +110,7 @@ def update_package_db(module): module.fail_json(msg="could not update package db: %s" % err) def remove_packages(module, packages): - + remove_c = 0 # Using a for loop in case of error, we can report the package that failed for package in packages: @@ -122,7 +122,7 @@ def remove_packages(module, packages): if rc != 0: module.fail_json(msg="failed to remove %s: %s" % (package, err)) - + remove_c += 1 if remove_c > 0: @@ -162,7 +162,7 @@ def main(): state = dict(default='installed', choices=['installed', 'removed', 'absent', 'present']), update_cache = dict(default=False, aliases=['update-cache'], type='bool'), package = dict(aliases=['pkg', 'name'], required=True))) - + if not os.path.exists(APT_PATH) or not os.path.exists(RPM_PATH): module.fail_json(msg="cannot find /usr/bin/apt-get and/or /usr/bin/rpm") @@ -182,6 +182,6 @@ def main(): # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * - + if __name__ == '__main__': main() diff --git a/lib/ansible/modules/packaging/os/layman.py b/lib/ansible/modules/packaging/os/layman.py index 440001b48a0..f18189f69c1 100644 --- a/lib/ansible/modules/packaging/os/layman.py +++ b/lib/ansible/modules/packaging/os/layman.py @@ -158,7 +158,7 @@ def install_overlay(module, name, list_url=None): if layman.is_installed(name): return False - + if module.check_mode: mymsg = 'Would add layman repo \'' + name + '\'' module.exit_json(changed=True, msg=mymsg) @@ -195,7 +195,7 @@ def uninstall_overlay(module, name): if not layman.is_installed(name): return False - + if module.check_mode: mymsg = 'Would remove layman repo \'' + name + '\'' module.exit_json(changed=True, msg=mymsg) diff --git a/lib/ansible/modules/packaging/os/rhn_channel.py b/lib/ansible/modules/packaging/os/rhn_channel.py index c2e87f1bd91..5f35a3f78a7 100644 --- a/lib/ansible/modules/packaging/os/rhn_channel.py +++ b/lib/ansible/modules/packaging/os/rhn_channel.py @@ -144,18 +144,18 @@ def main(): saturl = module.params['url'] user = module.params['user'] password = module.params['password'] - + #initialize connection client = xmlrpclib.Server(saturl, verbose=0) session = client.auth.login(user, password) - + # get systemid sys_id = get_systemid(client, session, systname) # 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) diff --git a/lib/ansible/modules/packaging/os/urpmi.py b/lib/ansible/modules/packaging/os/urpmi.py index beae17d13da..597fc2eaa50 100644 --- a/lib/ansible/modules/packaging/os/urpmi.py +++ b/lib/ansible/modules/packaging/os/urpmi.py @@ -119,10 +119,10 @@ def update_package_db(module): rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: module.fail_json(msg="could not update package db") - + def remove_packages(module, packages): - + remove_c = 0 # Using a for loop in case of error, we can report the package that failed for package in packages: @@ -135,7 +135,7 @@ def remove_packages(module, packages): if rc != 0: module.fail_json(msg="failed to remove %s" % (package)) - + remove_c += 1 if remove_c > 0: @@ -189,7 +189,7 @@ def main(): force = dict(default=True, type='bool'), no_recommends = dict(default=True, aliases=['no-recommends'], type='bool'), package = dict(aliases=['pkg', 'name'], required=True))) - + if not os.path.exists(URPMI_PATH): module.fail_json(msg="cannot find urpmi, looking for %s" % (URPMI_PATH)) @@ -212,6 +212,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * - + if __name__ == '__main__': main() diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 8a626d7c324..6f42b963942 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -390,12 +390,12 @@ def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, di except Exception: e = get_exception() module.fail_json(msg="Failure talking to yum: %s" % e) - + return [ po_to_nevra(p) for p in pkgs ] else: myrepoq = list(repoq) - + r_cmd = ['--disablerepo', ','.join(dis_repos)] myrepoq.extend(r_cmd) @@ -442,7 +442,7 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, dis_r for pkg in pkgs: if pkg in updates: retpkgs.append(pkg) - + return set([ po_to_nevra(p) for p in retpkgs ]) else: @@ -455,12 +455,12 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, dis_r cmd = myrepoq + ["--pkgnarrow=updates", "--qf", qf, pkgspec] rc,out,err = module.run_command(cmd) - + if rc == 0: return set([ p for p in out.split('\n') if p.strip() ]) else: module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err)) - + return set() def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=None, dis_repos=None, installroot='/'): @@ -725,7 +725,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i if is_installed(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot): found = True res['results'].append('package providing %s is already installed' % (spec)) - + if found: continue diff --git a/lib/ansible/modules/packaging/os/zypper.py b/lib/ansible/modules/packaging/os/zypper.py index 8628d52c270..5b36489d5a4 100644 --- a/lib/ansible/modules/packaging/os/zypper.py +++ b/lib/ansible/modules/packaging/os/zypper.py @@ -373,7 +373,7 @@ def package_present(m, name, want_latest): def package_update_all(m): "run update or patch on all available packages" - + retvals = {'rc': 0, 'stdout': '', 'stderr': ''} if m.params['type'] == 'patch': cmdname = 'patch' diff --git a/lib/ansible/modules/packaging/os/zypper_repository.py b/lib/ansible/modules/packaging/os/zypper_repository.py index 97ca36100b8..adad2bc195d 100644 --- a/lib/ansible/modules/packaging/os/zypper_repository.py +++ b/lib/ansible/modules/packaging/os/zypper_repository.py @@ -142,7 +142,7 @@ EXAMPLES = ''' - zypper_repository: repo: 'http://download.opensuse.org/repositories/systemsmanagement/openSUSE_Leap_42.1/' auto_import_keys: yes - + # Force refresh of a repository - zypper_repository: repo: 'http://my_internal_ci_repo/repo diff --git a/lib/ansible/modules/remote_management/foreman/katello.py b/lib/ansible/modules/remote_management/foreman/katello.py index 5679ad229d1..6d2bf446aea 100644 --- a/lib/ansible/modules/remote_management/foreman/katello.py +++ b/lib/ansible/modules/remote_management/foreman/katello.py @@ -243,7 +243,7 @@ class NailGun(object): return True except Exception: e = get_exception() - + if "Import is the same as existing data" in e.message: return False else: @@ -263,7 +263,7 @@ class NailGun(object): product.create() return True - + def sync_product(self, params): org = self.find_organization(params['organization']) product = self.find_product(params['name'], org.name) @@ -287,7 +287,7 @@ class NailGun(object): repository.create() return True - + def sync_repository(self, params): org = self.find_organization(params['organization']) repository = self.find_repository(params['name'], params['product'], org.name) @@ -357,7 +357,7 @@ class NailGun(object): for name in products: product = self.find_product(name, org.name) ids.append(product.id) - + sync_plan.add_products(data={'product_ids': ids}) return True @@ -373,7 +373,7 @@ class NailGun(object): content_view.update() else: content_view = content_view.create() - + if params['repositories']: repos = [] diff --git a/lib/ansible/modules/remote_management/stacki/stacki_host.py b/lib/ansible/modules/remote_management/stacki/stacki_host.py index e4d95febc1d..cf971d37e45 100644 --- a/lib/ansible/modules/remote_management/stacki/stacki_host.py +++ b/lib/ansible/modules/remote_management/stacki/stacki_host.py @@ -127,7 +127,7 @@ class StackiHost: auth_creds = {'USERNAME': module.params['stacki_user'], 'PASSWORD': module.params['stacki_password']} - + # Get Intial CSRF cred_a = self.do_request(self.module, self.endpoint, method="GET") cookie_a = cred_a.headers.get('Set-Cookie').split(';') @@ -144,7 +144,7 @@ class StackiHost: # Endpoint to get final authentication header login_endpoint = self.endpoint + "/login" - + # Get Final CSRF and Session ID login_req = self.do_request(self.module, login_endpoint, headers=header, payload=urllib.urlencode(auth_creds), method="POST") @@ -175,41 +175,41 @@ class StackiHost: def stack_check_host(self): - + res = self.do_request(self.module, self.endpoint, payload=json.dumps({"cmd": "list host"}), headers=self.header, method="POST") - + if self.hostname in res.read(): return True else: return False - - + + def stack_sync(self): - + res = self.do_request(self.module, self.endpoint, payload=json.dumps({ "cmd": "sync config"}), headers=self.header, method="POST") - + res = self.do_request(self.module, self.endpoint, payload=json.dumps({"cmd": "sync host config"}), headers=self.header, method="POST") - + def stack_force_install(self): - + data = dict() changed = False - + data['cmd'] = "set host boot {0} action=install" \ .format(self.hostname) res = self.do_request(self.module, self.endpoint, payload=json.dumps(data), headers=self.header, method="POST") changed = True - + self.stack_sync() - + result['changed'] = changed result['stdout'] = "api call successful".rstrip("\r\n") - + def stack_add_interface(self): @@ -217,35 +217,35 @@ class StackiHost: .format(self.hostname, self.prim_intf, self.prim_intf_ip, self.network, self.prim_intf_mac) res = self.do_request(self.module, self.endpoint, payload=json.dumps(data), headers=self.header, method="POST") - + def stack_add(self, result): - + data = dict() changed = False - + data['cmd'] = "add host {0} rack={1} rank={2} appliance={3}"\ .format(self.hostname, self.rack, self.rank, self.appliance) res = self.do_request(self.module, self.endpoint, payload=json.dumps(data), headers=self.header, method="POST") - + self.stack_sync() - + result['changed'] = changed result['stdout'] = "api call successful".rstrip("\r\n") - - + + def stack_remove(self, result): - + data = dict() - + data['cmd'] = "remove host {0}"\ .format(self.hostname) res = self.do_request(self.module, self.endpoint, payload=json.dumps(data), headers=self.header, method="POST") - + self.stack_sync() - + result['changed'] = True result['stdout'] = "api call successful".rstrip("\r\n") diff --git a/lib/ansible/modules/source_control/github_hooks.py b/lib/ansible/modules/source_control/github_hooks.py index 37ed6982614..56bf49fdb6f 100644 --- a/lib/ansible/modules/source_control/github_hooks.py +++ b/lib/ansible/modules/source_control/github_hooks.py @@ -118,7 +118,7 @@ def _clean504(module, hookurl, oauthkey, repo, user): # print "Last response was an ERROR for hook:" # print hook['id'] _delete(module, hookurl, oauthkey, repo, user, hook['id']) - + return 0, current_hooks def _cleanall(module, hookurl, oauthkey, repo, user): @@ -130,7 +130,7 @@ def _cleanall(module, hookurl, oauthkey, repo, user): # print "Last response was an ERROR for hook:" # print hook['id'] _delete(module, hookurl, oauthkey, repo, user, hook['id']) - + return 0, current_hooks def _create(module, hookurl, oauthkey, repo, user, content_type): diff --git a/lib/ansible/modules/system/group.py b/lib/ansible/modules/system/group.py index 132d71ad2d3..4242e6e008e 100644 --- a/lib/ansible/modules/system/group.py +++ b/lib/ansible/modules/system/group.py @@ -302,7 +302,7 @@ class DarwinGroup(Group): (rc, out, err) = self.execute_command(cmd) return (rc, out, err) return (None, '', '') - + def get_lowest_available_system_gid(self): # check for lowest available system gid (< 500) try: diff --git a/lib/ansible/modules/system/locale_gen.py b/lib/ansible/modules/system/locale_gen.py index 8e6a1835e2c..ad94f8093f4 100644 --- a/lib/ansible/modules/system/locale_gen.py +++ b/lib/ansible/modules/system/locale_gen.py @@ -154,14 +154,14 @@ def apply_change(targetState, name): else: # Delete locale. set_locale(name, enabled=False) - + localeGenExitValue = call("locale-gen") if localeGenExitValue!=0: raise EnvironmentError(localeGenExitValue, "locale.gen failed to execute, it returned "+str(localeGenExitValue)) def apply_change_ubuntu(targetState, name): """Create or remove locale. - + Keyword arguments: targetState -- Desired state, either present or absent. name -- Name including encoding such as de_CH.UTF-8. @@ -188,7 +188,7 @@ def apply_change_ubuntu(targetState, name): # Purge locales and regenerate. # Please provide a patch if you know how to avoid regenerating the locales to keep! localeGenExitValue = call(["locale-gen", "--purge"]) - + if localeGenExitValue!=0: raise EnvironmentError(localeGenExitValue, "locale.gen failed to execute, it returned "+str(localeGenExitValue)) @@ -227,7 +227,7 @@ def main(): else: prev_state = "absent" changed = (prev_state!=state) - + if module.check_mode: module.exit_json(changed=changed) else: diff --git a/lib/ansible/modules/system/pam_limits.py b/lib/ansible/modules/system/pam_limits.py index ab508c57275..f730924d9a7 100644 --- a/lib/ansible/modules/system/pam_limits.py +++ b/lib/ansible/modules/system/pam_limits.py @@ -272,7 +272,7 @@ def main(): nf.close() except: pass - + res_args = dict( changed = changed, msg = message ) diff --git a/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py index a4031a6b2a5..8a270b43870 100644 --- a/lib/ansible/modules/system/sysctl.py +++ b/lib/ansible/modules/system/sysctl.py @@ -279,7 +279,7 @@ class SysctlModule(object): sysctl_args = [self.sysctl_cmd, '-p', self.sysctl_file] if self.args['ignoreerrors']: sysctl_args.insert(1, '-e') - + rc,out,err = self.module.run_command(sysctl_args) if rc != 0: diff --git a/lib/ansible/modules/web_infrastructure/jira.py b/lib/ansible/modules/web_infrastructure/jira.py index 7e58b5cfb19..64877f0f6e6 100755 --- a/lib/ansible/modules/web_infrastructure/jira.py +++ b/lib/ansible/modules/web_infrastructure/jira.py @@ -417,7 +417,7 @@ def main(): # Dispatch try: - + # Lookup the corresponding method for this operation. This is # safe as the AnsibleModule should remove any unknown operations. thismod = sys.modules[__name__] diff --git a/lib/ansible/modules/web_infrastructure/letsencrypt.py b/lib/ansible/modules/web_infrastructure/letsencrypt.py index 7e8f76329da..0027cb6e707 100644 --- a/lib/ansible/modules/web_infrastructure/letsencrypt.py +++ b/lib/ansible/modules/web_infrastructure/letsencrypt.py @@ -775,7 +775,7 @@ def main(): ), supports_check_mode = True, ) - + # AnsibleModule() changes the locale, so change it back to C because we rely on time.strptime() when parsing certificate dates. locale.setlocale(locale.LC_ALL, "C") diff --git a/lib/ansible/modules/windows/win_package.py b/lib/ansible/modules/windows/win_package.py index bea20fe6758..f66364aeb70 100644 --- a/lib/ansible/modules/windows/win_package.py +++ b/lib/ansible/modules/windows/win_package.py @@ -100,7 +100,7 @@ EXAMPLES = r''' path: https://download.microsoft.com/download/A/F/0/AF0071F3-B198-4A35-AA90-C68D103BDCCF/rdcman.msi product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}' state: absent - + # Specify the expected non-zero return code when successful # In this case 3010 indicates 'reboot required' - name: 'Microsoft .NET Framework 4.5.1' diff --git a/lib/ansible/modules/windows/win_stat.py b/lib/ansible/modules/windows/win_stat.py index 73c8e436839..5f7140fbc2c 100644 --- a/lib/ansible/modules/windows/win_stat.py +++ b/lib/ansible/modules/windows/win_stat.py @@ -192,7 +192,7 @@ stat: type: string sample: BUILTIN\\Administrators sharename: - description: the name of share if folder is shared + description: the name of share if folder is shared returned: success, path exists, file is a directory and isshared == True type: string sample: file-share diff --git a/lib/ansible/playbook/role/metadata.py b/lib/ansible/playbook/role/metadata.py index dfbe20b632b..d62f2526acb 100644 --- a/lib/ansible/playbook/role/metadata.py +++ b/lib/ansible/playbook/role/metadata.py @@ -69,7 +69,7 @@ class RoleMetadata(Base): if ds: if not isinstance(ds, list): raise AnsibleParserError("Expected role dependencies to be a list.", obj=self._ds) - + for role_def in ds: if isinstance(role_def, string_types) or 'role' in role_def or 'name' in role_def: roles.append(role_def) @@ -86,7 +86,7 @@ class RoleMetadata(Base): current_role_path = None if self._owner: current_role_path = os.path.dirname(self._owner._role_path) - + try: return load_list_of_roles(roles, play=self._owner._play, current_role_path=current_role_path, variable_manager=self._variable_manager, loader=self._loader) except AssertionError: diff --git a/lib/ansible/playbook/role_include.py b/lib/ansible/playbook/role_include.py index 0ba26c90e6c..4ed9369cbae 100644 --- a/lib/ansible/playbook/role_include.py +++ b/lib/ansible/playbook/role_include.py @@ -108,7 +108,7 @@ class IncludeRole(Task): # build options for role includes for key in ['tasks', 'vars', 'defaults']: from_key ='%s_from' % key - if ir.args.get(from_key): + if ir.args.get(from_key): ir._from_files[key] = basename(ir.args.get(from_key)) #FIXME: find a way to make this list come from object ( attributes does not work as per below) diff --git a/lib/ansible/plugins/action/package.py b/lib/ansible/plugins/action/package.py index 0b725759a9e..45fb85abd2b 100644 --- a/lib/ansible/plugins/action/package.py +++ b/lib/ansible/plugins/action/package.py @@ -51,7 +51,7 @@ class ActionModule(ActionBase): if module == 'auto': facts = self._execute_module(module_name='setup', module_args=dict(filter='ansible_pkg_mgr', gather_subset='!all'), task_vars=task_vars) display.debug("Facts %s" % facts) - if 'ansible_facts' in facts and 'ansible_pkg_mgr' in facts['ansible_facts']: + if 'ansible_facts' in facts and 'ansible_pkg_mgr' in facts['ansible_facts']: module = getattr(facts['ansible_facts'], 'ansible_pkg_mgr', 'auto') if module != 'auto': diff --git a/lib/ansible/plugins/action/service.py b/lib/ansible/plugins/action/service.py index b6caf67ac9c..33ec6de35fa 100644 --- a/lib/ansible/plugins/action/service.py +++ b/lib/ansible/plugins/action/service.py @@ -50,7 +50,7 @@ class ActionModule(ActionBase): if module == 'auto': facts = self._execute_module(module_name='setup', module_args=dict(gather_subset='!all', filter='ansible_service_mgr'), task_vars=task_vars) self._display.debug("Facts %s" % facts) - if 'ansible_facts' in facts and 'ansible_service_mgr' in facts['ansible_facts']: + if 'ansible_facts' in facts and 'ansible_service_mgr' in facts['ansible_facts']: module = facts['ansible_facts']['ansible_service_mgr'] if not module or module == 'auto' or module not in self._shared_loader_obj.module_loader: diff --git a/lib/ansible/plugins/callback/jabber.py b/lib/ansible/plugins/callback/jabber.py index d06016d7150..ff839716fff 100644 --- a/lib/ansible/plugins/callback/jabber.py +++ b/lib/ansible/plugins/callback/jabber.py @@ -66,7 +66,7 @@ class CallbackModule(CallbackBase): def v2_runner_on_ok(self, result): self._clean_results(result._result, result._task.action) self.debug = self._dump_results(result._result) - + def v2_playbook_on_task_start(self, task, is_conditional): self.task = task diff --git a/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py index e93b97b568b..85257ca1705 100644 --- a/lib/ansible/plugins/callback/syslog_json.py +++ b/lib/ansible/plugins/callback/syslog_json.py @@ -18,7 +18,7 @@ class CallbackModule(CallbackBase): make sure you have in ansible.cfg: callback_plugins = and put the plugin in - + This plugin makes use of the following environment variables: SYSLOG_SERVER (optional): defaults to localhost SYSLOG_PORT (optional): defaults to 514 diff --git a/lib/ansible/plugins/connection/iocage.py b/lib/ansible/plugins/connection/iocage.py index d6a960cb5c2..89d648b4a7e 100644 --- a/lib/ansible/plugins/connection/iocage.py +++ b/lib/ansible/plugins/connection/iocage.py @@ -56,7 +56,7 @@ class Connection(Jail): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - + stdout, stderr = p.communicate() # otherwise p.returncode would not be set p.wait() diff --git a/lib/ansible/plugins/lookup/first_found.py b/lib/ansible/plugins/lookup/first_found.py index 36e86188d13..fc302bf26e7 100644 --- a/lib/ansible/plugins/lookup/first_found.py +++ b/lib/ansible/plugins/lookup/first_found.py @@ -47,7 +47,7 @@ __metaclass__ = type # /tmp/staging/foo # ${inventory_hostname} # bar - + # - name: copy first existing file found to /some/file # action: copy src=$item dest=/some/file # with_first_found: diff --git a/lib/ansible/plugins/lookup/hashi_vault.py b/lib/ansible/plugins/lookup/hashi_vault.py index e1953fea184..74719967bc5 100644 --- a/lib/ansible/plugins/lookup/hashi_vault.py +++ b/lib/ansible/plugins/lookup/hashi_vault.py @@ -48,11 +48,11 @@ class HashiVault: raise AnsibleError("Please pip install hvac to use this module") self.url = kwargs.get('url', ANSIBLE_HASHI_VAULT_ADDR) - + self.token = kwargs.get('token') if self.token==None: raise AnsibleError("No Vault Token specified") - + # split secret arg, which has format 'secret/hello:value' into secret='secret/hello' and secret_field='value' s = kwargs.get('secret') if s==None: @@ -76,13 +76,13 @@ class HashiVault: data = self.client.read(self.secret) if data is None: raise AnsibleError("The secret %s doesn't seem to exist" % self.secret) - + if self.secret_field=='': # secret was specified with trailing ':' return data['data'] - + if self.secret_field not in data['data']: raise AnsibleError("The secret %s does not contain the field '%s'. " % (self.secret, self.secret_field)) - + return data['data'][self.secret_field] @@ -105,6 +105,6 @@ class LookupModule(LookupBase): key = term.split()[0] value = vault_conn.get() ret.append(value) - + return ret - + diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 08ae4ca9a7a..5451108241e 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -322,7 +322,7 @@ class StrategyBase: # get the original host and task. We then assign them to the TaskResult for use in callbacks/etc. original_host = get_original_host(task_result._host) original_task = iterator.get_original_task(original_host, task_result._task) - + task_result._host = original_host task_result._task = original_task @@ -662,7 +662,7 @@ class StrategyBase: if group_name not in host.get_groups(): new_group.add_host(real_host) changed = True - + if changed: # clear cache of group dict, which is used in magic host variables self._inventory.clear_group_dict_cache() @@ -899,7 +899,7 @@ class StrategyBase: elif meta_action == 'end_play': if _evaluate_conditional(target_host): for host in self._inventory.get_hosts(iterator._play.hosts): - if not host.name in self._tqm._unreachable_hosts: + if not host.name in self._tqm._unreachable_hosts: iterator._host_states[host.name].run_state = iterator.ITERATING_COMPLETE msg="ending play" #elif meta_action == 'reset_connection': diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index dfa3131c66a..70dd6ad0e49 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -371,7 +371,7 @@ class VariableManager: # special case for the 'environment' magic variable, as someone # may have set it as a variable and we don't want to stomp on it if task: - if 'environment' not in all_vars: + if 'environment' not in all_vars: all_vars['environment'] = task.environment else: display.warning("The variable 'environment' appears to be used already, which is also used internally for environment variables set on the task/block/play. You should use a different variable name to avoid conflicts with this internal variable") diff --git a/test/integration/cleanup_ec2.py b/test/integration/cleanup_ec2.py index 559a5c0ae1a..64178394a67 100644 --- a/test/integration/cleanup_ec2.py +++ b/test/integration/cleanup_ec2.py @@ -75,10 +75,10 @@ def prompt_and_delete(item, prompt, assumeyes): assumeyes = raw_input(prompt).lower() == 'y' assert hasattr(item, 'delete') or hasattr(item, 'terminate') , "Class <%s> has no delete or terminate attribute" % item.__class__ if assumeyes: - if hasattr(item, 'delete'): + if hasattr(item, 'delete'): item.delete() print ("Deleted %s" % item) - if hasattr(item, 'terminate'): + if hasattr(item, 'terminate'): item.terminate() print ("Terminated %s" % item) diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index f7170762ee9..16013a74292 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -6,7 +6,6 @@ contrib/inventory/consul_io.py contrib/inventory/digital_ocean.py contrib/inventory/docker.py contrib/inventory/ec2.py -contrib/inventory/fleet.py contrib/inventory/freeipa.py contrib/inventory/gce.py contrib/inventory/linode.py @@ -16,7 +15,6 @@ contrib/inventory/rax.py contrib/inventory/softlayer.py contrib/inventory/spacewalk.py contrib/inventory/ssh_config.py -contrib/inventory/stacki.py contrib/inventory/vbox.py contrib/inventory/vmware_inventory.py contrib/inventory/windows_azure.py @@ -27,7 +25,6 @@ docs/docsite/conf.py docs/docsite/rst/conf.py docs/docsite/rst/dev_guide/conf.py examples/scripts/uptime.py -hacking/dump_playbook_attributes.py hacking/metadata-tool.py hacking/module_formatter.py hacking/tests/gen_distribution_version_testcase.py @@ -142,16 +139,13 @@ lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py lib/ansible/modules/cloud/azure/azure_rm_securitygroup_facts.py -lib/ansible/modules/cloud/azure/azure_rm_storageblob.py lib/ansible/modules/cloud/azure/azure_rm_subnet.py lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py -lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py lib/ansible/modules/cloud/centurylink/clc_loadbalancer.py lib/ansible/modules/cloud/cloudscale/cloudscale_server.py lib/ansible/modules/cloud/cloudstack/cs_firewall.py lib/ansible/modules/cloud/cloudstack/cs_host.py lib/ansible/modules/cloud/cloudstack/cs_instance.py -lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py lib/ansible/modules/cloud/cloudstack/cs_iso.py lib/ansible/modules/cloud/cloudstack/cs_portforward.py lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py @@ -163,7 +157,6 @@ lib/ansible/modules/cloud/docker/docker_image.py lib/ansible/modules/cloud/docker/docker_service.py lib/ansible/modules/cloud/google/gc_storage.py lib/ansible/modules/cloud/google/gcdns_record.py -lib/ansible/modules/cloud/google/gcdns_zone.py lib/ansible/modules/cloud/google/gce_img.py lib/ansible/modules/cloud/google/gce_lb.py lib/ansible/modules/cloud/google/gce_mig.py @@ -212,7 +205,6 @@ lib/ansible/modules/cloud/profitbricks/profitbricks_volume_attachments.py lib/ansible/modules/cloud/rackspace/rax_cbs.py lib/ansible/modules/cloud/rackspace/rax_cbs_attachments.py lib/ansible/modules/cloud/rackspace/rax_clb.py -lib/ansible/modules/cloud/rackspace/rax_facts.py lib/ansible/modules/cloud/rackspace/rax_identity.py lib/ansible/modules/cloud/rackspace/rax_network.py lib/ansible/modules/cloud/rackspace/rax_queue.py @@ -220,7 +212,6 @@ lib/ansible/modules/cloud/softlayer/sl_vm.py lib/ansible/modules/cloud/vmware/vca_fw.py lib/ansible/modules/cloud/vmware/vmware_guest.py lib/ansible/modules/cloud/vmware/vmware_local_user_manager.py -lib/ansible/modules/cloud/vmware/vmware_vswitch.py lib/ansible/modules/cloud/vmware/vsphere_copy.py lib/ansible/modules/cloud/vmware/vsphere_guest.py lib/ansible/modules/cloud/webfaction/webfaction_app.py @@ -234,10 +225,8 @@ lib/ansible/modules/clustering/consul_kv.py lib/ansible/modules/clustering/consul_session.py lib/ansible/modules/commands/command.py lib/ansible/modules/commands/script.py -lib/ansible/modules/crypto/openssl_privatekey.py lib/ansible/modules/crypto/openssl_publickey.py lib/ansible/modules/database/influxdb/influxdb_retention_policy.py -lib/ansible/modules/database/misc/elasticsearch_plugin.py lib/ansible/modules/database/misc/kibana_plugin.py lib/ansible/modules/database/misc/mongodb_parameter.py lib/ansible/modules/database/misc/mongodb_user.py @@ -254,7 +243,6 @@ lib/ansible/modules/database/postgresql/postgresql_lang.py lib/ansible/modules/database/postgresql/postgresql_privs.py lib/ansible/modules/database/postgresql/postgresql_schema.py lib/ansible/modules/database/postgresql/postgresql_user.py -lib/ansible/modules/database/vertica/vertica_configuration.py lib/ansible/modules/database/vertica/vertica_role.py lib/ansible/modules/database/vertica/vertica_schema.py lib/ansible/modules/database/vertica/vertica_user.py @@ -280,7 +268,6 @@ lib/ansible/modules/monitoring/logicmonitor.py lib/ansible/modules/monitoring/logicmonitor_facts.py lib/ansible/modules/monitoring/monit.py lib/ansible/modules/monitoring/nagios.py -lib/ansible/modules/monitoring/newrelic_deployment.py lib/ansible/modules/monitoring/pagerduty.py lib/ansible/modules/monitoring/pagerduty_alert.py lib/ansible/modules/monitoring/pingdom.py @@ -297,7 +284,6 @@ lib/ansible/modules/network/a10/a10_virtual_server.py lib/ansible/modules/network/basics/get_url.py lib/ansible/modules/network/basics/slurp.py lib/ansible/modules/network/basics/uri.py -lib/ansible/modules/network/bigswitch/bigmon_chain.py lib/ansible/modules/network/cloudengine/ce_command.py lib/ansible/modules/network/cloudflare_dns.py lib/ansible/modules/network/dellos10/dellos10_facts.py @@ -307,7 +293,6 @@ lib/ansible/modules/network/dellos9/dellos9_config.py lib/ansible/modules/network/dellos9/dellos9_facts.py lib/ansible/modules/network/dnsimple.py lib/ansible/modules/network/dnsmadeeasy.py -lib/ansible/modules/network/eos/eos_eapi.py lib/ansible/modules/network/exoscale/exo_dns_record.py lib/ansible/modules/network/f5/bigip_facts.py lib/ansible/modules/network/f5/bigip_monitor_tcp.py @@ -382,7 +367,6 @@ lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py lib/ansible/modules/network/ovs/openvswitch_port.py lib/ansible/modules/network/panos/panos_nat_policy.py lib/ansible/modules/network/snmp_facts.py -lib/ansible/modules/network/wakeonlan.py lib/ansible/modules/notification/flowdock.py lib/ansible/modules/notification/hall.py lib/ansible/modules/notification/irc.py @@ -507,13 +491,10 @@ lib/ansible/playbook/play_context.py lib/ansible/playbook/playbook_include.py lib/ansible/playbook/role/__init__.py lib/ansible/playbook/role/metadata.py -lib/ansible/playbook/role_include.py lib/ansible/playbook/taggable.py lib/ansible/plugins/action/__init__.py lib/ansible/plugins/action/add_host.py lib/ansible/plugins/action/async.py -lib/ansible/plugins/action/package.py -lib/ansible/plugins/action/service.py lib/ansible/plugins/action/set_fact.py lib/ansible/plugins/action/set_stats.py lib/ansible/plugins/action/synchronize.py @@ -522,14 +503,12 @@ lib/ansible/plugins/cache/jsonfile.py lib/ansible/plugins/callback/default.py lib/ansible/plugins/callback/dense.py lib/ansible/plugins/callback/foreman.py -lib/ansible/plugins/callback/jabber.py lib/ansible/plugins/callback/logentries.py lib/ansible/plugins/callback/oneline.py lib/ansible/plugins/callback/profile_tasks.py lib/ansible/plugins/callback/selective.py lib/ansible/plugins/callback/syslog_json.py lib/ansible/plugins/connection/accelerate.py -lib/ansible/plugins/connection/iocage.py lib/ansible/plugins/connection/paramiko_ssh.py lib/ansible/plugins/connection/ssh.py lib/ansible/plugins/connection/winrm.py @@ -581,14 +560,12 @@ test/units/module_utils/basic/test_log.py test/units/module_utils/basic/test_no_log.py test/units/module_utils/basic/test_safe_eval.py test/units/module_utils/basic/test_set_mode_if_different.py -test/units/module_utils/gcp/test_auth.py test/units/module_utils/json_utils/test_filter_non_json_lines.py test/units/module_utils/test_basic.py test/units/module_utils/test_distribution_version.py test/units/module_utils/test_facts.py test/units/module_utils/test_text.py test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py -test/units/modules/cloud/google/test_gce_tag.py test/units/parsing/test_mod_args.py test/units/parsing/yaml/test_loader.py test/units/playbook/test_block.py @@ -599,7 +576,6 @@ test/units/playbook/test_task.py test/units/plugins/action/test_raw.py test/units/plugins/action/test_synchronize.py test/units/plugins/lookup/test_ini.py -test/units/plugins/lookup/test_lastpass.py test/units/plugins/lookup/test_password.py test/units/plugins/strategy/test_strategy_base.py test/units/template/test_templar.py diff --git a/test/sanity/pep8/legacy-ignore.txt b/test/sanity/pep8/legacy-ignore.txt index 3d2daffbb76..ff6aba80466 100644 --- a/test/sanity/pep8/legacy-ignore.txt +++ b/test/sanity/pep8/legacy-ignore.txt @@ -8,7 +8,6 @@ E125 E126 E129 E131 -E271 E501 E701 E703 @@ -17,4 +16,3 @@ E712 E721 W191 W291 -W293 diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py index 6506a598507..3bc58c01ab7 100644 --- a/test/units/cli/test_galaxy.py +++ b/test/units/cli/test_galaxy.py @@ -120,7 +120,7 @@ class TestGalaxy(unittest.TestCase): with patch.object(ansible.cli.CLI, "execute", return_value=None) as mock_ex: with patch.object(ansible.cli.CLI, "run", return_value=None) as mock_run: gc.run() - + # testing self.assertEqual(mock_run.call_count, 1) self.assertTrue(isinstance(gc.api, ansible.galaxy.api.GalaxyAPI)) diff --git a/test/units/module_utils/gcp/test_auth.py b/test/units/module_utils/gcp/test_auth.py index 102a864218d..5aa8049be26 100644 --- a/test/units/module_utils/gcp/test_auth.py +++ b/test/units/module_utils/gcp/test_auth.py @@ -135,7 +135,7 @@ class GCPAuthTestCase(unittest.TestCase): require_valid_json=False, check_libcloud=False) self.assertTrue(is_valid) - + @mock.patch('ansible.module_utils.gcp._get_gcp_environ_var', side_effect=fake_get_gcp_environ_var) def test_get_gcp_environment_credentials(self, mockobj): @@ -144,7 +144,7 @@ class GCPAuthTestCase(unittest.TestCase): actual = _get_gcp_environment_credentials(None, None, None) expected = tuple(['gce-email', None, None]) self.assertEqual(expected, actual) - + fake_env_data = {'GCE_PEM_FILE_PATH': '/path/to/pem.pem'} expected = tuple([None, '/path/to/pem.pem', None]) actual = _get_gcp_environment_credentials(None, None, None) diff --git a/test/units/module_utils/test_basic.py b/test/units/module_utils/test_basic.py index a03e3401f1f..b8551cb722a 100644 --- a/test/units/module_utils/test_basic.py +++ b/test/units/module_utils/test_basic.py @@ -176,10 +176,10 @@ class TestModuleUtilsBasic(ModuleTestCase): return ("Bar", "2", "Two") else: return ("", "", "") - + with patch('platform.linux_distribution', side_effect=_dist): self.assertEqual(get_distribution(), "Bar") - + with patch('platform.linux_distribution', side_effect=Exception("boo")): with patch('platform.dist', return_value=("bar", "2", "Two")): self.assertEqual(get_distribution(), "Bar") @@ -699,7 +699,7 @@ class TestModuleUtilsBasic(ModuleTestCase): self.assertRaises(SystemExit, am.set_context_if_different, '/path/to/file', ['foo_u', 'foo_r', 'foo_t', 's0'], True) am.is_special_selinux_path = MagicMock(return_value=(True, ['sp_u', 'sp_r', 'sp_t', 's0'])) - + with patch('selinux.lsetfilecon', return_value=0) as m: self.assertEqual(am.set_context_if_different('/path/to/file', ['foo_u', 'foo_r', 'foo_t', 's0'], False), True) m.assert_called_with('/path/to/file', 'sp_u:sp_r:sp_t:s0') diff --git a/test/units/modules/cloud/google/test_gce_tag.py b/test/units/modules/cloud/google/test_gce_tag.py index 6a4595e263d..81973b71f88 100644 --- a/test/units/modules/cloud/google/test_gce_tag.py +++ b/test/units/modules/cloud/google/test_gce_tag.py @@ -52,7 +52,7 @@ class TestGCETag(unittest.TestCase): want = ['one'] got = _get_changed_items(tags_to_add, existing_tags) self.assertEqual(want, got) - + # simulate removing tags # specifying one tag on right that doesn't exist tags_to_remove = ['one', 'two'] @@ -63,6 +63,6 @@ class TestGCETag(unittest.TestCase): if __name__ == '__main__': unittest.main() - - + + diff --git a/test/units/plugins/lookup/test_lastpass.py b/test/units/plugins/lookup/test_lastpass.py index bab974759a6..9918d488d7d 100644 --- a/test/units/plugins/lookup/test_lastpass.py +++ b/test/units/plugins/lookup/test_lastpass.py @@ -114,12 +114,12 @@ class MockLPass(LPass): class DisconnectedMockLPass(MockLPass): - + _mock_disconnected = True class LoggedOutMockLPass(MockLPass): - + _mock_logged_out = True diff --git a/test/units/plugins/strategy/test_strategy_base.py b/test/units/plugins/strategy/test_strategy_base.py index b5508c42e53..c9c305e0b13 100644 --- a/test/units/plugins/strategy/test_strategy_base.py +++ b/test/units/plugins/strategy/test_strategy_base.py @@ -163,7 +163,7 @@ class TestStrategyBase(unittest.TestCase): mock_tqm._failed_hosts = [] mock_tqm._unreachable_hosts = [] self.assertEqual(strategy_base.get_hosts_remaining(play=mock_play), mock_hosts) - + mock_tqm._failed_hosts = ["host01"] self.assertEqual(strategy_base.get_hosts_remaining(play=mock_play), mock_hosts[1:]) self.assertEqual(strategy_base.get_failed_hosts(play=mock_play), [mock_hosts[0]]) @@ -186,7 +186,7 @@ class TestStrategyBase(unittest.TestCase): mock_inventory = MagicMock() mock_options = MagicMock() mock_options.module_path = None - + tqm = TaskQueueManager( inventory=mock_inventory, variable_manager=mock_var_manager, @@ -210,7 +210,7 @@ class TestStrategyBase(unittest.TestCase): self.assertEqual(strategy_base._pending_results, 3) finally: tqm.cleanup() - + def test_strategy_base_process_pending_results(self): mock_tqm = MagicMock() @@ -240,7 +240,7 @@ class TestStrategyBase(unittest.TestCase): mock_tqm._stats = MagicMock() mock_tqm._stats.increment.return_value = None - + mock_play = MagicMock() mock_host = MagicMock() diff --git a/test/units/template/test_templar.py b/test/units/template/test_templar.py index 91f12fedede..f2e1be5dfb5 100644 --- a/test/units/template/test_templar.py +++ b/test/units/template/test_templar.py @@ -103,7 +103,7 @@ class TestTemplar(unittest.TestCase): def test_template_jinja2_extensions(self): fake_loader = DictDataLoader({}) templar = Templar(loader=fake_loader) - + old_exts = C.DEFAULT_JINJA2_EXTENSIONS try: C.DEFAULT_JINJA2_EXTENSIONS = "foo,bar"