1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

PEP8 E712 fixes (#21916)

This commit is contained in:
Matt Martz 2017-02-24 16:49:43 -06:00 committed by GitHub
parent 5d39056379
commit 305c88700d
34 changed files with 103 additions and 123 deletions

View file

@ -1718,7 +1718,7 @@ class AnsibleModule(object):
def _set_defaults(self, pre=True): def _set_defaults(self, pre=True):
for (k,v) in self.argument_spec.items(): for (k,v) in self.argument_spec.items():
default = v.get('default', None) default = v.get('default', None)
if pre == True: if pre is True:
# this prevents setting defaults on required items # this prevents setting defaults on required items
if default is not None and k not in self.params: if default is not None and k not in self.params:
self.params[k] = default self.params[k] = default

View file

@ -1033,7 +1033,7 @@ class ElbManager(object):
policy = [] policy = []
policy_type = 'LBCookieStickinessPolicyType' policy_type = 'LBCookieStickinessPolicyType'
if self.module.boolean(self.stickiness['enabled']) == True: if self.module.boolean(self.stickiness['enabled']) is True:
if 'expiration' not in self.stickiness: if 'expiration' not in self.stickiness:
self.module.fail_json(msg='expiration must be set when type is loadbalancer') self.module.fail_json(msg='expiration must be set when type is loadbalancer')
@ -1050,7 +1050,7 @@ class ElbManager(object):
policy.append(self._policy_name(policy_attrs['type'])) policy.append(self._policy_name(policy_attrs['type']))
self._set_stickiness_policy(elb_info, listeners_dict, policy, **policy_attrs) self._set_stickiness_policy(elb_info, listeners_dict, policy, **policy_attrs)
elif self.module.boolean(self.stickiness['enabled']) == False: elif self.module.boolean(self.stickiness['enabled']) is False:
if len(elb_info.policies.lb_cookie_stickiness_policies): if len(elb_info.policies.lb_cookie_stickiness_policies):
if elb_info.policies.lb_cookie_stickiness_policies[0].policy_name == self._policy_name(policy_type): if elb_info.policies.lb_cookie_stickiness_policies[0].policy_name == self._policy_name(policy_type):
self.changed = True self.changed = True
@ -1062,7 +1062,7 @@ class ElbManager(object):
elif self.stickiness['type'] == 'application': elif self.stickiness['type'] == 'application':
policy = [] policy = []
policy_type = 'AppCookieStickinessPolicyType' policy_type = 'AppCookieStickinessPolicyType'
if self.module.boolean(self.stickiness['enabled']) == True: if self.module.boolean(self.stickiness['enabled']) is True:
if 'cookie' not in self.stickiness: if 'cookie' not in self.stickiness:
self.module.fail_json(msg='cookie must be set when type is application') self.module.fail_json(msg='cookie must be set when type is application')
@ -1076,7 +1076,7 @@ class ElbManager(object):
} }
policy.append(self._policy_name(policy_attrs['type'])) policy.append(self._policy_name(policy_attrs['type']))
self._set_stickiness_policy(elb_info, listeners_dict, policy, **policy_attrs) self._set_stickiness_policy(elb_info, listeners_dict, policy, **policy_attrs)
elif self.module.boolean(self.stickiness['enabled']) == False: elif self.module.boolean(self.stickiness['enabled']) is False:
if len(elb_info.policies.app_cookie_stickiness_policies): if len(elb_info.policies.app_cookie_stickiness_policies):
if elb_info.policies.app_cookie_stickiness_policies[0].policy_name == self._policy_name(policy_type): if elb_info.policies.app_cookie_stickiness_policies[0].policy_name == self._policy_name(policy_type):
self.changed = True self.changed = True

View file

@ -316,7 +316,7 @@ def create_eni(connection, vpc_id, module):
eni = find_eni(connection, module) eni = find_eni(connection, module)
if eni is None: if eni is None:
eni = connection.create_network_interface(subnet_id, private_ip_address, description, security_groups) eni = connection.create_network_interface(subnet_id, private_ip_address, description, security_groups)
if attached == True and instance_id is not None: if attached is True and instance_id is not None:
try: try:
eni.attach(instance_id, device_index) eni.attach(instance_id, device_index)
except BotoServerError: except BotoServerError:
@ -399,14 +399,14 @@ def modify_eni(connection, vpc_id, module, eni):
secondary_addresses_to_remove_count = current_secondary_address_count - secondary_private_ip_address_count secondary_addresses_to_remove_count = current_secondary_address_count - secondary_private_ip_address_count
connection.unassign_private_ip_addresses(network_interface_id=eni.id, private_ip_addresses=current_secondary_addresses[:secondary_addresses_to_remove_count], dry_run=False) connection.unassign_private_ip_addresses(network_interface_id=eni.id, private_ip_addresses=current_secondary_addresses[:secondary_addresses_to_remove_count], dry_run=False)
if attached == True: if attached is True:
if eni.attachment and eni.attachment.instance_id != instance_id: if eni.attachment and eni.attachment.instance_id != instance_id:
detach_eni(eni, module) detach_eni(eni, module)
if eni.attachment is None: if eni.attachment is None:
eni.attach(instance_id, device_index) eni.attach(instance_id, device_index)
wait_for_eni(eni, "attached") wait_for_eni(eni, "attached")
changed = True changed = True
elif attached == False: elif attached is False:
detach_eni(eni, module) detach_eni(eni, module)
except BotoServerError as e: except BotoServerError as e:

View file

@ -448,7 +448,7 @@ def find_default_vpc_nacl(vpc_id, client, module):
except botocore.exceptions.ClientError as e: except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
nacls = response['NetworkAcls'] nacls = response['NetworkAcls']
return [n['NetworkAclId'] for n in nacls if n['IsDefault'] == True] return [n['NetworkAclId'] for n in nacls if n['IsDefault'] is True]
def find_subnet_ids_by_nacl_id(nacl_id, client, module): def find_subnet_ids_by_nacl_id(nacl_id, client, module):

View file

@ -1005,7 +1005,7 @@ def validate_parameters(required_vars, valid_vars, module):
if k in valid_vars: if k in valid_vars:
params[v] = module.params[k] params[v] = module.params[k]
else: else:
if module.params.get(k) == False: if module.params.get(k) is False:
pass pass
else: else:
module.fail_json(msg="Parameter %s is not valid for %s command" % (k, command)) module.fail_json(msg="Parameter %s is not valid for %s command" % (k, command))

View file

@ -805,7 +805,7 @@ class ClcLoadBalancer:
if not node in nodes: if not node in nodes:
changed = True changed = True
nodes.append(node) nodes.append(node)
if changed == True and not self.module.check_mode: if changed is True and not self.module.check_mode:
result = self.set_loadbalancernodes( result = self.set_loadbalancernodes(
alias, alias,
location, location,
@ -836,7 +836,7 @@ class ClcLoadBalancer:
if node in nodes: if node in nodes:
changed = True changed = True
nodes.remove(node) nodes.remove(node)
if changed == True and not self.module.check_mode: if changed is True and not self.module.check_mode:
result = self.set_loadbalancernodes( result = self.set_loadbalancernodes(
alias, alias,
location, location,

View file

@ -623,7 +623,7 @@ def normalize_image(image):
def is_running(container): def is_running(container):
'''Return True if an inspected container is in a state we consider "running."''' '''Return True if an inspected container is in a state we consider "running."'''
return container['State']['Running'] == True and not container['State'].get('Ghost', False) return container['State']['Running'] is True and not container['State'].get('Ghost', False)
def get_docker_py_versioninfo(): def get_docker_py_versioninfo():

View file

@ -383,7 +383,7 @@ def main():
elif module.params.get('state') == 'present': elif module.params.get('state') == 'present':
(changed, instance) = create_virtual_instance(module) (changed, instance) = create_virtual_instance(module)
if module.params.get('wait') == True and instance: if module.params.get('wait') is True and instance:
(changed, instance) = wait_for_instance(module, instance['id']) (changed, instance) = wait_for_instance(module, instance['id'])
module.exit_json(changed=changed, instance=json.loads(json.dumps(instance, default=lambda o: o.__dict__))) module.exit_json(changed=changed, instance=json.loads(json.dumps(instance, default=lambda o: o.__dict__)))

View file

@ -231,7 +231,7 @@ def main():
gateway.delete_fw_rule(**kwargs) gateway.delete_fw_rule(**kwargs)
result['changed'] = True result['changed'] = True
if not module.check_mode and result['changed'] == True: if not module.check_mode and result['changed'] is True:
task = gateway.save_services_configuration() task = gateway.save_services_configuration()
if task: if task:
vca.block_until_completed(task) vca.block_until_completed(task)

View file

@ -762,7 +762,7 @@ def deploy_template(vsphere_client, guest, resource_pool, template_src, esxi, mo
vm.set_extra_config(vm_extra_config) vm.set_extra_config(vm_extra_config)
# Power on if asked # Power on if asked
if power_on_after_clone == True: if power_on_after_clone is True:
state = 'powered_on' state = 'powered_on'
power_state(vm, state, True) power_state(vm, state, True)

View file

@ -534,7 +534,7 @@ class Connection(object):
self.cursor.execute(query % (set_what, for_whom)) self.cursor.execute(query % (set_what, for_whom))
# Only revoke GRANT/ADMIN OPTION if grant_option actually is False. # Only revoke GRANT/ADMIN OPTION if grant_option actually is False.
if grant_option == False: if grant_option is False:
if obj_type == 'group': if obj_type == 'group':
query = 'REVOKE ADMIN OPTION FOR %s FROM %s' query = 'REVOKE ADMIN OPTION FOR %s FROM %s'
else: else:

View file

@ -173,7 +173,7 @@ def create_meter(module, name, apiid, apikey):
except IOError: except IOError:
# Now download the file... # Now download the file...
rc = download_request(module, name, apiid, apikey, cert_type) rc = download_request(module, name, apiid, apikey, cert_type)
if rc == False: if rc is False:
module.fail_json("Download request for " + cert_type + ".pem failed") module.fail_json("Download request for " + cert_type + ".pem failed")
return 0, "Meter " + name + " created" return 0, "Meter " + name + " created"

View file

@ -204,7 +204,7 @@ def main():
changed = False changed = False
if operation == 'create': if operation == 'create':
if slb_server_exists == False: if slb_server_exists is False:
result = axapi_call_v3(module, axapi_base_url+'slb/server/', method='POST', body=json.dumps(json_post), signature=signature) result = axapi_call_v3(module, axapi_base_url+'slb/server/', method='POST', body=json.dumps(json_post), signature=signature)
if axapi_failure(result): if axapi_failure(result):
module.fail_json(msg="failed to create the server: %s" % result['response']['err']['msg']) module.fail_json(msg="failed to create the server: %s" % result['response']['err']['msg'])

View file

@ -210,7 +210,7 @@ def main():
kickstart_image_file): kickstart_image_file):
changed = True changed = True
if not module.check_mode and changed == True: if not module.check_mode and changed is True:
set_boot_options(module, set_boot_options(module,
system_image_file, system_image_file,
kickstart=kickstart_image_file) kickstart=kickstart_image_file)

View file

@ -680,7 +680,7 @@ def main():
commands.append(defaults) commands.append(defaults)
elif state == 'absent': elif state == 'absent':
if existing.get('sparse') == True: if existing.get('sparse') is True:
delta['sparse'] = False delta['sparse'] = False
# defaults is a list of commands # defaults is a list of commands
defaults = config_pim_interface_defaults(existing, jp_bidir, isauth) defaults = config_pim_interface_defaults(existing, jp_bidir, isauth)

View file

@ -300,12 +300,12 @@ def get_commands_to_config_vpc(module, vpc, domain, existing):
' source {1} vrf {2}'.format(pkl_dest, pkl_src, pkl_vrf)) ' source {1} vrf {2}'.format(pkl_dest, pkl_src, pkl_vrf))
commands.append(pkl_command) commands.append(pkl_command)
if vpc.get('auto_recovery') == False: if vpc.get('auto_recovery') is False:
vpc['auto_recovery'] = 'no' vpc['auto_recovery'] = 'no'
else: else:
vpc['auto_recovery'] = '' vpc['auto_recovery'] = ''
if vpc.get('peer_gw') == False: if vpc.get('peer_gw') is False:
vpc['peer_gw'] = 'no' vpc['peer_gw'] = 'no'
else: else:
vpc['peer_gw'] = '' vpc['peer_gw'] = ''

View file

@ -209,7 +209,7 @@ def main():
# Verify that we receive a community when using snmp v2 # Verify that we receive a community when using snmp v2
if m_args['version'] == "v2" or m_args['version'] == "v2c": if m_args['version'] == "v2" or m_args['version'] == "v2c":
if m_args['community'] == False: if m_args['community'] is False:
module.fail_json(msg='Community not set when using snmp version 2') module.fail_json(msg='Community not set when using snmp version 2')
if m_args['version'] == "v3": if m_args['version'] == "v3":

View file

@ -302,7 +302,7 @@ def package_latest(names, pkg_spec, module):
# parse out a successful update above. This way we will report a # parse out a successful update above. This way we will report a
# successful run when we actually modify something but fail # successful run when we actually modify something but fail
# otherwise. # otherwise.
if pkg_spec[name]['changed'] != True: if pkg_spec[name]['changed'] is not True:
if pkg_spec[name]['stderr']: if pkg_spec[name]['stderr']:
pkg_spec[name]['rc'] = 1 pkg_spec[name]['rc'] = 1
@ -614,7 +614,7 @@ def main():
else: else:
combined_error_message = pkg_spec[n]['stdout'] combined_error_message = pkg_spec[n]['stdout']
if pkg_spec[n]['changed'] == True: if pkg_spec[n]['changed'] is True:
combined_changed = True combined_changed = True
# If combined_error_message contains anything at least some part of the # If combined_error_message contains anything at least some part of the

View file

@ -155,7 +155,7 @@ def main():
else: else:
installed = False installed = False
if ( state == 'present' or state == 'latest' ) and installed == False: if ( state == 'present' or state == 'latest' ) and installed is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
rc, output = install_package(module, depot, name) rc, output = install_package(module, depot, name)
@ -167,7 +167,7 @@ def main():
else: else:
module.fail_json(name=name, msg=output, rc=rc) module.fail_json(name=name, msg=output, rc=rc)
elif state == 'latest' and installed == True: elif state == 'latest' and installed is True:
#Check depot version #Check depot version
rc, version_depot = query_package(module, name, depot) rc, version_depot = query_package(module, name, depot)
@ -189,7 +189,7 @@ def main():
output = "Software package not in repository " + depot output = "Software package not in repository " + depot
module.fail_json(name=name, msg=output, rc=rc) module.fail_json(name=name, msg=output, rc=rc)
elif state == 'absent' and installed == True: elif state == 'absent' and installed is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
rc, output = remove_package(module, name) rc, output = remove_package(module, name)

View file

@ -208,9 +208,9 @@ def main():
rc,raw_fs,err = module.run_command("%s -c /dev/null -o value -s TYPE %s" % (cmd, dev)) rc,raw_fs,err = module.run_command("%s -c /dev/null -o value -s TYPE %s" % (cmd, dev))
fs = raw_fs.strip() fs = raw_fs.strip()
if fs == fstype and resizefs == False and not force: if fs == fstype and resizefs is False and not force:
module.exit_json(changed=False) module.exit_json(changed=False)
elif fs == fstype and resizefs == True: elif fs == fstype and resizefs is True:
# Get dev and fs size and compare # Get dev and fs size and compare
devsize_in_bytes = _get_dev_size(dev, module) devsize_in_bytes = _get_dev_size(dev, module)
fssize_in_bytes = _get_fs_size(fssize_cmd, dev, module) fssize_in_bytes = _get_fs_size(fssize_cmd, dev, module)

View file

@ -211,14 +211,14 @@ def update_fw_settings(fw_zone, fw_settings):
# masquerade handling # masquerade handling
# #
def get_masquerade_enabled(zone): def get_masquerade_enabled(zone):
if fw.queryMasquerade(zone) == True: if fw.queryMasquerade(zone) is True:
return True return True
else: else:
return False return False
def get_masquerade_enabled_permanent(zone): def get_masquerade_enabled_permanent(zone):
fw_zone, fw_settings = get_fw_zone_settings(zone) fw_zone, fw_settings = get_fw_zone_settings(zone)
if fw_settings.getMasquerade() == True: if fw_settings.getMasquerade() is True:
return True return True
else: else:
return False return False
@ -507,7 +507,7 @@ def main():
## Check for firewalld running ## Check for firewalld running
try: try:
if fw.connected == False: if fw.connected is False:
module.fail_json(msg='firewalld service must be running, or try with offline=true') module.fail_json(msg='firewalld service must be running, or try with offline=true')
except AttributeError: except AttributeError:
module.fail_json(msg="firewalld connection can't be established,\ module.fail_json(msg="firewalld connection can't be established,\
@ -623,7 +623,7 @@ def main():
msgs.append('Permanent operation') msgs.append('Permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -633,7 +633,7 @@ def main():
) )
changed=True changed=True
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -651,7 +651,7 @@ def main():
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -661,7 +661,7 @@ def main():
) )
changed=True changed=True
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -671,7 +671,7 @@ def main():
) )
changed=True changed=True
if changed == True: if changed is True:
msgs.append("Changed service %s to %s" % (service, desired_state)) msgs.append("Changed service %s to %s" % (service, desired_state))
# FIXME - source type does not handle non-permanent mode, this was an # FIXME - source type does not handle non-permanent mode, this was an
@ -679,7 +679,7 @@ def main():
if source is not None: if source is not None:
is_enabled = action_handler(get_source, (zone, source)) is_enabled = action_handler(get_source, (zone, source))
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -687,7 +687,7 @@ def main():
changed=True changed=True
msgs.append("Added %s to zone %s" % (source, zone)) msgs.append("Added %s to zone %s" % (source, zone))
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -749,7 +749,7 @@ def main():
msgs.append('Permanent operation') msgs.append('Permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -759,7 +759,7 @@ def main():
) )
changed=True changed=True
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -776,7 +776,7 @@ def main():
msgs.append('Non-permanent operation') msgs.append('Non-permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -786,7 +786,7 @@ def main():
) )
changed=True changed=True
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -796,7 +796,7 @@ def main():
) )
changed=True changed=True
if changed == True: if changed is True:
msgs.append("Changed port %s to %s" % ("%s/%s" % (port, protocol), \ msgs.append("Changed port %s to %s" % ("%s/%s" % (port, protocol), \
desired_state)) desired_state))
@ -853,7 +853,7 @@ def main():
msgs.append('Permanent operation') msgs.append('Permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -863,7 +863,7 @@ def main():
) )
changed=True changed=True
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -880,7 +880,7 @@ def main():
msgs.append('Non-permanent operation') msgs.append('Non-permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -890,7 +890,7 @@ def main():
) )
changed=True changed=True
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -900,7 +900,7 @@ def main():
) )
changed=True changed=True
if changed == True: if changed is True:
msgs.append("Changed rich_rule %s to %s" % (rich_rule, desired_state)) msgs.append("Changed rich_rule %s to %s" % (rich_rule, desired_state))
if interface is not None: if interface is not None:
@ -948,7 +948,7 @@ def main():
) )
msgs.append('Permanent operation') msgs.append('Permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -956,7 +956,7 @@ def main():
changed=True changed=True
msgs.append("Changed %s to zone %s" % (interface, zone)) msgs.append("Changed %s to zone %s" % (interface, zone))
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -970,7 +970,7 @@ def main():
) )
msgs.append('Non-permanent operation') msgs.append('Non-permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -978,7 +978,7 @@ def main():
changed=True changed=True
msgs.append("Changed %s to zone %s" % (interface, zone)) msgs.append("Changed %s to zone %s" % (interface, zone))
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -1027,7 +1027,7 @@ def main():
msgs.append('Permanent operation') msgs.append('Permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -1035,7 +1035,7 @@ def main():
changed=True changed=True
msgs.append("Added masquerade to zone %s" % (zone)) msgs.append("Added masquerade to zone %s" % (zone))
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -1047,7 +1047,7 @@ def main():
msgs.append('Non-permanent operation') msgs.append('Non-permanent operation')
if desired_state == "enabled": if desired_state == "enabled":
if is_enabled == False: if is_enabled is False:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
@ -1055,7 +1055,7 @@ def main():
changed=True changed=True
msgs.append("Added masquerade to zone %s" % (zone)) msgs.append("Added masquerade to zone %s" % (zone))
elif desired_state == "disabled": elif desired_state == "disabled":
if is_enabled == True: if is_enabled is True:
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)

View file

@ -241,11 +241,11 @@ def get_peers():
uuid = value uuid = value
if key.lower() == 'state': if key.lower() == 'state':
state = value state = value
peers[hostname] = [ uuid, state ] peers[hostname] = [uuid, state]
elif row.lower() == 'other names:': elif row.lower() == 'other names:':
shortNames = True shortNames = True
elif row != '' and shortNames == True: elif row != '' and shortNames is True:
peers[row] = [ uuid, state ] peers[row] = [uuid, state]
elif row == '': elif row == '':
shortNames = False shortNames = False
return peers return peers

View file

@ -105,7 +105,7 @@ class Group(object):
if key == 'gid' and kwargs[key] is not None: if key == 'gid' and kwargs[key] is not None:
cmd.append('-g') cmd.append('-g')
cmd.append(kwargs[key]) cmd.append(kwargs[key])
elif key == 'system' and kwargs[key] == True: elif key == 'system' and kwargs[key] is True:
cmd.append('-r') cmd.append('-r')
cmd.append(self.name) cmd.append(self.name)
return self.execute_command(cmd) return self.execute_command(cmd)
@ -190,8 +190,8 @@ class AIX(Group):
cmd = [self.module.get_bin_path('mkgroup', True)] cmd = [self.module.get_bin_path('mkgroup', True)]
for key in kwargs: for key in kwargs:
if key == 'gid' and kwargs[key] is not None: if key == 'gid' and kwargs[key] is not None:
cmd.append('id='+kwargs[key]) cmd.append('id=' + kwargs[key])
elif key == 'system' and kwargs[key] == True: elif key == 'system' and kwargs[key] is True:
cmd.append('-a') cmd.append('-a')
cmd.append(self.name) cmd.append(self.name)
return self.execute_command(cmd) return self.execute_command(cmd)
@ -202,7 +202,7 @@ class AIX(Group):
for key in kwargs: for key in kwargs:
if key == 'gid': if key == 'gid':
if kwargs[key] is not None and info[2] != int(kwargs[key]): if kwargs[key] is not None and info[2] != int(kwargs[key]):
cmd.append('id='+kwargs[key]) cmd.append('id=' + kwargs[key])
if len(cmd) == 1: if len(cmd) == 1:
return (None, '', '') return (None, '', '')
if self.module.check_mode: if self.module.check_mode:
@ -275,9 +275,9 @@ class DarwinGroup(Group):
cmd += [ '-o', 'create' ] cmd += [ '-o', 'create' ]
if self.gid is not None: if self.gid is not None:
cmd += [ '-i', self.gid ] cmd += [ '-i', self.gid ]
elif 'system' in kwargs and kwargs['system'] == True: elif 'system' in kwargs and kwargs['system'] is True:
gid = self.get_lowest_available_system_gid() gid = self.get_lowest_available_system_gid()
if gid != False: if gid is not False:
self.gid = str(gid) self.gid = str(gid)
cmd += [ '-i', self.gid ] cmd += [ '-i', self.gid ]
cmd += [ '-L', self.name ] cmd += [ '-L', self.name ]

View file

@ -206,10 +206,10 @@ def sanity_check(module,host,key,sshkeygen):
except: except:
pass pass
if stdout=='': #host not found if stdout == '': # host not found
module.fail_json(msg="Host parameter does not match hashed host field in supplied key") module.fail_json(msg="Host parameter does not match hashed host field in supplied key")
def search_for_host_key(module,host,key,hash_host,path,sshkeygen): def search_for_host_key(module, host, key, hash_host, path, sshkeygen):
'''search_for_host_key(module,host,key,path,sshkeygen) -> (found,replace_or_add,found_line) '''search_for_host_key(module,host,key,path,sshkeygen) -> (found,replace_or_add,found_line)
Looks up host and keytype in the known_hosts file path; if it's there, looks to see Looks up host and keytype in the known_hosts file path; if it's there, looks to see
@ -220,37 +220,37 @@ def search_for_host_key(module,host,key,hash_host,path,sshkeygen):
if found=False, then replace is always False. if found=False, then replace is always False.
sshkeygen is the path to ssh-keygen, found earlier with get_bin_path sshkeygen is the path to ssh-keygen, found earlier with get_bin_path
''' '''
if os.path.exists(path)==False: if os.path.exists(path) is False:
return False, False, None, key return False, False, None, key
sshkeygen_command=[sshkeygen,'-F',host,'-f',path] sshkeygen_command=[sshkeygen, '-F', host, '-f', path]
#openssh >=6.4 has changed ssh-keygen behaviour such that it returns # openssh >=6.4 has changed ssh-keygen behaviour such that it returns
#1 if no host is found, whereas previously it returned 0 # 1 if no host is found, whereas previously it returned 0
rc,stdout,stderr=module.run_command(sshkeygen_command, rc,stdout,stderr=module.run_command(sshkeygen_command,
check_rc=False) check_rc = False)
if stdout=='' and stderr=='' and (rc==0 or rc==1): if stdout == '' and stderr == '' and (rc == 0 or rc == 1):
return False, False, None, key #host not found, no other errors return False, False, None, key # host not found, no other errors
if rc!=0: #something went wrong if rc != 0: # something went wrong
module.fail_json(msg="ssh-keygen failed (rc=%d,stdout='%s',stderr='%s')" % (rc,stdout,stderr)) module.fail_json(msg="ssh-keygen failed (rc=%d,stdout='%s',stderr='%s')" % (rc,stdout,stderr))
#If user supplied no key, we don't want to try and replace anything with it # If user supplied no key, we don't want to try and replace anything with it
if key is None: if key is None:
return True, False, None, key return True, False, None, key
lines=stdout.split('\n') lines = stdout.split('\n')
new_key = normalize_known_hosts_key(key) new_key = normalize_known_hosts_key(key)
sshkeygen_command.insert(1,'-H') sshkeygen_command.insert(1, '-H')
rc,stdout,stderr=module.run_command(sshkeygen_command,check_rc=False) rc, stdout, stderr = module.run_command(sshkeygen_command, check_rc=False)
if rc not in (0, 1) or stderr != '': #something went wrong if rc not in (0, 1) or stderr != '': # something went wrong
module.fail_json(msg="ssh-keygen failed to hash host (rc=%d,stdout='%s',stderr='%s')" % (rc,stdout,stderr)) module.fail_json(msg="ssh-keygen failed to hash host (rc=%d,stdout='%s',stderr='%s')" % (rc, stdout, stderr))
hashed_lines=stdout.split('\n') hashed_lines = stdout.split('\n')
for lnum,l in enumerate(lines): for lnum, l in enumerate(lines):
if l=='': if l == '':
continue continue
elif l[0]=='#': # info output from ssh-keygen; contains the line number where key was found elif l[0] == '#': # info output from ssh-keygen; contains the line number where key was found
try: try:
# This output format has been hardcoded in ssh-keygen since at least OpenSSH 4.0 # This output format has been hardcoded in ssh-keygen since at least OpenSSH 4.0
# It always outputs the non-localized comment before the found key # It always outputs the non-localized comment before the found key
@ -259,18 +259,18 @@ def search_for_host_key(module,host,key,hash_host,path,sshkeygen):
module.fail_json(msg="failed to parse output of ssh-keygen for line number: '%s'" % l) module.fail_json(msg="failed to parse output of ssh-keygen for line number: '%s'" % l)
else: else:
found_key = normalize_known_hosts_key(l) found_key = normalize_known_hosts_key(l)
if hash_host==True: if hash_host is True:
if found_key['host'][:3]=='|1|': if found_key['host'][:3] == '|1|':
new_key['host']=found_key['host'] new_key['host']=found_key['host']
else: else:
hashed_host=normalize_known_hosts_key(hashed_lines[lnum]) hashed_host=normalize_known_hosts_key(hashed_lines[lnum])
found_key['host']=hashed_host['host'] found_key['host']=hashed_host['host']
key=key.replace(host,found_key['host']) key=key.replace(host,found_key['host'])
if new_key==found_key: #found a match if new_key==found_key: # found a match
return True, False, found_line, key #found exactly the same key, don't replace return True, False, found_line, key # found exactly the same key, don't replace
elif new_key['type'] == found_key['type']: # found a different key for the same key type elif new_key['type'] == found_key['type']: # found a different key for the same key type
return True, True, found_line, key return True, True, found_line, key
#No match found, return found and replace, but no line # No match found, return found and replace, but no line
return True, True, None, key return True, True, None, key
def normalize_known_hosts_key(key): def normalize_known_hosts_key(key):

View file

@ -233,7 +233,7 @@ def main():
else: else:
if changed: if changed:
try: try:
if ubuntuMode==False: if ubuntuMode is False:
apply_change(state, name) apply_change(state, name)
else: else:
apply_change_ubuntu(state, name) apply_change_ubuntu(state, name)

View file

@ -2207,7 +2207,7 @@ def main():
if user.user_exists(): if user.user_exists():
info = user.user_info() info = user.user_info()
if info == False: if info is False:
result['msg'] = "failed to look up user name: %s" % user.name result['msg'] = "failed to look up user name: %s" % user.name
result['failed'] = True result['failed'] = True
result['uid'] = info[2] result['uid'] = info[2]

View file

@ -264,12 +264,12 @@ class JenkinsJob:
if self.enabled is None: if self.enabled is None:
return False return False
if ( (self.enabled == False and status != "disabled") or (self.enabled == True and status == "disabled") ): if ( (self.enabled is False and status != "disabled") or (self.enabled is True and status == "disabled") ):
return True return True
return False return False
def switch_state(self): def switch_state(self):
if self.enabled == False: if self.enabled is False:
self.server.disable_job(self.name) self.server.disable_job(self.name)
else: else:
self.server.enable_job(self.name) self.server.enable_job(self.name)

View file

@ -660,7 +660,7 @@ class Connection(ConnectionBase):
raise AnsibleOptionsError('scp_if_ssh needs to be one of [smart|True|False]') raise AnsibleOptionsError('scp_if_ssh needs to be one of [smart|True|False]')
if scp_if_ssh == 'smart': if scp_if_ssh == 'smart':
methods = ['sftp', 'scp', 'piped'] methods = ['sftp', 'scp', 'piped']
elif scp_if_ssh == True: elif scp_if_ssh is True:
methods = ['scp'] methods = ['scp']
else: else:
methods = ['sftp'] methods = ['sftp']

View file

@ -323,7 +323,7 @@ def ipaddr(value, query = '', version = False, alias = 'ipaddr'):
if not value: if not value:
return False return False
elif value == True: elif value is True:
return False return False
# Check if value is a list and parse each element # Check if value is a list and parse each element

View file

@ -115,7 +115,7 @@ class LookupModule(LookupBase):
... flat=0 # returns a dict; default is 1 == string ... flat=0 # returns a dict; default is 1 == string
''' '''
if HAVE_DNS == False: if HAVE_DNS is False:
raise AnsibleError("Can't LOOKUP(dig): module dns.resolver is not installed") raise AnsibleError("Can't LOOKUP(dig): module dns.resolver is not installed")
# Create Resolver object so that we can set NS if necessary # Create Resolver object so that we can set NS if necessary

View file

@ -39,7 +39,7 @@ class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs): def run(self, terms, variables=None, **kwargs):
if HAVE_DNS == False: if HAVE_DNS is False:
raise AnsibleError("Can't LOOKUP(dnstxt): module dns.resolver is not installed") raise AnsibleError("Can't LOOKUP(dnstxt): module dns.resolver is not installed")
ret = [] ret = []

View file

@ -138,7 +138,7 @@ def get_docstring(filename, verbose=False):
except: except:
display.error("unable to parse %s" % filename) display.error("unable to parse %s" % filename)
if verbose == True: if verbose is True:
display.display("unable to parse %s" % filename) display.display("unable to parse %s" % filename)
raise raise

View file

@ -28,7 +28,6 @@ lib/ansible/modules/cloud/amazon/ec2_asg.py
lib/ansible/modules/cloud/amazon/ec2_asg_facts.py lib/ansible/modules/cloud/amazon/ec2_asg_facts.py
lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py
lib/ansible/modules/cloud/amazon/ec2_elb.py lib/ansible/modules/cloud/amazon/ec2_elb.py
lib/ansible/modules/cloud/amazon/ec2_elb_lb.py
lib/ansible/modules/cloud/amazon/ec2_eni.py lib/ansible/modules/cloud/amazon/ec2_eni.py
lib/ansible/modules/cloud/amazon/ec2_eni_facts.py lib/ansible/modules/cloud/amazon/ec2_eni_facts.py
lib/ansible/modules/cloud/amazon/ec2_group.py lib/ansible/modules/cloud/amazon/ec2_group.py
@ -40,7 +39,6 @@ lib/ansible/modules/cloud/amazon/ec2_snapshot_facts.py
lib/ansible/modules/cloud/amazon/ec2_tag.py lib/ansible/modules/cloud/amazon/ec2_tag.py
lib/ansible/modules/cloud/amazon/ec2_vol_facts.py lib/ansible/modules/cloud/amazon/ec2_vol_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_nacl.py
lib/ansible/modules/cloud/amazon/ec2_vpc_net.py lib/ansible/modules/cloud/amazon/ec2_vpc_net.py
lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_facts.py
@ -76,7 +74,6 @@ 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_securitygroup_facts.py
lib/ansible/modules/cloud/azure/azure_rm_subnet.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_virtualmachine.py
lib/ansible/modules/cloud/centurylink/clc_loadbalancer.py
lib/ansible/modules/cloud/cloudscale/cloudscale_server.py lib/ansible/modules/cloud/cloudscale/cloudscale_server.py
lib/ansible/modules/cloud/cloudstack/cs_host.py lib/ansible/modules/cloud/cloudstack/cs_host.py
lib/ansible/modules/cloud/cloudstack/cs_instance.py lib/ansible/modules/cloud/cloudstack/cs_instance.py
@ -84,7 +81,6 @@ lib/ansible/modules/cloud/cloudstack/cs_iso.py
lib/ansible/modules/cloud/cloudstack/cs_portforward.py lib/ansible/modules/cloud/cloudstack/cs_portforward.py
lib/ansible/modules/cloud/cloudstack/cs_sshkeypair.py lib/ansible/modules/cloud/cloudstack/cs_sshkeypair.py
lib/ansible/modules/cloud/digital_ocean/digital_ocean.py lib/ansible/modules/cloud/digital_ocean/digital_ocean.py
lib/ansible/modules/cloud/docker/_docker.py
lib/ansible/modules/cloud/google/gc_storage.py lib/ansible/modules/cloud/google/gc_storage.py
lib/ansible/modules/cloud/google/gce_tag.py lib/ansible/modules/cloud/google/gce_tag.py
lib/ansible/modules/cloud/google/gcpubsub.py lib/ansible/modules/cloud/google/gcpubsub.py
@ -100,7 +96,6 @@ lib/ansible/modules/cloud/packet/packet_sshkey.py
lib/ansible/modules/cloud/profitbricks/profitbricks.py lib/ansible/modules/cloud/profitbricks/profitbricks.py
lib/ansible/modules/cloud/profitbricks/profitbricks_datacenter.py lib/ansible/modules/cloud/profitbricks/profitbricks_datacenter.py
lib/ansible/modules/cloud/softlayer/sl_vm.py 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_guest.py
lib/ansible/modules/cloud/vmware/vsphere_guest.py lib/ansible/modules/cloud/vmware/vsphere_guest.py
lib/ansible/modules/cloud/webfaction/webfaction_app.py lib/ansible/modules/cloud/webfaction/webfaction_app.py
@ -131,14 +126,12 @@ lib/ansible/modules/files/synchronize.py
lib/ansible/modules/files/tempfile.py lib/ansible/modules/files/tempfile.py
lib/ansible/modules/files/unarchive.py lib/ansible/modules/files/unarchive.py
lib/ansible/modules/messaging/rabbitmq_queue.py lib/ansible/modules/messaging/rabbitmq_queue.py
lib/ansible/modules/monitoring/boundary_meter.py
lib/ansible/modules/monitoring/datadog_monitor.py lib/ansible/modules/monitoring/datadog_monitor.py
lib/ansible/modules/monitoring/logicmonitor.py lib/ansible/modules/monitoring/logicmonitor.py
lib/ansible/modules/monitoring/nagios.py lib/ansible/modules/monitoring/nagios.py
lib/ansible/modules/monitoring/pagerduty_alert.py lib/ansible/modules/monitoring/pagerduty_alert.py
lib/ansible/modules/monitoring/zabbix_screen.py lib/ansible/modules/monitoring/zabbix_screen.py
lib/ansible/modules/network/a10/a10_server.py lib/ansible/modules/network/a10/a10_server.py
lib/ansible/modules/network/a10/a10_server_axapi3.py
lib/ansible/modules/network/a10/a10_service_group.py lib/ansible/modules/network/a10/a10_service_group.py
lib/ansible/modules/network/basics/slurp.py lib/ansible/modules/network/basics/slurp.py
lib/ansible/modules/network/cloudflare_dns.py lib/ansible/modules/network/cloudflare_dns.py
@ -160,12 +153,9 @@ lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py
lib/ansible/modules/network/nxos/nxos_evpn_vni.py lib/ansible/modules/network/nxos/nxos_evpn_vni.py
lib/ansible/modules/network/nxos/nxos_feature.py lib/ansible/modules/network/nxos/nxos_feature.py
lib/ansible/modules/network/nxos/nxos_gir.py lib/ansible/modules/network/nxos/nxos_gir.py
lib/ansible/modules/network/nxos/nxos_install_os.py
lib/ansible/modules/network/nxos/nxos_interface_ospf.py lib/ansible/modules/network/nxos/nxos_interface_ospf.py
lib/ansible/modules/network/nxos/nxos_pim_interface.py
lib/ansible/modules/network/nxos/nxos_snapshot.py lib/ansible/modules/network/nxos/nxos_snapshot.py
lib/ansible/modules/network/nxos/nxos_vlan.py lib/ansible/modules/network/nxos/nxos_vlan.py
lib/ansible/modules/network/nxos/nxos_vpc.py
lib/ansible/modules/network/panos/panos_nat_policy.py lib/ansible/modules/network/panos/panos_nat_policy.py
lib/ansible/modules/network/snmp_facts.py lib/ansible/modules/network/snmp_facts.py
lib/ansible/modules/notification/hall.py lib/ansible/modules/notification/hall.py
@ -194,17 +184,12 @@ lib/ansible/modules/storage/netapp/netapp_e_snapshot_volume.py
lib/ansible/modules/storage/netapp/netapp_e_storage_system.py lib/ansible/modules/storage/netapp/netapp_e_storage_system.py
lib/ansible/modules/storage/netapp/netapp_e_storagepool.py lib/ansible/modules/storage/netapp/netapp_e_storagepool.py
lib/ansible/modules/system/debconf.py lib/ansible/modules/system/debconf.py
lib/ansible/modules/system/filesystem.py
lib/ansible/modules/system/firewalld.py lib/ansible/modules/system/firewalld.py
lib/ansible/modules/system/gluster_volume.py
lib/ansible/modules/system/group.py
lib/ansible/modules/system/known_hosts.py lib/ansible/modules/system/known_hosts.py
lib/ansible/modules/system/locale_gen.py
lib/ansible/modules/system/lvol.py lib/ansible/modules/system/lvol.py
lib/ansible/modules/system/pam_limits.py lib/ansible/modules/system/pam_limits.py
lib/ansible/modules/system/solaris_zone.py lib/ansible/modules/system/solaris_zone.py
lib/ansible/modules/system/systemd.py lib/ansible/modules/system/systemd.py
lib/ansible/modules/system/user.py
lib/ansible/modules/utilities/helper/meta.py lib/ansible/modules/utilities/helper/meta.py
lib/ansible/modules/utilities/logic/include.py lib/ansible/modules/utilities/logic/include.py
lib/ansible/modules/utilities/logic/include_role.py lib/ansible/modules/utilities/logic/include_role.py
@ -214,7 +199,6 @@ lib/ansible/modules/utilities/logic/set_fact.py
lib/ansible/modules/utilities/logic/wait_for.py lib/ansible/modules/utilities/logic/wait_for.py
lib/ansible/modules/web_infrastructure/apache2_mod_proxy.py lib/ansible/modules/web_infrastructure/apache2_mod_proxy.py
lib/ansible/modules/web_infrastructure/django_manage.py lib/ansible/modules/web_infrastructure/django_manage.py
lib/ansible/modules/web_infrastructure/jenkins_job.py
lib/ansible/modules/web_infrastructure/jira.py lib/ansible/modules/web_infrastructure/jira.py
lib/ansible/modules/web_infrastructure/nginx_status_facts.py lib/ansible/modules/web_infrastructure/nginx_status_facts.py
lib/ansible/modules/windows/win_acl.py lib/ansible/modules/windows/win_acl.py
@ -250,8 +234,6 @@ lib/ansible/plugins/connection/paramiko_ssh.py
lib/ansible/plugins/connection/ssh.py lib/ansible/plugins/connection/ssh.py
lib/ansible/plugins/connection/winrm.py lib/ansible/plugins/connection/winrm.py
lib/ansible/plugins/filter/ipaddr.py lib/ansible/plugins/filter/ipaddr.py
lib/ansible/plugins/lookup/dig.py
lib/ansible/plugins/lookup/dnstxt.py
lib/ansible/plugins/lookup/first_found.py lib/ansible/plugins/lookup/first_found.py
lib/ansible/plugins/shell/fish.py lib/ansible/plugins/shell/fish.py
lib/ansible/plugins/shell/sh.py lib/ansible/plugins/shell/sh.py
@ -259,5 +241,4 @@ lib/ansible/plugins/strategy/__init__.py
lib/ansible/plugins/strategy/linear.py lib/ansible/plugins/strategy/linear.py
lib/ansible/template/__init__.py lib/ansible/template/__init__.py
lib/ansible/utils/encrypt.py lib/ansible/utils/encrypt.py
lib/ansible/utils/module_docs.py
lib/ansible/vars/__init__.py lib/ansible/vars/__init__.py

View file

@ -3,4 +3,3 @@ E114
E125 E125
E129 E129
E501 E501
E712