diff --git a/lib/ansible/module_utils/network/iosxr/iosxr.py b/lib/ansible/module_utils/network/iosxr/iosxr.py
index 8ab1cc0959..53ee00d387 100644
--- a/lib/ansible/module_utils/network/iosxr/iosxr.py
+++ b/lib/ansible/module_utils/network/iosxr/iosxr.py
@@ -152,7 +152,7 @@ def get_connection(module):
elif network_api == 'netconf':
module.connection = NetconfConnection(module._socket_path)
else:
- module.fail_json(msg='Invalid connection type {!s}'.format(network_api))
+ module.fail_json(msg='Invalid connection type {0!s}'.format(network_api))
return module.connection
@@ -318,7 +318,7 @@ def etree_findall(root, node):
def is_cliconf(module):
capabilities = get_device_capabilities(module)
- return True if capabilities.get('network_api') == 'cliconf' else False
+ return (capabilities.get('network_api') == 'cliconf')
def is_netconf(module):
diff --git a/lib/ansible/modules/cloud/amazon/aws_api_gateway.py b/lib/ansible/modules/cloud/amazon/aws_api_gateway.py
index 66f7a26c2a..f8cc2e263a 100644
--- a/lib/ansible/modules/cloud/amazon/aws_api_gateway.py
+++ b/lib/ansible/modules/cloud/amazon/aws_api_gateway.py
@@ -1,4 +1,6 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -181,7 +183,7 @@ def get_api_definitions(module, swagger_file=None, swagger_dict=None, swagger_te
with open(swagger_file) as f:
apidata = f.read()
except OSError as e:
- msg = "Failed trying to read swagger file {}: {}".format(str(swagger_file), str(e))
+ msg = "Failed trying to read swagger file {0}: {1}".format(str(swagger_file), str(e))
module.fail_json(msg=msg, exception=traceback.format_exc())
if swagger_dict is not None:
apidata = json.dumps(swagger_dict)
@@ -216,7 +218,7 @@ def delete_rest_api(module, client, api_id):
try:
delete_response = delete_api(client, api_id=api_id)
except (botocore.exceptions.ClientError, botocore.exceptions.EndpointConnectionError) as e:
- module.fail_json_aws(e, msg="deleting API {}".format(api_id))
+ module.fail_json_aws(e, msg="deleting API {0}".format(api_id))
return delete_response
@@ -235,7 +237,7 @@ def ensure_api_in_correct_state(module, client, api_id=None, api_data=None, stag
try:
configure_response = configure_api(client, api_data=api_data, api_id=api_id)
except (botocore.exceptions.ClientError, botocore.exceptions.EndpointConnectionError) as e:
- module.fail_json_aws(e, msg="configuring API {}".format(api_id))
+ module.fail_json_aws(e, msg="configuring API {0}".format(api_id))
deploy_response = None
@@ -244,7 +246,7 @@ def ensure_api_in_correct_state(module, client, api_id=None, api_data=None, stag
deploy_response = create_deployment(client, api_id=api_id, stage=stage,
description=deploy_desc)
except (botocore.exceptions.ClientError, botocore.exceptions.EndpointConnectionError) as e:
- msg = "deploying api {} to stage {}".format(api_id, stage)
+ msg = "deploying api {0} to stage {1}".format(api_id, stage)
module.fail_json_aws(e, msg)
return configure_response, deploy_response
diff --git a/lib/ansible/modules/cloud/amazon/aws_kms.py b/lib/ansible/modules/cloud/amazon/aws_kms.py
index f694a9a9f2..175404c8c6 100644
--- a/lib/ansible/modules/cloud/amazon/aws_kms.py
+++ b/lib/ansible/modules/cloud/amazon/aws_kms.py
@@ -1,18 +1,7 @@
#!/usr/bin/python
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see .
+# -*- coding: utf-8 -*
+
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -734,7 +723,7 @@ def get_arn_from_kms_alias(kms, aliasname):
key_id = a['TargetKeyId']
break
if not key_id:
- raise Exception('could not find alias {}'.format(aliasname))
+ raise Exception('could not find alias {0}'.format(aliasname))
# now that we have the ID for the key, we need to get the key's ARN. The alias
# has an ARN but we need the key itself.
@@ -742,14 +731,14 @@ def get_arn_from_kms_alias(kms, aliasname):
for k in ret['Keys']:
if k['KeyId'] == key_id:
return k['KeyArn']
- raise Exception('could not find key from id: {}'.format(key_id))
+ raise Exception('could not find key from id: {0}'.format(key_id))
def get_arn_from_role_name(iam, rolename):
ret = iam.get_role(RoleName=rolename)
if ret.get('Role') and ret['Role'].get('Arn'):
return ret['Role']['Arn']
- raise Exception('could not find arn for name {}.'.format(rolename))
+ raise Exception('could not find arn for name {0}.'.format(rolename))
def do_grant(kms, keyarn, role_arn, granttypes, mode='grant', dry_run=True, clean_invalid_entries=True):
@@ -826,7 +815,7 @@ def assert_policy_shape(policy):
'''Since the policy seems a little, uh, fragile, make sure we know approximately what we're looking at.'''
errors = []
if policy['Version'] != "2012-10-17":
- errors.append('Unknown version/date ({}) of policy. Things are probably different than we assumed they were.'.format(policy['Version']))
+ errors.append('Unknown version/date ({0}) of policy. Things are probably different than we assumed they were.'.format(policy['Version']))
found_statement_type = {}
for statement in policy['Statement']:
@@ -836,10 +825,10 @@ def assert_policy_shape(policy):
for statementtype in statement_label.keys():
if not found_statement_type.get(statementtype):
- errors.append('Policy is missing {}.'.format(statementtype))
+ errors.append('Policy is missing {0}.'.format(statementtype))
if len(errors):
- raise Exception('Problems asserting policy shape. Cowardly refusing to modify it: {}'.format(' '.join(errors)))
+ raise Exception('Problems asserting policy shape. Cowardly refusing to modify it: {0}'.format(' '.join(errors)))
return None
@@ -881,13 +870,13 @@ def main():
if module.params['role_name'] and not module.params['role_arn']:
module.params['role_arn'] = get_arn_from_role_name(iam, module.params['role_name'])
if not module.params['role_arn']:
- module.fail_json(msg='role_arn or role_name is required to {}'.format(module.params['mode']))
+ module.fail_json(msg='role_arn or role_name is required to {0}'.format(module.params['mode']))
# check the grant types for 'grant' only.
if mode == 'grant':
for g in module.params['grant_types']:
if g not in statement_label:
- module.fail_json(msg='{} is an unknown grant type.'.format(g))
+ module.fail_json(msg='{0} is an unknown grant type.'.format(g))
ret = do_grant(kms, module.params['key_arn'], module.params['role_arn'], module.params['grant_types'],
mode=mode,
diff --git a/lib/ansible/modules/cloud/amazon/ec2_eip.py b/lib/ansible/modules/cloud/amazon/ec2_eip.py
index badc5002d6..1811978cdb 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_eip.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_eip.py
@@ -1,4 +1,6 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -227,7 +229,7 @@ def _find_address_by_ip(ec2, public_ip):
try:
return ec2.get_all_addresses([public_ip])[0]
except boto.exception.EC2ResponseError as e:
- if "Address '{}' not found.".format(public_ip) not in e.message:
+ if "Address '{0}' not found.".format(public_ip) not in e.message:
raise
diff --git a/lib/ansible/modules/cloud/amazon/ecs_ecr.py b/lib/ansible/modules/cloud/amazon/ecs_ecr.py
index f0610cf9e0..f11a978806 100644
--- a/lib/ansible/modules/cloud/amazon/ecs_ecr.py
+++ b/lib/ansible/modules/cloud/amazon/ecs_ecr.py
@@ -1,4 +1,6 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -191,8 +193,8 @@ class EcsEcr:
if registry_id:
default_registry_id = self.sts.get_caller_identity().get('Account')
if registry_id != default_registry_id:
- raise Exception('Cannot create repository in registry {}.'
- 'Would be created in {} instead.'.format(
+ raise Exception('Cannot create repository in registry {0}.'
+ 'Would be created in {1} instead.'.format(
registry_id, default_registry_id))
if not self.check_mode:
repo = self.ecr.create_repository(repositoryName=name).get('repository')
@@ -216,9 +218,9 @@ class EcsEcr:
if self.get_repository(registry_id, name) is None:
printable = name
if registry_id:
- printable = '{}:{}'.format(registry_id, name)
+ printable = '{0}:{1}'.format(registry_id, name)
raise Exception(
- 'could not find repository {}'.format(printable))
+ 'could not find repository {0}'.format(printable))
return
def delete_repository(self, registry_id, name):
diff --git a/lib/ansible/modules/cloud/amazon/sns.py b/lib/ansible/modules/cloud/amazon/sns.py
index 9a391da3c2..d0781bc972 100644
--- a/lib/ansible/modules/cloud/amazon/sns.py
+++ b/lib/ansible/modules/cloud/amazon/sns.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2014, Michael J. Schultz
+# Copyright: (c) 2014, Michael J. Schultz
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -135,7 +135,7 @@ from ansible.module_utils.aws.core import AnsibleAWSModule
def arn_topic_lookup(module, client, short_topic):
- lookup_topic = ':{}'.format(short_topic)
+ lookup_topic = ':{0}'.format(short_topic)
try:
paginator = client.get_paginator('list_topics')
@@ -206,7 +206,7 @@ def main():
sns_kwargs['TopicArn'] = arn_topic_lookup(module, client, topic)
if not sns_kwargs['TopicArn']:
- module.fail_json(msg='Could not find topic: {}'.format(topic))
+ module.fail_json(msg='Could not find topic: {0}'.format(topic))
if sns_kwargs['MessageStructure'] == 'json':
sns_kwargs['Message'] = json.dumps(dict_msg)
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_acs.py b/lib/ansible/modules/cloud/azure/azure_rm_acs.py
index aa1525ff29..e7fbdaf589 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_acs.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_acs.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
-#
-# Copyright (c) 2017 Julien Stroheker,
-#
+# -*- coding: utf-8 -*
+
+# Copyright: (c) 2017, Julien Stroheker
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -545,7 +545,7 @@ class AzureRMContainerService(AzureRMModuleBase):
mastercount = self.master_profile[0].get('count')
if mastercount != 1 and mastercount != 3 and mastercount != 5:
- self.fail('Master Count number wrong : {} / should be 1 3 or 5'.format(mastercount))
+ self.fail('Master Count number wrong : {0} / should be 1 3 or 5'.format(mastercount))
# For now Agent Pool cannot be more than 1, just remove this part in the future if it change
agentpoolcount = len(self.agent_pool_profiles)
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_availabilityset_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_availabilityset_facts.py
index 31a5dc48dc..5ae281fada 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_availabilityset_facts.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_availabilityset_facts.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
-#
-# Copyright (c) 2016 Julien Stroheker,
+# -*- coding: utf-8 -*-
+# Copyright: (c) 2016, Julien Stroheker
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -126,7 +126,7 @@ class AzureRMAvailabilitySetFacts(AzureRMModuleBase):
def get_item(self):
"""Get a single availability set"""
- self.log('Get properties for {}'.format(self.name))
+ self.log('Get properties for {0}'.format(self.name))
item = None
result = []
@@ -153,7 +153,7 @@ class AzureRMAvailabilitySetFacts(AzureRMModuleBase):
try:
response = self.compute_client.availability_sets.list(self.resource_group)
except CloudError as exc:
- self.fail('Failed to list all items - {}'.format(str(exc)))
+ self.fail('Failed to list all items - {0}'.format(str(exc)))
results = []
for item in response:
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_functionapp.py b/lib/ansible/modules/cloud/azure/azure_rm_functionapp.py
index 3ce93d8407..c1a17e0e87 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_functionapp.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_functionapp.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
-#
-# Copyright (c) 2016 Thomas Stringer,
-#
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2016, Thomas Stringer
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -207,7 +207,7 @@ class AzureRMFunctionApp(AzureRMModuleBase):
)
self.results['changed'] = True
except CloudError as exc:
- self.fail('Failure while deleting web app: {}'.format(exc))
+ self.fail('Failure while deleting web app: {0}'.format(exc))
else:
self.results['changed'] = False
else:
@@ -235,7 +235,7 @@ class AzureRMFunctionApp(AzureRMModuleBase):
).result()
self.results['state'] = new_function_app.as_dict()
except CloudError as exc:
- self.fail('Error creating or updating web app: {}'.format(exc))
+ self.fail('Error creating or updating web app: {0}'.format(exc))
return self.results
@@ -289,7 +289,7 @@ class AzureRMFunctionApp(AzureRMModuleBase):
def storage_connection_string(self):
"""Construct the storage account connection string"""
- return 'DefaultEndpointsProtocol=https;AccountName={};AccountKey={}'.format(
+ return 'DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}'.format(
self.storage_account,
self.storage_key
)
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py b/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py
index 982bd6531c..c44d144239 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py
@@ -1,5 +1,7 @@
#!/usr/bin/python
-# Copyright (c) 2016 Thomas Stringer,
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2016, Thomas Stringer
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -782,7 +784,7 @@ class AzureRMLoadBalancer(AzureRMModuleBase):
def get_public_ip_address_instance(self, id):
"""Get a reference to the public ip address resource"""
- self.log('Fetching public ip address {}'.format(id))
+ self.log('Fetching public ip address {0}'.format(id))
resource_id = format_resource_id(id, self.subscription_id, 'Microsoft.Network', 'publicIPAddresses', self.resource_group)
return self.network_models.PublicIPAddress(id=resource_id)
@@ -844,7 +846,7 @@ def default_compare(new, old, path):
def frontend_ip_configuration_id(subscription_id, resource_group_name, load_balancer_name, name):
"""Generate the id for a frontend ip configuration"""
- return '/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Network/loadBalancers/{}/frontendIPConfigurations/{}'.format(
+ return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/loadBalancers/{2}/frontendIPConfigurations/{3}'.format(
subscription_id,
resource_group_name,
load_balancer_name,
@@ -854,7 +856,7 @@ def frontend_ip_configuration_id(subscription_id, resource_group_name, load_bala
def backend_address_pool_id(subscription_id, resource_group_name, load_balancer_name, name):
"""Generate the id for a backend address pool"""
- return '/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Network/loadBalancers/{}/backendAddressPools/{}'.format(
+ return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/loadBalancers/{2}/backendAddressPools/{3}'.format(
subscription_id,
resource_group_name,
load_balancer_name,
@@ -864,7 +866,7 @@ def backend_address_pool_id(subscription_id, resource_group_name, load_balancer_
def probe_id(subscription_id, resource_group_name, load_balancer_name, name):
"""Generate the id for a probe"""
- return '/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Network/loadBalancers/{}/probes/{}'.format(
+ return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/loadBalancers/{2}/probes/{3}'.format(
subscription_id,
resource_group_name,
load_balancer_name,
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer_facts.py
index 0ea3a882e3..ba976ffd61 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer_facts.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer_facts.py
@@ -1,22 +1,9 @@
#!/usr/bin/python
-#
-# Copyright (c) 2016 Thomas Stringer,
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see .
-#
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2016, Thomas Stringer
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@@ -136,7 +123,7 @@ class AzureRMLoadBalancerFacts(AzureRMModuleBase):
def get_item(self):
"""Get a single load balancer"""
- self.log('Get properties for {}'.format(self.name))
+ self.log('Get properties for {0}'.format(self.name))
item = None
result = []
@@ -160,12 +147,12 @@ class AzureRMLoadBalancerFacts(AzureRMModuleBase):
try:
response = self.network_client.load_balancers.list(self.resource_group)
except AzureHttpError as exc:
- self.fail('Failed to list items in resource group {} - {}'.format(self.resource_group, str(exc)))
+ self.fail('Failed to list items in resource group {0} - {1}'.format(self.resource_group, str(exc)))
else:
try:
response = self.network_client.load_balancers.list_all()
except AzureHttpError as exc:
- self.fail('Failed to list all items - {}'.format(str(exc)))
+ self.fail('Failed to list all items - {0}'.format(str(exc)))
results = []
for item in response:
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_managed_disk_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_managed_disk_facts.py
index 1664613024..3dc3df4b75 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_managed_disk_facts.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_managed_disk_facts.py
@@ -1,21 +1,10 @@
#!/usr/bin/python
-#
-# Copyright (c) 2016 Bruno Medina Bolanos Cacho,
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2016, Bruno Medina Bolanos Cacho
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@@ -202,7 +191,7 @@ class AzureRMManagedDiskFacts(AzureRMModuleBase):
try:
response = self.compute_client.disks.list()
except CloudError as exc:
- self.fail('Failed to list all items - {}'.format(str(exc)))
+ self.fail('Failed to list all items - {0}'.format(str(exc)))
results = []
for item in response:
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py
index bdd19fa3e4..504e8acbe2 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
-#
-# Copyright (c) 2017 Sertac Ozercan,
+# -*- coding: utf-8 -*-
+# Copyright: (c) 2017, Sertac Ozercan
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -373,7 +373,7 @@ class AzureRMVirtualMachineScaleSetFacts(AzureRMModuleBase):
def get_item(self):
"""Get a single virtual machine scale set"""
- self.log('Get properties for {}'.format(self.name))
+ self.log('Get properties for {0}'.format(self.name))
item = None
results = []
@@ -396,7 +396,7 @@ class AzureRMVirtualMachineScaleSetFacts(AzureRMModuleBase):
try:
response = self.compute_client.virtual_machine_scale_sets.list(self.resource_group)
except CloudError as exc:
- self.fail('Failed to list all items - {}'.format(str(exc)))
+ self.fail('Failed to list all items - {0}'.format(str(exc)))
results = []
for item in response:
diff --git a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_block_storage.py b/lib/ansible/modules/cloud/digital_ocean/digital_ocean_block_storage.py
index ea123e72b8..f3e88787b7 100644
--- a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_block_storage.py
+++ b/lib/ansible/modules/cloud/digital_ocean/digital_ocean_block_storage.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-#
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -127,7 +127,7 @@ class DOBlockStorage(object):
return v
def poll_action_for_complete_status(self, action_id):
- url = 'actions/{}'.format(action_id)
+ url = 'actions/{0}'.format(action_id)
end_time = time.time() + self.module.params['timeout']
while time.time() < end_time:
time.sleep(2)
@@ -142,7 +142,7 @@ class DOBlockStorage(object):
raise DOBlockStorageException('Unable to reach api.digitalocean.com')
def get_attached_droplet_ID(self, volume_name, region):
- url = 'volumes?name={}®ion={}'.format(volume_name, region)
+ url = 'volumes?name={0}®ion={1}'.format(volume_name, region)
response = self.rest.get(url)
status = response.status_code
json = response.json
@@ -207,7 +207,7 @@ class DOBlockStorage(object):
def delete_block_storage(self):
volume_name = self.get_key_or_fail('volume_name')
region = self.get_key_or_fail('region')
- url = 'volumes?name={}®ion={}'.format(volume_name, region)
+ url = 'volumes?name={0}®ion={1}'.format(volume_name, region)
attached_droplet_id = self.get_attached_droplet_ID(volume_name, region)
if attached_droplet_id is not None:
self.attach_detach_block_storage('detach', volume_name, region, attached_droplet_id)
diff --git a/lib/ansible/modules/cloud/google/gce_instance_template.py b/lib/ansible/modules/cloud/google/gce_instance_template.py
index c2a3afc9f8..e5e99e19e9 100644
--- a/lib/ansible/modules/cloud/google/gce_instance_template.py
+++ b/lib/ansible/modules/cloud/google/gce_instance_template.py
@@ -1,4 +1,6 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -416,7 +418,7 @@ def create_instance_template(module, gce):
changed = True
except GoogleBaseError as err:
module.fail_json(
- msg='Unexpected error attempting to create instance {}, error: {}'
+ msg='Unexpected error attempting to create instance {0}, error: {1}'
.format(
instance,
err.value
diff --git a/lib/ansible/modules/cloud/lxd/lxd_container.py b/lib/ansible/modules/cloud/lxd/lxd_container.py
index 29af63f10a..2119e70e88 100644
--- a/lib/ansible/modules/cloud/lxd/lxd_container.py
+++ b/lib/ansible/modules/cloud/lxd/lxd_container.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Hiroaki Nakamura
+# Copyright: (c) 2016, Hiroaki Nakamura
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -585,11 +585,11 @@ def main():
),
key_file=dict(
type='str',
- default='{}/.config/lxc/client.key'.format(os.environ['HOME'])
+ default='{0}/.config/lxc/client.key'.format(os.environ['HOME'])
),
cert_file=dict(
type='str',
- default='{}/.config/lxc/client.crt'.format(os.environ['HOME'])
+ default='{0}/.config/lxc/client.crt'.format(os.environ['HOME'])
),
trust_password=dict(type='str', no_log=True)
),
diff --git a/lib/ansible/modules/cloud/lxd/lxd_profile.py b/lib/ansible/modules/cloud/lxd/lxd_profile.py
index 524fa4a87d..d1bffddae1 100644
--- a/lib/ansible/modules/cloud/lxd/lxd_profile.py
+++ b/lib/ansible/modules/cloud/lxd/lxd_profile.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Hiroaki Nakamura
+# Copyright: (c) 2016, Hiroaki Nakamura
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -263,7 +263,7 @@ class LXDProfileManagement(object):
def _rename_profile(self):
config = {'name': self.new_name}
- self.client.do('POST', '/1.0/profiles/{}'.format(self.name), config)
+ self.client.do('POST', '/1.0/profiles/{0}'.format(self.name), config)
self.actions.append('rename')
self.name = self.new_name
@@ -284,11 +284,11 @@ class LXDProfileManagement(object):
config = self.old_profile_json.copy()
for k, v in self.config.items():
config[k] = v
- self.client.do('PUT', '/1.0/profiles/{}'.format(self.name), config)
+ self.client.do('PUT', '/1.0/profiles/{0}'.format(self.name), config)
self.actions.append('apply_profile_configs')
def _delete_profile(self):
- self.client.do('DELETE', '/1.0/profiles/{}'.format(self.name))
+ self.client.do('DELETE', '/1.0/profiles/{0}'.format(self.name))
self.actions.append('delete')
def run(self):
@@ -354,11 +354,11 @@ def main():
),
key_file=dict(
type='str',
- default='{}/.config/lxc/client.key'.format(os.environ['HOME'])
+ default='{0}/.config/lxc/client.key'.format(os.environ['HOME'])
),
cert_file=dict(
type='str',
- default='{}/.config/lxc/client.crt'.format(os.environ['HOME'])
+ default='{0}/.config/lxc/client.crt'.format(os.environ['HOME'])
),
trust_password=dict(type='str', no_log=True)
),
diff --git a/lib/ansible/modules/cloud/misc/proxmox_kvm.py b/lib/ansible/modules/cloud/misc/proxmox_kvm.py
index e79c438050..260516babc 100644
--- a/lib/ansible/modules/cloud/misc/proxmox_kvm.py
+++ b/lib/ansible/modules/cloud/misc/proxmox_kvm.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Abdoul Bah (@helldorado)
+# Copyright: (c) 2016, Abdoul Bah (@helldorado)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -675,7 +675,7 @@ def create_vm(module, proxmox, vmid, newid, node, name, memory, cpu, cores, sock
valid_clone_params = ['format', 'full', 'pool', 'snapname', 'storage', 'target']
clone_params = {}
# Default args for vm. Note: -args option is for experts only. It allows you to pass arbitrary arguments to kvm.
- vm_args = "-serial unix:/var/run/qemu-server/{}.serial,server,nowait".format(vmid)
+ vm_args = "-serial unix:/var/run/qemu-server/{0}.serial,server,nowait".format(vmid)
proxmox_node = proxmox.nodes(node)
@@ -909,7 +909,7 @@ def main():
try:
vmid = get_nextvmid(module, proxmox)
except Exception as e:
- module.fail_json(msg="Can't get the next vmid for VM {} automatically. Ensure your cluster state is good".format(name))
+ module.fail_json(msg="Can't get the next vmid for VM {0} automatically. Ensure your cluster state is good".format(name))
else:
try:
if not clone:
@@ -918,9 +918,9 @@ def main():
vmid = get_vmid(proxmox, clone)[0]
except Exception as e:
if not clone:
- module.fail_json(msg="VM {} does not exist in cluster.".format(name))
+ module.fail_json(msg="VM {0} does not exist in cluster.".format(name))
else:
- module.fail_json(msg="VM {} does not exist in cluster.".format(clone))
+ module.fail_json(msg="VM {0} does not exist in cluster.".format(clone))
if clone is not None:
if get_vmid(proxmox, name):
@@ -933,7 +933,7 @@ def main():
try:
newid = get_nextvmid(module, proxmox)
except Exception as e:
- module.fail_json(msg="Can't get the next vmid for VM {} automatically. Ensure your cluster state is good".format(name))
+ module.fail_json(msg="Can't get the next vmid for VM {0} automatically. Ensure your cluster state is good".format(name))
else:
vm = get_vm(proxmox, newid)
if vm:
@@ -942,15 +942,15 @@ def main():
if delete is not None:
try:
settings(module, proxmox, vmid, node, name, timeout, delete=delete)
- module.exit_json(changed=True, msg="Settings has deleted on VM {} with vmid {}".format(name, vmid))
+ module.exit_json(changed=True, msg="Settings has deleted on VM {0} with vmid {1}".format(name, vmid))
except Exception as e:
- module.fail_json(msg='Unable to delete settings on VM {} with vmid {}: '.format(name, vmid) + str(e))
+ module.fail_json(msg='Unable to delete settings on VM {0} with vmid {1}: '.format(name, vmid) + str(e))
elif revert is not None:
try:
settings(module, proxmox, vmid, node, name, timeout, revert=revert)
- module.exit_json(changed=True, msg="Settings has reverted on VM {} with vmid {}".format(name, vmid))
+ module.exit_json(changed=True, msg="Settings has reverted on VM {0} with vmid {1}".format(name, vmid))
except Exception as e:
- module.fail_json(msg='Unable to revert settings on VM {} with vmid {}: Maybe is not a pending task... '.format(name, vmid) + str(e))
+ module.fail_json(msg='Unable to revert settings on VM {0} with vmid {1}: Maybe is not a pending task... '.format(name, vmid) + str(e))
if state == 'present':
try:
@@ -1031,9 +1031,9 @@ def main():
module.exit_json(changed=True, msg="VM %s with vmid %s deployed" % (name, vmid), **results)
except Exception as e:
if update:
- module.fail_json(msg="Unable to update vm {} with vmid {}=".format(name, vmid) + str(e))
+ module.fail_json(msg="Unable to update vm {0} with vmid {1}=".format(name, vmid) + str(e))
elif clone is not None:
- module.fail_json(msg="Unable to clone vm {} from vmid {}=".format(name, vmid) + str(e))
+ module.fail_json(msg="Unable to clone vm {0} from vmid {1}=".format(name, vmid) + str(e))
else:
module.fail_json(msg="creation of %s VM %s with vmid %s failed with exception=%s" % (VZ_TYPE, name, vmid, e))
@@ -1111,7 +1111,7 @@ def main():
if status:
module.exit_json(changed=False, msg="VM %s with vmid = %s is %s" % (name, vmid, current), **status)
except Exception as e:
- module.fail_json(msg="Unable to get vm {} with vmid = {} status: ".format(name, vmid) + str(e))
+ module.fail_json(msg="Unable to get vm {0} with vmid = {1} status: ".format(name, vmid) + str(e))
if __name__ == '__main__':
diff --git a/lib/ansible/modules/cloud/misc/serverless.py b/lib/ansible/modules/cloud/misc/serverless.py
index 49f43224d5..de58b07cd6 100644
--- a/lib/ansible/modules/cloud/misc/serverless.py
+++ b/lib/ansible/modules/cloud/misc/serverless.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Ryan Scott Brown
+# Copyright: (c) 2016, Ryan Scott Brown
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -147,9 +147,9 @@ def read_serverless_config(module):
config = yaml.safe_load(sls_config.read())
return config
except IOError as e:
- module.fail_json(msg="Could not open serverless.yml in {}. err: {}".format(path, str(e)), exception=traceback.format_exc())
+ module.fail_json(msg="Could not open serverless.yml in {0}. err: {1}".format(path, str(e)), exception=traceback.format_exc())
- module.fail_json(msg="Failed to open serverless config at {}".format(
+ module.fail_json(msg="Failed to open serverless config at {0}".format(
os.path.join(path, 'serverless.yml')))
@@ -159,9 +159,9 @@ def get_service_name(module, stage):
module.fail_json(msg="Could not read `service` key from serverless.yml file")
if stage:
- return "{}-{}".format(config['service'], stage)
+ return "{0}-{1}".format(config['service'], stage)
- return "{}-{}".format(config['service'], config.get('stage', 'dev'))
+ return "{0}-{1}".format(config['service'], config.get('stage', 'dev'))
def main():
@@ -202,7 +202,7 @@ def main():
elif state == 'absent':
command += 'remove '
else:
- module.fail_json(msg="State must either be 'present' or 'absent'. Received: {}".format(state))
+ module.fail_json(msg="State must either be 'present' or 'absent'. Received: {0}".format(state))
if state == 'present':
if not deploy:
@@ -211,19 +211,19 @@ def main():
command += '--force '
if region:
- command += '--region {} '.format(region)
+ command += '--region {0} '.format(region)
if stage:
- command += '--stage {} '.format(stage)
+ command += '--stage {0} '.format(stage)
if verbose:
command += '--verbose '
rc, out, err = module.run_command(command, cwd=service_path)
if rc != 0:
- if state == 'absent' and "-{}' does not exist".format(stage) in out:
+ if state == 'absent' and "-{0}' does not exist".format(stage) in out:
module.exit_json(changed=False, state='absent', command=command,
out=out, service_name=get_service_name(module, stage))
- module.fail_json(msg="Failure when executing Serverless command. Exited {}.\nstdout: {}\nstderr: {}".format(rc, out, err))
+ module.fail_json(msg="Failure when executing Serverless command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(rc, out, err))
# gather some facts about the deployment
module.exit_json(changed=True, state='present', out=out, command=command,
diff --git a/lib/ansible/modules/cloud/univention/udm_dns_record.py b/lib/ansible/modules/cloud/univention/udm_dns_record.py
index 4b73f406f6..1955db5d98 100644
--- a/lib/ansible/modules/cloud/univention/udm_dns_record.py
+++ b/lib/ansible/modules/cloud/univention/udm_dns_record.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
-# Copyright (c) 2016, Adfinis SyGroup AG
+# Copyright: (c) 2016, Adfinis SyGroup AG
# Tobias Rueetschi
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -125,13 +125,13 @@ def main():
changed = False
obj = list(ldap_search(
- '(&(objectClass=dNSZone)(zoneName={})(relativeDomainName={}))'.format(zone, name),
+ '(&(objectClass=dNSZone)(zoneName={0})(relativeDomainName={1}))'.format(zone, name),
attr=['dNSZone']
))
exists = bool(len(obj))
- container = 'zoneName={},cn=dns,{}'.format(zone, base_dn())
- dn = 'relativeDomainName={},{}'.format(name, container)
+ container = 'zoneName={0},cn=dns,{1}'.format(zone, base_dn())
+ dn = 'relativeDomainName={0},{1}'.format(name, container)
if state == 'present':
try:
@@ -139,17 +139,17 @@ def main():
so = forward_zone.lookup(
config(),
uldap(),
- '(zone={})'.format(zone),
+ '(zone={0})'.format(zone),
scope='domain',
) or reverse_zone.lookup(
config(),
uldap(),
- '(zone={})'.format(zone),
+ '(zone={0})'.format(zone),
scope='domain',
)
- obj = umc_module_for_add('dns/{}'.format(type), container, superordinate=so[0])
+ obj = umc_module_for_add('dns/{0}'.format(type), container, superordinate=so[0])
else:
- obj = umc_module_for_edit('dns/{}'.format(type), dn)
+ obj = umc_module_for_edit('dns/{0}'.format(type), dn)
obj['name'] = name
for k, v in data.items():
obj[k] = v
@@ -162,18 +162,18 @@ def main():
obj.modify()
except Exception as e:
module.fail_json(
- msg='Creating/editing dns entry {} in {} failed: {}'.format(name, container, e)
+ msg='Creating/editing dns entry {0} in {1} failed: {2}'.format(name, container, e)
)
if state == 'absent' and exists:
try:
- obj = umc_module_for_edit('dns/{}'.format(type), dn)
+ obj = umc_module_for_edit('dns/{0}'.format(type), dn)
if not module.check_mode:
obj.remove()
changed = True
except Exception as e:
module.fail_json(
- msg='Removing dns entry {} in {} failed: {}'.format(name, container, e)
+ msg='Removing dns entry {0} in {1} failed: {2}'.format(name, container, e)
)
module.exit_json(
diff --git a/lib/ansible/modules/cloud/univention/udm_dns_zone.py b/lib/ansible/modules/cloud/univention/udm_dns_zone.py
index 6dab63581a..261e67149a 100644
--- a/lib/ansible/modules/cloud/univention/udm_dns_zone.py
+++ b/lib/ansible/modules/cloud/univention/udm_dns_zone.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
-# Copyright (c) 2016, Adfinis SyGroup AG
+# Copyright: (c) 2016, Adfinis SyGroup AG
# Tobias Rueetschi
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -122,7 +122,7 @@ def convert_time(time):
return ('0', 'seconds')
for unit in units:
if time >= unit[0]:
- return ('{}'.format(time // unit[0]), unit[1])
+ return ('{0}'.format(time // unit[0]), unit[1])
def main():
@@ -172,22 +172,22 @@ def main():
changed = False
obj = list(ldap_search(
- '(&(objectClass=dNSZone)(zoneName={}))'.format(zone),
+ '(&(objectClass=dNSZone)(zoneName={0}))'.format(zone),
attr=['dNSZone']
))
exists = bool(len(obj))
- container = 'cn=dns,{}'.format(base_dn())
- dn = 'zoneName={},{}'.format(zone, container)
+ container = 'cn=dns,{0}'.format(base_dn())
+ dn = 'zoneName={0},{1}'.format(zone, container)
if contact == '':
- contact = 'root@{}.'.format(zone)
+ contact = 'root@{0}.'.format(zone)
if state == 'present':
try:
if not exists:
- obj = umc_module_for_add('dns/{}'.format(type), container)
+ obj = umc_module_for_add('dns/{0}'.format(type), container)
else:
- obj = umc_module_for_edit('dns/{}'.format(type), dn)
+ obj = umc_module_for_edit('dns/{0}'.format(type), dn)
obj['zone'] = zone
obj['nameserver'] = nameserver
obj['a'] = interfaces
@@ -211,18 +211,18 @@ def main():
obj.modify()
except Exception as e:
module.fail_json(
- msg='Creating/editing dns zone {} failed: {}'.format(zone, e)
+ msg='Creating/editing dns zone {0} failed: {1}'.format(zone, e)
)
if state == 'absent' and exists:
try:
- obj = umc_module_for_edit('dns/{}'.format(type), dn)
+ obj = umc_module_for_edit('dns/{0}'.format(type), dn)
if not module.check_mode:
obj.remove()
changed = True
except Exception as e:
module.fail_json(
- msg='Removing dns zone {} failed: {}'.format(zone, e)
+ msg='Removing dns zone {0} failed: {1}'.format(zone, e)
)
module.exit_json(
diff --git a/lib/ansible/modules/cloud/univention/udm_group.py b/lib/ansible/modules/cloud/univention/udm_group.py
index 485acdc0d7..f5a63915cd 100644
--- a/lib/ansible/modules/cloud/univention/udm_group.py
+++ b/lib/ansible/modules/cloud/univention/udm_group.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
-# Copyright (c) 2016, Adfinis SyGroup AG
+# Copyright: (c) 2016, Adfinis SyGroup AG
# Tobias Rueetschi
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -114,18 +114,18 @@ def main():
changed = False
groups = list(ldap_search(
- '(&(objectClass=posixGroup)(cn={}))'.format(name),
+ '(&(objectClass=posixGroup)(cn={0}))'.format(name),
attr=['cn']
))
if position != '':
container = position
else:
if ou != '':
- ou = 'ou={},'.format(ou)
+ ou = 'ou={0},'.format(ou)
if subpath != '':
- subpath = '{},'.format(subpath)
- container = '{}{}{}'.format(subpath, ou, base_dn())
- group_dn = 'cn={},{}'.format(name, container)
+ subpath = '{0},'.format(subpath)
+ container = '{0}{1}{2}'.format(subpath, ou, base_dn())
+ group_dn = 'cn={0},{1}'.format(name, container)
exists = bool(len(groups))
@@ -146,7 +146,7 @@ def main():
grp.modify()
except Exception:
module.fail_json(
- msg="Creating/editing group {} in {} failed".format(name, container)
+ msg="Creating/editing group {0} in {1} failed".format(name, container)
)
if state == 'absent' and exists:
@@ -157,7 +157,7 @@ def main():
changed = True
except Exception:
module.fail_json(
- msg="Removing group {} failed".format(name)
+ msg="Removing group {0} failed".format(name)
)
module.exit_json(
diff --git a/lib/ansible/modules/cloud/univention/udm_share.py b/lib/ansible/modules/cloud/univention/udm_share.py
index bcf0909e7a..133bd400be 100644
--- a/lib/ansible/modules/cloud/univention/udm_share.py
+++ b/lib/ansible/modules/cloud/univention/udm_share.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
-# Copyright (c) 2016, Adfinis SyGroup AG
+# Copyright: (c) 2016, Adfinis SyGroup AG
# Tobias Rueetschi
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -479,13 +479,13 @@ def main():
changed = False
obj = list(ldap_search(
- '(&(objectClass=univentionShare)(cn={}))'.format(name),
+ '(&(objectClass=univentionShare)(cn={0}))'.format(name),
attr=['cn']
))
exists = bool(len(obj))
- container = 'cn=shares,ou={},{}'.format(module.params['ou'], base_dn())
- dn = 'cn={},{}'.format(name, container)
+ container = 'cn=shares,ou={0},{1}'.format(module.params['ou'], base_dn())
+ dn = 'cn={0},{1}'.format(name, container)
if state == 'present':
try:
@@ -494,7 +494,7 @@ def main():
else:
obj = umc_module_for_edit('shares/share', dn)
- module.params['printablename'] = '{} ({})'.format(name, module.params['host'])
+ module.params['printablename'] = '{0} ({1})'.format(name, module.params['host'])
for k in obj.keys():
if module.params[k] is True:
module.params[k] = '1'
@@ -516,7 +516,7 @@ def main():
obj.modify()
except Exception as err:
module.fail_json(
- msg='Creating/editing share {} in {} failed: {}'.format(
+ msg='Creating/editing share {0} in {1} failed: {2}'.format(
name,
container,
err,
@@ -531,7 +531,7 @@ def main():
changed = True
except Exception as err:
module.fail_json(
- msg='Removing share {} in {} failed: {}'.format(
+ msg='Removing share {0} in {1} failed: {2}'.format(
name,
container,
err,
diff --git a/lib/ansible/modules/cloud/univention/udm_user.py b/lib/ansible/modules/cloud/univention/udm_user.py
index e6a74224fa..9c456844ec 100644
--- a/lib/ansible/modules/cloud/univention/udm_user.py
+++ b/lib/ansible/modules/cloud/univention/udm_user.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
-# Copyright (c) 2016, Adfinis SyGroup AG
+# Copyright: (c) 2016, Adfinis SyGroup AG
# Tobias Rueetschi
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -415,18 +415,18 @@ def main():
changed = False
users = list(ldap_search(
- '(&(objectClass=posixAccount)(uid={}))'.format(username),
+ '(&(objectClass=posixAccount)(uid={0}))'.format(username),
attr=['uid']
))
if position != '':
container = position
else:
if ou != '':
- ou = 'ou={},'.format(ou)
+ ou = 'ou={0},'.format(ou)
if subpath != '':
- subpath = '{},'.format(subpath)
- container = '{}{}{}'.format(subpath, ou, base_dn())
- user_dn = 'uid={},{}'.format(username, container)
+ subpath = '{0},'.format(subpath)
+ container = '{0}{1}{2}'.format(subpath, ou, base_dn())
+ user_dn = 'uid={0},{1}'.format(username, container)
exists = bool(len(users))
@@ -438,12 +438,12 @@ def main():
obj = umc_module_for_edit('users/user', user_dn)
if module.params['displayName'] is None:
- module.params['displayName'] = '{} {}'.format(
+ module.params['displayName'] = '{0} {1}'.format(
module.params['firstname'],
module.params['lastname']
)
if module.params['unixhome'] is None:
- module.params['unixhome'] = '/home/{}'.format(
+ module.params['unixhome'] = '/home/{0}'.format(
module.params['username']
)
for k in obj.keys():
@@ -479,7 +479,7 @@ def main():
obj.modify()
except Exception:
module.fail_json(
- msg="Creating/editing user {} in {} failed".format(
+ msg="Creating/editing user {0} in {1} failed".format(
username,
container
)
@@ -487,7 +487,7 @@ def main():
try:
groups = module.params['groups']
if groups:
- filter = '(&(objectClass=posixGroup)(|(cn={})))'.format(
+ filter = '(&(objectClass=posixGroup)(|(cn={0})))'.format(
')(cn='.join(groups)
)
group_dns = list(ldap_search(filter, attr=['dn']))
@@ -500,7 +500,7 @@ def main():
changed = True
except Exception:
module.fail_json(
- msg="Adding groups to user {} failed".format(username)
+ msg="Adding groups to user {0} failed".format(username)
)
if state == 'absent' and exists:
@@ -511,7 +511,7 @@ def main():
changed = True
except Exception:
module.fail_json(
- msg="Removing user {} failed".format(username)
+ msg="Removing user {0} failed".format(username)
)
module.exit_json(
diff --git a/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py b/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py
index 26eb0840dd..224744c488 100644
--- a/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py
+++ b/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py
@@ -128,7 +128,7 @@ class VMwareConfigurationBackup(PyVmomi):
def load_configuration(self):
if not os.path.isfile(self.src):
- self.module.fail_json(msg="Source file {} does not exist".format(self.src))
+ self.module.fail_json(msg="Source file {0} does not exist".format(self.src))
url = self.host.configManager.firmwareSystem.QueryFirmwareConfigUploadURL()
url = url.replace('*', self.host.name)
diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_app.py b/lib/ansible/modules/cloud/webfaction/webfaction_app.py
index b1629e7d45..3e93eb9697 100644
--- a/lib/ansible/modules/cloud/webfaction/webfaction_app.py
+++ b/lib/ansible/modules/cloud/webfaction/webfaction_app.py
@@ -1,11 +1,12 @@
#!/usr/bin/python
-#
-# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2015, Quentin Stafford-Fraser, with contributions gratefully acknowledged from:
# * Andy Baker
# * Federico Tarantini
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
+
# Create a Webfaction application using Ansible and the Webfaction API
#
# Valid application types can be found by looking here:
@@ -183,7 +184,7 @@ def main():
)
else:
- module.fail_json(msg="Unknown state specified: {}".format(app_state))
+ module.fail_json(msg="Unknown state specified: {0}".format(app_state))
module.exit_json(
changed=True,
diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_db.py b/lib/ansible/modules/cloud/webfaction/webfaction_db.py
index 2951739b1d..6bf819fbf2 100644
--- a/lib/ansible/modules/cloud/webfaction/webfaction_db.py
+++ b/lib/ansible/modules/cloud/webfaction/webfaction_db.py
@@ -1,11 +1,12 @@
#!/usr/bin/python
-#
-# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2015, Quentin Stafford-Fraser, with contributions gratefully acknowledged from:
# * Andy Baker
# * Federico Tarantini
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
+
# Create a webfaction database using Ansible and the Webfaction API
from __future__ import absolute_import, division, print_function
@@ -181,7 +182,7 @@ def main():
)
else:
- module.fail_json(msg="Unknown state specified: {}".format(db_state))
+ module.fail_json(msg="Unknown state specified: {0}".format(db_state))
module.exit_json(
changed=True,
diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_domain.py b/lib/ansible/modules/cloud/webfaction/webfaction_domain.py
index 3bea294337..cb6d8f317c 100644
--- a/lib/ansible/modules/cloud/webfaction/webfaction_domain.py
+++ b/lib/ansible/modules/cloud/webfaction/webfaction_domain.py
@@ -1,8 +1,9 @@
#!/usr/bin/python
-#
-# (c) Quentin Stafford-Fraser 2015
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2015, Quentin Stafford-Fraser
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
+
# Create Webfaction domains and subdomains using Ansible and the Webfaction API
from __future__ import absolute_import, division, print_function
@@ -155,7 +156,7 @@ def main():
)
else:
- module.fail_json(msg="Unknown state specified: {}".format(domain_state))
+ module.fail_json(msg="Unknown state specified: {0}".format(domain_state))
module.exit_json(
changed=True,
diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py b/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
index 73a94fe24f..c2fed9321c 100644
--- a/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
+++ b/lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
@@ -1,8 +1,9 @@
#!/usr/bin/python
-#
-# (c) Quentin Stafford-Fraser and Andy Baker 2015
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2015, Quentin Stafford-Fraser and Andy Baker
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
+
# Create webfaction mailbox using Ansible and the Webfaction API
from __future__ import absolute_import, division, print_function
@@ -126,7 +127,7 @@ def main():
result.update(webfaction.delete_mailbox(session_id, mailbox_name))
else:
- module.fail_json(msg="Unknown state specified: {}".format(site_state))
+ module.fail_json(msg="Unknown state specified: {0}".format(site_state))
module.exit_json(changed=True, result=result)
diff --git a/lib/ansible/modules/cloud/webfaction/webfaction_site.py b/lib/ansible/modules/cloud/webfaction/webfaction_site.py
index 763b61316e..b88c7b2472 100644
--- a/lib/ansible/modules/cloud/webfaction/webfaction_site.py
+++ b/lib/ansible/modules/cloud/webfaction/webfaction_site.py
@@ -1,7 +1,9 @@
#!/usr/bin/python
-# (c) Quentin Stafford-Fraser 2015
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2015, Quentin Stafford-Fraser
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
+
# Create Webfaction website using Ansible and the Webfaction API
from __future__ import absolute_import, division, print_function
@@ -190,7 +192,7 @@ def main():
)
else:
- module.fail_json(msg="Unknown state specified: {}".format(site_state))
+ module.fail_json(msg="Unknown state specified: {0}".format(site_state))
module.exit_json(
changed=True,
diff --git a/lib/ansible/modules/monitoring/grafana_plugin.py b/lib/ansible/modules/monitoring/grafana_plugin.py
index d737e92fea..cad8a24867 100644
--- a/lib/ansible/modules/monitoring/grafana_plugin.py
+++ b/lib/ansible/modules/monitoring/grafana_plugin.py
@@ -106,15 +106,15 @@ def grafana_cli_bin(params):
raise GrafanaCliException('grafana-cli binary is not present or not in PATH')
else:
if 'grafana_plugin_url' in params and params['grafana_plugin_url']:
- grafana_cli = '{} {} {}'.format(grafana_cli, '--pluginUrl', params['grafana_plugin_url'])
+ grafana_cli = '{0} {1} {2}'.format(grafana_cli, '--pluginUrl', params['grafana_plugin_url'])
if 'grafana_plugins_dir' in params and params['grafana_plugins_dir']:
- grafana_cli = '{} {} {}'.format(grafana_cli, '--pluginsDir', params['grafana_plugins_dir'])
+ grafana_cli = '{0} {1} {2}'.format(grafana_cli, '--pluginsDir', params['grafana_plugins_dir'])
if 'grafana_repo' in params and params['grafana_repo']:
- grafana_cli = '{} {} {}'.format(grafana_cli, '--repo', params['grafana_repo'])
+ grafana_cli = '{0} {1} {2}'.format(grafana_cli, '--repo', params['grafana_repo'])
if 'validate_certs' in params and params['validate_certs'] is False:
- grafana_cli = '{} {}'.format(grafana_cli, '--insecure')
+ grafana_cli = '{0} {1}'.format(grafana_cli, '--insecure')
- return '{} {}'.format(grafana_cli, 'plugins')
+ return '{0} {1}'.format(grafana_cli, 'plugins')
def get_grafana_plugin_version(module, params):
@@ -125,7 +125,7 @@ def get_grafana_plugin_version(module, params):
:param params: ansible module params.
'''
grafana_cli = grafana_cli_bin(params)
- rc, stdout, stderr = module.run_command('{} ls'.format(grafana_cli))
+ rc, stdout, stderr = module.run_command('{0} ls'.format(grafana_cli))
stdout_lines = stdout.split("\n")
for line in stdout_lines:
if line.find(' @ ') != -1:
@@ -155,9 +155,9 @@ def grafana_plugin(module, params):
'version': grafana_plugin_version}
else:
if params['version'] == 'latest' or params['version'] is None:
- cmd = '{} update {}'.format(grafana_cli, params['name'])
+ cmd = '{0} update {1}'.format(grafana_cli, params['name'])
else:
- cmd = '{} install {} {}'.format(grafana_cli, params['name'], params['version'])
+ cmd = '{0} install {1} {2}'.format(grafana_cli, params['name'], params['version'])
else:
return {'msg': 'Grafana plugin already installed',
'changed': False,
@@ -165,13 +165,13 @@ def grafana_plugin(module, params):
else:
if 'version' in params:
if params['version'] == 'latest' or params['version'] is None:
- cmd = '{} install {}'.format(grafana_cli, params['name'])
+ cmd = '{0} install {1}'.format(grafana_cli, params['name'])
else:
- cmd = '{} install {} {}'.format(grafana_cli, params['name'], params['version'])
+ cmd = '{0} install {1} {2}'.format(grafana_cli, params['name'], params['version'])
else:
- cmd = '{} install {}'.format(grafana_cli, params['name'])
+ cmd = '{0} install {1}'.format(grafana_cli, params['name'])
else:
- cmd = '{} uninstall {}'.format(grafana_cli, params['name'])
+ cmd = '{0} uninstall {1}'.format(grafana_cli, params['name'])
rc, stdout, stderr = module.run_command(cmd)
if rc == 0:
@@ -183,11 +183,11 @@ def grafana_plugin(module, params):
plugin_name, plugin_version = line.split(' @ ')
else:
plugin_version = None
- return {'msg': 'Grafana plugin {} installed : {}'.format(params['name'], cmd),
+ return {'msg': 'Grafana plugin {0} installed : {1}'.format(params['name'], cmd),
'changed': True,
'version': plugin_version}
else:
- raise GrafanaCliException("'{}' execution returned an error : [{}] {} {}".format(cmd, rc, stdout, stderr))
+ raise GrafanaCliException("'{0}' execution returned an error : [{1}] {2} {3}".format(cmd, rc, stdout, stderr))
def main():
@@ -210,13 +210,13 @@ def main():
except GrafanaCliException as e:
module.fail_json(
failed=True,
- msg="{}".format(e)
+ msg="{0}".format(e)
)
return
except Exception as e:
module.fail_json(
failed=True,
- msg="{} : {} ".format(type(e), e)
+ msg="{0} : {1} ".format(type(e), e)
)
return
diff --git a/lib/ansible/modules/net_tools/dnsmadeeasy.py b/lib/ansible/modules/net_tools/dnsmadeeasy.py
index 48aee7befe..d051f3d5b1 100644
--- a/lib/ansible/modules/net_tools/dnsmadeeasy.py
+++ b/lib/ansible/modules/net_tools/dnsmadeeasy.py
@@ -1,4 +1,6 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -644,7 +646,7 @@ def main():
if not contact_list_id.isdigit() and contact_list_id != '':
contact_list = DME.getContactListByName(contact_list_id)
if not contact_list:
- module.fail_json(msg="Contact list {} does not exist".format(contact_list_id))
+ module.fail_json(msg="Contact list {0} does not exist".format(contact_list_id))
contact_list_id = contact_list.get('id', '')
new_monitor['contactListId'] = contact_list_id
else:
diff --git a/lib/ansible/modules/net_tools/ipinfoio_facts.py b/lib/ansible/modules/net_tools/ipinfoio_facts.py
index 3c708cf836..e347511ec7 100644
--- a/lib/ansible/modules/net_tools/ipinfoio_facts.py
+++ b/lib/ansible/modules/net_tools/ipinfoio_facts.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
-#
-# (c) 2016, Aleksei Kostiuk
+# -*- coding: UTF-8 -*-
+
+# Copyright: (c) 2016, Aleksei Kostiuk
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -101,7 +102,7 @@ class IpinfoioFacts(object):
try:
info['status'] == 200
except AssertionError:
- self.module.fail_json(msg='Could not get {} page, '
+ self.module.fail_json(msg='Could not get {0} page, '
'check for connectivity!'.format(self.url))
else:
try:
diff --git a/lib/ansible/modules/network/a10/a10_server_axapi3.py b/lib/ansible/modules/network/a10/a10_server_axapi3.py
index 5b82f179c4..9b6f97948e 100644
--- a/lib/ansible/modules/network/a10/a10_server_axapi3.py
+++ b/lib/ansible/modules/network/a10/a10_server_axapi3.py
@@ -1,9 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2014, Mischa Peters
-# (c) 2016, Eric Chou
-#
+# Copyright: (c) 2014, Mischa Peters
+# Copyright: (c) 2016, Eric Chou
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -162,7 +161,7 @@ def main():
slb_server_status = module.params['server_status']
slb_server_ports = module.params['server_ports']
- axapi_base_url = 'https://{}/axapi/v3/'.format(host)
+ axapi_base_url = 'https://{0}/axapi/v3/'.format(host)
axapi_auth_url = axapi_base_url + 'auth/'
signature = axapi_authenticate_v3(module, axapi_auth_url, username, password)
diff --git a/lib/ansible/modules/network/avi/avi_api_version.py b/lib/ansible/modules/network/avi/avi_api_version.py
index ec00592ba5..16df11ce5a 100644
--- a/lib/ansible/modules/network/avi/avi_api_version.py
+++ b/lib/ansible/modules/network/avi/avi_api_version.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
"""
# Created on July 24, 2017
#
@@ -6,8 +7,8 @@
#
# module_check: not supported
#
-# Copyright: (c) 2017 Gaurav Rastogi,
-# Vilian Atmadzhov,
+# Copyright: (c) 2017, Gaurav Rastogi
+# Copyright: (c) 2017, Vilian Atmadzhov
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
"""
@@ -83,7 +84,7 @@ def main():
api.close()
module.exit_json(changed=False, obj=remote)
except Exception as e:
- module.fail_json(msg="Unable to get an AVI session. {}".format(e))
+ module.fail_json(msg="Unable to get an AVI session. {0}".format(e))
if __name__ == '__main__':
diff --git a/lib/ansible/modules/network/bigswitch/bcf_switch.py b/lib/ansible/modules/network/bigswitch/bcf_switch.py
index f4fe61e6fd..60996b9434 100644
--- a/lib/ansible/modules/network/bigswitch/bcf_switch.py
+++ b/lib/ansible/modules/network/bigswitch/bcf_switch.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ted Elhourani
+# Copyright: (c) 2017, Ted Elhourani
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -101,7 +101,7 @@ def switch(module, check_mode):
response = rest.get('switch-config', data={})
if response.status_code != 200:
- module.fail_json(msg="failed to obtain existing switch config: {}".format(response.json['description']))
+ module.fail_json(msg="failed to obtain existing switch config: {0}".format(response.json['description']))
config_present = False
for switch in response.json:
@@ -127,14 +127,14 @@ def switch(module, check_mode):
if response.status_code == 204:
module.exit_json(changed=True)
else:
- module.fail_json(msg="error configuring switch '{}': {}".format(name, response.json['description']))
+ module.fail_json(msg="error configuring switch '{0}': {1}".format(name, response.json['description']))
if state in ('absent'):
response = rest.delete('switch-config[name="%s"]' % name, data={})
if response.status_code == 204:
module.exit_json(changed=True)
else:
- module.fail_json(msg="error deleting switch '{}': {}".format(name, response.json['description']))
+ module.fail_json(msg="error deleting switch '{0}': {1}".format(name, response.json['description']))
def main():
diff --git a/lib/ansible/modules/network/bigswitch/bigmon_chain.py b/lib/ansible/modules/network/bigswitch/bigmon_chain.py
index 4a41482bff..26ef4aa6f1 100644
--- a/lib/ansible/modules/network/bigswitch/bigmon_chain.py
+++ b/lib/ansible/modules/network/bigswitch/bigmon_chain.py
@@ -1,10 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# Ansible module to manage Big Monitoring Fabric service chains
-# (c) 2016, Ted Elhourani
+# Copyright: (c) 2016, Ted Elhourani
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+# Ansible module to manage Big Monitoring Fabric service chains
+
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@@ -88,7 +89,7 @@ def chain(module):
response = rest.get('chain?config=true', data={})
if response.status_code != 200:
- module.fail_json(msg="failed to obtain existing chain config: {}".format(response.json['description']))
+ module.fail_json(msg="failed to obtain existing chain config: {0}".format(response.json['description']))
config_present = False
matching = [chain for chain in response.json if chain['name'] == name]
@@ -106,14 +107,14 @@ def chain(module):
if response.status_code == 204:
module.exit_json(changed=True)
else:
- module.fail_json(msg="error creating chain '{}': {}".format(name, response.json['description']))
+ module.fail_json(msg="error creating chain '{0}': {1}".format(name, response.json['description']))
if state in ('absent'):
response = rest.delete('chain[name="%s"]' % name, data={})
if response.status_code == 204:
module.exit_json(changed=True)
else:
- module.fail_json(msg="error deleting chain '{}': {}".format(name, response.json['description']))
+ module.fail_json(msg="error deleting chain '{0}': {1}".format(name, response.json['description']))
def main():
diff --git a/lib/ansible/modules/network/bigswitch/bigmon_policy.py b/lib/ansible/modules/network/bigswitch/bigmon_policy.py
index e125646bd9..99b617d61e 100644
--- a/lib/ansible/modules/network/bigswitch/bigmon_policy.py
+++ b/lib/ansible/modules/network/bigswitch/bigmon_policy.py
@@ -1,10 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# Ansible module to manage Big Monitoring Fabric service chains
-# (c) 2016, Ted Elhourani
+# Copyright: (c) 2016, Ted Elhourani
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+# Ansible module to manage Big Monitoring Fabric service chains
+
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@@ -121,7 +122,7 @@ def policy(module):
response = rest.get('policy?config=true', data={})
if response.status_code != 200:
- module.fail_json(msg="failed to obtain existing policy config: {}".format(response.json['description']))
+ module.fail_json(msg="failed to obtain existing policy config: {0}".format(response.json['description']))
config_present = False
@@ -151,14 +152,14 @@ def policy(module):
if response.status_code == 204:
module.exit_json(changed=True)
else:
- module.fail_json(msg="error creating policy '{}': {}".format(name, response.json['description']))
+ module.fail_json(msg="error creating policy '{0}': {1}".format(name, response.json['description']))
if state in ('absent'):
response = rest.delete('policy[name="%s"]' % name, data={})
if response.status_code == 204:
module.exit_json(changed=True)
else:
- module.fail_json(msg="error deleting policy '{}': {}".format(name, response.json['description']))
+ module.fail_json(msg="error deleting policy '{0}': {1}".format(name, response.json['description']))
def main():
diff --git a/lib/ansible/modules/network/cloudengine/ce_file_copy.py b/lib/ansible/modules/network/cloudengine/ce_file_copy.py
index 6e8ef64b4c..be535994cb 100644
--- a/lib/ansible/modules/network/cloudengine/ce_file_copy.py
+++ b/lib/ansible/modules/network/cloudengine/ce_file_copy.py
@@ -1,20 +1,7 @@
#!/usr/bin/python
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see .
-#
+# -*- coding: utf-8 -*-
+
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -281,7 +268,7 @@ class FileCopy(object):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=hostname, username=username, password=password, port=port)
- full_remote_path = '{}{}'.format(self.file_system, dest)
+ full_remote_path = '{0}{1}'.format(self.file_system, dest)
scp = SCPClient(ssh.get_transport())
try:
scp.put(self.local_file, full_remote_path)
@@ -351,7 +338,7 @@ class FileCopy(object):
if not os.path.isfile(self.local_file):
self.module.fail_json(
- msg="Local file {} not found".format(self.local_file))
+ msg="Local file {0} not found".format(self.local_file))
dest = self.remote_file or ('/' + os.path.basename(self.local_file))
remote_exists, file_size = self.remote_file_exists(
diff --git a/lib/ansible/modules/network/eos/eos_interface.py b/lib/ansible/modules/network/eos/eos_interface.py
index 13b906af9b..c6f1981607 100644
--- a/lib/ansible/modules/network/eos/eos_interface.py
+++ b/lib/ansible/modules/network/eos/eos_interface.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -187,7 +187,7 @@ def parse_shutdown(configobj, name):
cfg = configobj['interface %s' % name]
cfg = '\n'.join(cfg.children)
match = re.search(r'shutdown', cfg, re.M)
- return True if match else False
+ return bool(match)
def parse_config_argument(configobj, name, arg=None):
@@ -368,7 +368,7 @@ def check_declarative_intent_params(module, want, result):
have_host = []
have_port = []
if have_neighbors is None:
- command = {'command': 'show lldp neighbors {}'.format(w['name']), 'output': 'text'}
+ command = {'command': 'show lldp neighbors {0}'.format(w['name']), 'output': 'text'}
have_neighbors = run_commands(module, [command])
if have_neighbors[0]:
diff --git a/lib/ansible/modules/network/eos/eos_l3_interface.py b/lib/ansible/modules/network/eos/eos_l3_interface.py
index 92292b237b..b60f156e83 100644
--- a/lib/ansible/modules/network/eos/eos_l3_interface.py
+++ b/lib/ansible/modules/network/eos/eos_l3_interface.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -170,23 +170,23 @@ def map_obj_to_commands(updates, module):
if state == 'absent' and obj_in_have:
if obj_in_have['ipv4']:
if ipv4:
- commands.append('no ip address {}'.format(ipv4))
+ commands.append('no ip address {0}'.format(ipv4))
else:
commands.append('no ip address')
if obj_in_have['ipv6']:
if ipv6:
- commands.append('no ipv6 address {}'.format(ipv6))
+ commands.append('no ipv6 address {0}'.format(ipv6))
else:
commands.append('no ipv6 address')
elif state == 'present':
if ipv4:
if obj_in_have is None or obj_in_have['ipv4'] is None or ipv4 != obj_in_have['ipv4']:
- commands.append('ip address {}'.format(ipv4))
+ commands.append('ip address {0}'.format(ipv4))
if ipv6:
if obj_in_have is None or obj_in_have['ipv6'] is None or ipv6.lower() != obj_in_have['ipv6'].lower():
- commands.append('ipv6 address {}'.format(ipv6))
+ commands.append('ipv6 address {0}'.format(ipv6))
if commands[-1] == interface:
commands.pop(-1)
diff --git a/lib/ansible/modules/network/eos/eos_linkagg.py b/lib/ansible/modules/network/eos/eos_linkagg.py
index 842a152937..32422d66fe 100644
--- a/lib/ansible/modules/network/eos/eos_linkagg.py
+++ b/lib/ansible/modules/network/eos/eos_linkagg.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -141,10 +141,10 @@ def map_obj_to_commands(updates, module):
if state == 'absent':
if obj_in_have:
- commands.append('no interface port-channel {}'.format(group))
+ commands.append('no interface port-channel {0}'.format(group))
elif state == 'present':
- cmd = ['interface port-channel {}'.format(group),
+ cmd = ['interface port-channel {0}'.format(group),
'end']
if not obj_in_have:
if not group:
@@ -152,11 +152,11 @@ def map_obj_to_commands(updates, module):
commands.extend(cmd)
if min_links != 'None':
- commands.append('port-channel min-links {}'.format(min_links))
+ commands.append('port-channel min-links {0}'.format(min_links))
if members:
for m in members:
- commands.append('interface {}'.format(m))
+ commands.append('interface {0}'.format(m))
commands.append('channel-group {0} mode {1}'.format(group, mode))
else:
@@ -164,27 +164,27 @@ def map_obj_to_commands(updates, module):
if 'members' not in obj_in_have.keys():
for m in members:
commands.extend(cmd)
- commands.append('interface {}'.format(m))
+ commands.append('interface {0}'.format(m))
commands.append('channel-group {0} mode {1}'.format(group, mode))
elif set(members) != set(obj_in_have['members']):
missing_members = list(set(members) - set(obj_in_have['members']))
for m in missing_members:
commands.extend(cmd)
- commands.append('interface {}'.format(m))
+ commands.append('interface {0}'.format(m))
commands.append('channel-group {0} mode {1}'.format(group, mode))
superfluous_members = list(set(obj_in_have['members']) - set(members))
for m in superfluous_members:
commands.extend(cmd)
- commands.append('interface {}'.format(m))
- commands.append('no channel-group {}'.format(group))
+ commands.append('interface {0}'.format(m))
+ commands.append('no channel-group {0}'.format(group))
if purge:
for h in have:
obj_in_want = search_obj_in_list(h['group'], want)
if not obj_in_want:
- commands.append('no interface port-channel {}'.format(h['group']))
+ commands.append('no interface port-channel {0}'.format(h['group']))
return commands
@@ -221,9 +221,9 @@ def parse_mode(group, member, config):
mode = None
for line in config.strip().split('!'):
- match_int = re.findall(r'interface {}\\b'.format(member), line, re.M)
+ match_int = re.findall(r'interface {0}\\b'.format(member), line, re.M)
if match_int:
- match = re.search(r'channel-group {} mode (\S+)'.format(group), line, re.M)
+ match = re.search(r'channel-group {0} mode (\S+)'.format(group), line, re.M)
if match:
mode = match.group(1)
@@ -234,7 +234,7 @@ def parse_members(group, config):
members = []
for line in config.strip().split('!'):
- match_group = re.findall(r'channel-group {} mode'.format(group), line, re.M)
+ match_group = re.findall(r'channel-group {0} mode'.format(group), line, re.M)
if match_group:
match = re.search(r'interface (\S+)', line, re.M)
if match:
@@ -263,7 +263,7 @@ def parse_min_links(group, config):
min_links = ''
for line in config.strip().split('!'):
- match_pc = re.findall(r'interface Port-Channel{}\\b'.format(group), line, re.M)
+ match_pc = re.findall(r'interface Port-Channel{0}\\b'.format(group), line, re.M)
if match_pc:
match = re.search(r'port-channel min-links (\S+)', line, re.M)
if match:
diff --git a/lib/ansible/modules/network/eos/eos_logging.py b/lib/ansible/modules/network/eos/eos_logging.py
index 5330237cfd..39e45b4e88 100644
--- a/lib/ansible/modules/network/eos/eos_logging.py
+++ b/lib/ansible/modules/network/eos/eos_logging.py
@@ -1,23 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
-#
-# This file is part of Ansible by Red Hat
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see .
-#
+# Copyright: (c) 2017, Ansible by Red Hat, inc
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -152,16 +138,16 @@ def map_obj_to_commands(updates, module):
if state == 'absent' and w in have:
if dest:
if dest == 'host':
- commands.append('no logging host {}'.format(name))
+ commands.append('no logging host {0}'.format(name))
elif dest in DEST_GROUP:
- commands.append('no logging {}'.format(dest))
+ commands.append('no logging {0}'.format(dest))
else:
module.fail_json(msg='dest must be among console, monitor, buffered, host, on')
if facility:
- commands.append('no logging facility {}'.format(facility))
+ commands.append('no logging facility {0}'.format(facility))
if state == 'present' and w not in have:
if facility:
@@ -175,10 +161,10 @@ def map_obj_to_commands(updates, module):
present = True
if not present:
- commands.append('logging facility {}'.format(facility))
+ commands.append('logging facility {0}'.format(facility))
if dest == 'host':
- commands.append('logging host {}'.format(name))
+ commands.append('logging host {0}'.format(name))
elif dest == 'on':
commands.append('logging on')
@@ -203,14 +189,14 @@ def map_obj_to_commands(updates, module):
if not present:
if size and level:
- commands.append('logging buffered {} {}'.format(size, level))
+ commands.append('logging buffered {0} {1}'.format(size, level))
else:
- commands.append('logging buffered {}'.format(size))
+ commands.append('logging buffered {0}'.format(size))
else:
- dest_cmd = 'logging {}'.format(dest)
+ dest_cmd = 'logging {0}'.format(dest)
if level:
- dest_cmd += ' {}'.format(level)
+ dest_cmd += ' {0}'.format(level)
commands.append(dest_cmd)
@@ -268,7 +254,7 @@ def parse_level(line, dest):
match = re.search(r'logging buffered (?:\d+) (\S+)', line, re.M)
else:
- match = re.search(r'logging {} (\S+)'.format(dest), line, re.M)
+ match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
if match:
if match.group(1) in LEVEL_GROUP:
diff --git a/lib/ansible/modules/network/eos/eos_static_route.py b/lib/ansible/modules/network/eos/eos_static_route.py
index c0ccac6744..b717ac5bab 100644
--- a/lib/ansible/modules/network/eos/eos_static_route.py
+++ b/lib/ansible/modules/network/eos/eos_static_route.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -224,7 +224,7 @@ def main():
if address and prefix:
if '/' not in address or not validate_ip_address(address.split('/')[0]):
- module.fail_json(msg='{} is not a valid IP address'.format(address))
+ module.fail_json(msg='{0} is not a valid IP address'.format(address))
if not validate_prefix(prefix):
module.fail_json(msg='Length of prefix should be between 0 and 32 bits')
diff --git a/lib/ansible/modules/network/ios/ios_l3_interface.py b/lib/ansible/modules/network/ios/ios_l3_interface.py
index 13855d91a5..2ed489cd6e 100644
--- a/lib/ansible/modules/network/ios/ios_l3_interface.py
+++ b/lib/ansible/modules/network/ios/ios_l3_interface.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -188,12 +188,12 @@ def map_obj_to_commands(updates, module):
address = ipv4.split('/')
if len(address) == 2:
ipv4 = '{0} {1}'.format(address[0], to_netmask(address[1]))
- commands.append('no ip address {}'.format(ipv4))
+ commands.append('no ip address {0}'.format(ipv4))
else:
commands.append('no ip address')
if obj_in_have['ipv6']:
if ipv6:
- commands.append('no ipv6 address {}'.format(ipv6))
+ commands.append('no ipv6 address {0}'.format(ipv6))
else:
commands.append('no ipv6 address')
if 'dhcp' in obj_in_have['ipv6']:
@@ -205,11 +205,11 @@ def map_obj_to_commands(updates, module):
address = ipv4.split('/')
if len(address) == 2:
ipv4 = '{0} {1}'.format(address[0], to_netmask(address[1]))
- commands.append('ip address {}'.format(ipv4))
+ commands.append('ip address {0}'.format(ipv4))
if ipv6:
if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() not in [addr.lower() for addr in obj_in_have['ipv6']]:
- commands.append('ipv6 address {}'.format(ipv6))
+ commands.append('ipv6 address {0}'.format(ipv6))
if commands[-1] == interface:
commands.pop(-1)
diff --git a/lib/ansible/modules/network/iosxr/iosxr_banner.py b/lib/ansible/modules/network/iosxr/iosxr_banner.py
index 0183d71999..18d74b1d70 100644
--- a/lib/ansible/modules/network/iosxr/iosxr_banner.py
+++ b/lib/ansible/modules/network/iosxr/iosxr_banner.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -111,7 +111,7 @@ class ConfigBase(object):
def map_params_to_obj(self):
text = self._module.params['text']
if text:
- text = "{!r}".format(str(text).strip())
+ text = "{0!r}".format(str(text).strip())
self._want.update({
'banner': self._module.params['banner'],
'text': text,
@@ -128,11 +128,11 @@ class CliConfiguration(ConfigBase):
state = self._module.params['state']
if state == 'absent':
if self._have.get('state') != 'absent' and ('text' in self._have.keys() and self._have['text']):
- commands.append('no banner {!s}'.format(self._module.params['banner']))
+ commands.append('no banner {0!s}'.format(self._module.params['banner']))
elif state == 'present':
if (self._want['text'] and
self._want['text'].encode().decode('unicode_escape').strip("'") != self._have.get('text')):
- banner_cmd = 'banner {!s} '.format(self._module.params['banner'])
+ banner_cmd = 'banner {0!s} '.format(self._module.params['banner'])
banner_cmd += self._want['text'].strip()
commands.append(banner_cmd)
self._result['commands'] = commands
@@ -144,7 +144,7 @@ class CliConfiguration(ConfigBase):
self._result['changed'] = True
def map_config_to_obj(self):
- cli_filter = 'banner {!s}'.format(self._module.params['banner'])
+ cli_filter = 'banner {0!s}'.format(self._module.params['banner'])
output = get_config(self._module, config_filter=cli_filter)
match = re.search(r'banner (\S+) (.*)', output, re.DOTALL)
if match:
diff --git a/lib/ansible/modules/network/iosxr/iosxr_interface.py b/lib/ansible/modules/network/iosxr/iosxr_interface.py
index 3fc8a5392a..99fc095936 100644
--- a/lib/ansible/modules/network/iosxr/iosxr_interface.py
+++ b/lib/ansible/modules/network/iosxr/iosxr_interface.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -322,7 +322,7 @@ class CliConfiguration(ConfigBase):
'speed': self.parse_config_argument(intf_config, 'speed'),
'duplex': self.parse_config_argument(intf_config, 'duplex'),
'mtu': self.parse_config_argument(intf_config, 'mtu'),
- 'enabled': True if not self.parse_shutdown(intf_config) else False,
+ 'enabled': not bool(self.parse_shutdown(intf_config)),
'active': active,
'state': 'present'
}
@@ -385,7 +385,7 @@ class CliConfiguration(ConfigBase):
if self._result['changed']:
sleep(want_item['delay'])
- command = 'show interfaces {!s}'.format(want_item['name'])
+ command = 'show interfaces {0!s}'.format(want_item['name'])
out = run_commands(self._module, command)[0]
if want_state in ('up', 'down'):
@@ -399,7 +399,7 @@ class CliConfiguration(ConfigBase):
have_state = match.group(1)
if have_state is None or not conditional(want_state, have_state.strip()):
- failed_conditions.append('state ' + 'eq({!s})'.format(want_state))
+ failed_conditions.append('state ' + 'eq({0!s})'.format(want_state))
if want_tx_rate:
match = re.search(r'%s (\d+)' % 'output rate', out, re.M)
@@ -575,7 +575,7 @@ class NCConfiguration(ConfigBase):
if want_state in ('up', 'down'):
if want_state not in line_state_map[want_item['name']]:
- failed_conditions.append('state ' + 'eq({!s})'.format(want_state))
+ failed_conditions.append('state ' + 'eq({0!s})'.format(want_state))
if want_tx_rate:
if want_tx_rate != data_rate_map[want_item['name']]['output-data-rate']:
diff --git a/lib/ansible/modules/network/nxos/nxos_logging.py b/lib/ansible/modules/network/nxos/nxos_logging.py
index 69533574f6..be3d451d3c 100644
--- a/lib/ansible/modules/network/nxos/nxos_logging.py
+++ b/lib/ansible/modules/network/nxos/nxos_logging.py
@@ -1,23 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
-#
-# This file is part of Ansible by Red Hat
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see .
-#
+# Copyright: (c) 2017, Ansible by Red Hat, inc
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -232,19 +218,19 @@ def map_obj_to_commands(updates):
if state == 'absent' and w in have:
if w['facility'] is not None:
if not w['dest'] and not w['facility_link_status'] and w['facility'] not in DEFAULT_LOGGING_LEVEL[int(w['facility_level'])]:
- commands.append('no logging level {} {}'.format(w['facility'], w['facility_level']))
+ commands.append('no logging level {0} {1}'.format(w['facility'], w['facility_level']))
if w['facility_link_status'] and w['facility'] in ('ethpm'):
- commands.append('no logging level {} {}'.format(w['facility'], STATIC_CLI[w['facility_link_status']]))
+ commands.append('no logging level {0} {1}'.format(w['facility'], STATIC_CLI[w['facility_link_status']]))
if w['name'] is not None:
commands.append('no logging logfile')
if w['dest'] in ('console', 'module', 'monitor'):
- commands.append('no logging {}'.format(w['dest']))
+ commands.append('no logging {0}'.format(w['dest']))
if w['dest'] == 'server':
- commands.append('no logging server {}'.format(w['remote_server']))
+ commands.append('no logging server {0}'.format(w['remote_server']))
if w['interface']:
commands.append('no logging source-interface')
@@ -262,14 +248,14 @@ def map_obj_to_commands(updates):
if w['facility'] is None:
if w['dest']:
if w['dest'] not in ('logfile', 'server'):
- commands.append('logging {} {}'.format(w['dest'], w['dest_level']))
+ commands.append('logging {0} {1}'.format(w['dest'], w['dest_level']))
elif w['dest'] == 'logfile':
if w['file_size']:
- commands.append('logging logfile {} {} size {}'.format(
+ commands.append('logging logfile {0} {1} size {2}'.format(
w['name'], w['dest_level'], w['file_size']))
else:
- commands.append('logging logfile {} {}'.format(
+ commands.append('logging logfile {0} {1}'.format(
w['name'], w['dest_level']))
elif w['dest'] == 'server':
@@ -306,11 +292,11 @@ def map_obj_to_commands(updates):
w['facility']))
else:
if w['facility_link_status']:
- commands.append('logging level {} {}'.format(
+ commands.append('logging level {0} {1}'.format(
w['facility'], STATIC_CLI[w['facility_link_status']]))
else:
- commands.append('logging level {} {}'.format(w['facility'],
- w['facility_level']))
+ commands.append('logging level {0} {1}'.format(w['facility'],
+ w['facility_level']))
if w['interface']:
commands.append('logging source-interface {0} {1}'.format(*split_interface(w['interface'])))
@@ -337,7 +323,7 @@ def parse_facility_link_status(line, facility, status):
facility_link_status = None
if facility is not None:
- match = re.search(r'logging level {} {} (\S+)'.format(facility, status), line, re.M)
+ match = re.search(r'logging level {0} {1} (\S+)'.format(facility, status), line, re.M)
if match:
facility_link_status = status + "-" + match.group(1)
@@ -347,7 +333,7 @@ def parse_facility_link_status(line, facility, status):
def parse_event_status(line, event):
status = None
- match = re.search(r'logging event {} (\S+)'.format(event + '-status'), line, re.M)
+ match = re.search(r'logging event {0} (\S+)'.format(event + '-status'), line, re.M)
if match:
state = match.group(1)
if state:
@@ -383,7 +369,7 @@ def parse_message(line):
def parse_file_size(line, name, level):
file_size = None
- match = re.search(r'logging logfile {} {} size (\S+)'.format(name, level), line, re.M)
+ match = re.search(r'logging logfile {0} {1} size (\S+)'.format(name, level), line, re.M)
if match:
file_size = match.group(1)
if file_size == '8192':
@@ -441,7 +427,7 @@ def parse_dest_level(line, dest, name):
if dest and dest != 'server':
if dest == 'logfile':
- match = re.search(r'logging logfile {} (\S+)'.format(name), line, re.M)
+ match = re.search(r'logging logfile {0} (\S+)'.format(name), line, re.M)
if match:
dest_level = parse_match(match)
@@ -450,7 +436,7 @@ def parse_dest_level(line, dest, name):
if match:
dest_level = parse_match(match)
else:
- match = re.search(r'logging {} (\S+)'.format(dest), line, re.M)
+ match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
if match:
dest_level = parse_match(match)
@@ -466,7 +452,7 @@ def parse_facility_level(line, facility, dest):
facility_level = match.group(1)
elif facility is not None:
- match = re.search(r'logging level {} (\S+)'.format(facility), line, re.M)
+ match = re.search(r'logging level {0} (\S+)'.format(facility), line, re.M)
if match:
facility_level = match.group(1)
diff --git a/lib/ansible/modules/network/nxos/nxos_snapshot.py b/lib/ansible/modules/network/nxos/nxos_snapshot.py
index 3393087777..9eebc9b30f 100644
--- a/lib/ansible/modules/network/nxos/nxos_snapshot.py
+++ b/lib/ansible/modules/network/nxos/nxos_snapshot.py
@@ -1,20 +1,8 @@
#!/usr/bin/python
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see .
-#
+# -*- coding: utf-8 -*-
+
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -369,7 +357,7 @@ def main():
result['changed'] = True
if action == 'create' and module.params['path'] and module.params['save_snapshot_locally']:
- command = 'show snapshot dump {} | json'.format(module.params['snapshot_name'])
+ command = 'show snapshot dump {0} | json'.format(module.params['snapshot_name'])
content = execute_show_command(command, module)[0]
if content:
write_on_file(str(content), module.params['snapshot_name'], module)
diff --git a/lib/ansible/modules/network/vyos/vyos_vlan.py b/lib/ansible/modules/network/vyos/vyos_vlan.py
index 16d07f7710..b8a6f7fc7e 100644
--- a/lib/ansible/modules/network/vyos/vyos_vlan.py
+++ b/lib/ansible/modules/network/vyos/vyos_vlan.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Ansible by Red Hat, inc
+# Copyright: (c) 2017, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -160,9 +160,9 @@ def map_obj_to_commands(updates, module):
for i in w['interfaces']:
cmd = 'set interfaces ethernet {0} vif {1}'.format(i, vlan_id)
if w['name']:
- commands.append(cmd + ' description {}'.format(name))
+ commands.append(cmd + ' description {0}'.format(name))
elif w['address']:
- commands.append(cmd + ' address {}'.format(address))
+ commands.append(cmd + ' address {0}'.format(address))
else:
commands.append(cmd)
diff --git a/lib/ansible/modules/notification/cisco_spark.py b/lib/ansible/modules/notification/cisco_spark.py
index 16b519fcf1..fabf20f18c 100644
--- a/lib/ansible/modules/notification/cisco_spark.py
+++ b/lib/ansible/modules/notification/cisco_spark.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-#
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -126,7 +126,7 @@ def spark_message(module):
ansible = module.params
headers = {
- 'Authorization': 'Bearer {}'.format(ansible['personal_token']),
+ 'Authorization': 'Bearer {0}'.format(ansible['personal_token']),
'content-type': 'application/json'
}
diff --git a/lib/ansible/modules/notification/logentries_msg.py b/lib/ansible/modules/notification/logentries_msg.py
index 3407e0cf30..51ba941992 100644
--- a/lib/ansible/modules/notification/logentries_msg.py
+++ b/lib/ansible/modules/notification/logentries_msg.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
-# Copyright 2017, Ansible Project
-#
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -55,7 +56,7 @@ from ansible.module_utils.basic import AnsibleModule
def send_msg(module, token, msg, api, port):
- message = "{} {}\n".format(token, msg)
+ message = "{0} {1}\n".format(token, msg)
api_ip = socket.gethostbyname(api)
diff --git a/lib/ansible/modules/remote_management/foreman/_foreman.py b/lib/ansible/modules/remote_management/foreman/_foreman.py
index 874d101724..c077a70331 100644
--- a/lib/ansible/modules/remote_management/foreman/_foreman.py
+++ b/lib/ansible/modules/remote_management/foreman/_foreman.py
@@ -91,7 +91,7 @@ class NailGun(object):
def find_organization(self, name, **params):
org = self._entities.Organization(self._server, name=name, **params)
- response = org.search(set(), {'search': 'name={}'.format(name)})
+ response = org.search(set(), {'search': 'name={0}'.format(name)})
if len(response) == 1:
return response[0]
diff --git a/lib/ansible/modules/remote_management/foreman/_katello.py b/lib/ansible/modules/remote_management/foreman/_katello.py
index aec9264bbc..c53283be6c 100644
--- a/lib/ansible/modules/remote_management/foreman/_katello.py
+++ b/lib/ansible/modules/remote_management/foreman/_katello.py
@@ -248,7 +248,7 @@ class NailGun(object):
def find_organization(self, name, **params):
org = self._entities.Organization(self._server, name=name, **params)
- response = org.search(set(), {'search': 'name={}'.format(name)})
+ response = org.search(set(), {'search': 'name={0}'.format(name)})
if len(response) == 1:
return response[0]
diff --git a/lib/ansible/modules/source_control/github_deploy_key.py b/lib/ansible/modules/source_control/github_deploy_key.py
index 7a0b562491..d36cc2bfe2 100644
--- a/lib/ansible/modules/source_control/github_deploy_key.py
+++ b/lib/ansible/modules/source_control/github_deploy_key.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-#
+
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -177,7 +177,7 @@ class GithubDeployKey(object):
if self.otp is not None:
self.headers = {"X-GitHub-OTP": self.otp}
else:
- self.headers = {"Authorization": "token {}".format(self.token)}
+ self.headers = {"Authorization": "token {0}".format(self.token)}
def get_existing_key(self, key, title, force):
resp, info = fetch_url(self.module, self.url, headers=self.headers, method="GET")
@@ -226,7 +226,7 @@ class GithubDeployKey(object):
self.module.fail_json(msg="Failed to add deploy key", http_status_code=status_code, error=err)
def remove_existing_key(self, key_id):
- resp, info = fetch_url(self.module, self.url + "/{}".format(key_id), headers=self.headers, method="DELETE")
+ resp, info = fetch_url(self.module, self.url + "/{0}".format(key_id), headers=self.headers, method="DELETE")
status_code = info["status"]
@@ -278,7 +278,7 @@ def main():
token = module.params.get('token', None)
otp = module.params.get('otp', None)
- GITHUB_API_URL = "https://api.github.com/repos/{}/{}/keys".format(owner, repo)
+ GITHUB_API_URL = "https://api.github.com/repos/{0}/{1}/keys".format(owner, repo)
deploy_key = GithubDeployKey(module, GITHUB_API_URL, state, username, password, token, otp)
diff --git a/lib/ansible/modules/source_control/github_key.py b/lib/ansible/modules/source_control/github_key.py
index 5336d7f667..1e4ebd0e03 100644
--- a/lib/ansible/modules/source_control/github_key.py
+++ b/lib/ansible/modules/source_control/github_key.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-#
+
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -183,7 +183,7 @@ def ensure_key_present(module, session, name, pubkey, force, check_mode):
if new_signature == existing_signature and key['title'] != name:
module.fail_json(msg=(
"another key with the same content is already registered "
- "under the name |{}|").format(key['title']))
+ "under the name |{0}|").format(key['title']))
if matching_keys and force and matching_keys[0]['key'].split(' ')[1] != new_signature:
delete_keys(session, matching_keys, check_mode=check_mode)
diff --git a/lib/ansible/modules/storage/infinidat/infini_export.py b/lib/ansible/modules/storage/infinidat/infini_export.py
index ffc02e5f6d..b9561cac32 100644
--- a/lib/ansible/modules/storage/infinidat/infini_export.py
+++ b/lib/ansible/modules/storage/infinidat/infini_export.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
+# Copyright: (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -182,7 +182,7 @@ def main():
export = get_export(module, filesystem, system)
if filesystem is None:
- module.fail_json(msg='Filesystem {} not found'.format(module.params['filesystem']))
+ module.fail_json(msg='Filesystem {0} not found'.format(module.params['filesystem']))
if state == 'present':
update_export(module, export, filesystem, system)
diff --git a/lib/ansible/modules/storage/infinidat/infini_export_client.py b/lib/ansible/modules/storage/infinidat/infini_export_client.py
index 93db60aa8c..528eafc5f8 100644
--- a/lib/ansible/modules/storage/infinidat/infini_export_client.py
+++ b/lib/ansible/modules/storage/infinidat/infini_export_client.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
+# Copyright: (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -108,7 +108,7 @@ def get_export(module, system):
try:
export = system.exports.get(export_path=module.params['export'])
except Exception:
- module.fail_json(msg="Export with export path {} not found".format(module.params['export']))
+ module.fail_json(msg="Export with export path {0} not found".format(module.params['export']))
return export
diff --git a/lib/ansible/modules/storage/infinidat/infini_fs.py b/lib/ansible/modules/storage/infinidat/infini_fs.py
index 3e57313cfb..81f58d0e1e 100644
--- a/lib/ansible/modules/storage/infinidat/infini_fs.py
+++ b/lib/ansible/modules/storage/infinidat/infini_fs.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
+# Copyright: (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -155,7 +155,7 @@ def main():
filesystem = get_filesystem(module, system)
if pool is None:
- module.fail_json(msg='Pool {} not found'.format(module.params['pool']))
+ module.fail_json(msg='Pool {0} not found'.format(module.params['pool']))
if state == 'present' and not filesystem:
create_filesystem(module, system)
diff --git a/lib/ansible/modules/storage/infinidat/infini_host.py b/lib/ansible/modules/storage/infinidat/infini_host.py
index 47633e3cd3..ac90a92803 100644
--- a/lib/ansible/modules/storage/infinidat/infini_host.py
+++ b/lib/ansible/modules/storage/infinidat/infini_host.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
+# Copyright: (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -144,7 +144,7 @@ def main():
try:
system.volumes.get(name=module.params['volume'])
except Exception:
- module.fail_json(msg='Volume {} not found'.format(module.params['volume']))
+ module.fail_json(msg='Volume {0} not found'.format(module.params['volume']))
if host and state == 'present':
update_host(module, host)
diff --git a/lib/ansible/modules/storage/infinidat/infini_vol.py b/lib/ansible/modules/storage/infinidat/infini_vol.py
index e4bfb16a85..f81f65fd8f 100644
--- a/lib/ansible/modules/storage/infinidat/infini_vol.py
+++ b/lib/ansible/modules/storage/infinidat/infini_vol.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
+# Copyright: (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -150,7 +150,7 @@ def main():
volume = get_volume(module, system)
if pool is None:
- module.fail_json(msg='Pool {} not found'.format(module.params['pool']))
+ module.fail_json(msg='Pool {0} not found'.format(module.params['pool']))
if state == 'present' and not volume:
create_volume(module, system)
diff --git a/lib/ansible/modules/storage/purestorage/purefa_host.py b/lib/ansible/modules/storage/purestorage/purefa_host.py
index b166f8a4ab..02736ad95e 100644
--- a/lib/ansible/modules/storage/purestorage/purefa_host.py
+++ b/lib/ansible/modules/storage/purestorage/purefa_host.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Simon Dodsley (simon@purestorage.com)
+# Copyright: (c) 2017, Simon Dodsley (simon@purestorage.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -341,7 +341,7 @@ def main():
try:
array.get_volume(module.params['volume'])
except Exception:
- module.fail_json(msg='Volume {} not found'.format(module.params['volume']))
+ module.fail_json(msg='Volume {0} not found'.format(module.params['volume']))
if host is None and state == 'present':
make_host(module, array)
diff --git a/lib/ansible/modules/storage/purestorage/purefa_pg.py b/lib/ansible/modules/storage/purestorage/purefa_pg.py
index b62b989ae6..b794e9ff6f 100644
--- a/lib/ansible/modules/storage/purestorage/purefa_pg.py
+++ b/lib/ansible/modules/storage/purestorage/purefa_pg.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# (c) 2017, Simon Dodsley (simon@purestorage.com)
+# Copyright: (c) 2017, Simon Dodsley (simon@purestorage.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -320,14 +320,14 @@ def main():
for hst in module.params['host']:
array.get_host(hst)
except Exception:
- module.fail_json(msg='Host {} not found'.format(hst))
+ module.fail_json(msg='Host {0} not found'.format(hst))
if module.params['hostgroup']:
try:
for hstg in module.params['hostgroup']:
array.get_hgroup(hstg)
except Exception:
- module.fail_json(msg='Hostgroup {} not found'.format(hstg))
+ module.fail_json(msg='Hostgroup {0} not found'.format(hstg))
if pgroup and state == 'present':
update_pgroup(module, array)
diff --git a/lib/ansible/modules/system/firewalld.py b/lib/ansible/modules/system/firewalld.py
index 0e5976e46d..1eb0168b82 100644
--- a/lib/ansible/modules/system/firewalld.py
+++ b/lib/ansible/modules/system/firewalld.py
@@ -452,7 +452,7 @@ class InterfaceTransaction(FirewallTransaction):
# Even it shouldn't happen, it's actually possible that
# the same interface is in several zone XML files
self.module.fail_json(
- msg='ERROR: interface {} is in {} zone XML file, can only be in one'.format(
+ msg='ERROR: interface {0} is in {1} zone XML file, can only be in one'.format(
interface,
len(iface_zone_objs)
)
diff --git a/test/sanity/pylint/ignore.txt b/test/sanity/pylint/ignore.txt
index d7b0ee4a2a..c2be33bbf4 100644
--- a/test/sanity/pylint/ignore.txt
+++ b/test/sanity/pylint/ignore.txt
@@ -1,65 +1 @@
-lib/ansible/module_utils/network/iosxr/iosxr.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/amazon/aws_api_gateway.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/amazon/aws_kms.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/amazon/ec2_eip.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/amazon/ecs_ecr.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/amazon/sns.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_acs.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_availabilityset_facts.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_functionapp.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_loadbalancer_facts.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_managed_disk_facts.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/digital_ocean/digital_ocean_block_storage.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/google/gce_instance_template.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/lxd/lxd_container.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/lxd/lxd_profile.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/misc/proxmox_kvm.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/misc/serverless.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/univention/udm_dns_record.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/univention/udm_dns_zone.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/univention/udm_group.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/univention/udm_share.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/univention/udm_user.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/webfaction/webfaction_app.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/webfaction/webfaction_db.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/webfaction/webfaction_domain.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py ansible-format-automatic-specification
-lib/ansible/modules/cloud/webfaction/webfaction_site.py ansible-format-automatic-specification
-lib/ansible/modules/monitoring/grafana_plugin.py ansible-format-automatic-specification
-lib/ansible/modules/net_tools/dnsmadeeasy.py ansible-format-automatic-specification
-lib/ansible/modules/net_tools/ipinfoio_facts.py ansible-format-automatic-specification
-lib/ansible/modules/network/a10/a10_server_axapi3.py ansible-format-automatic-specification
-lib/ansible/modules/network/avi/avi_api_version.py ansible-format-automatic-specification
-lib/ansible/modules/network/bigswitch/bcf_switch.py ansible-format-automatic-specification
-lib/ansible/modules/network/bigswitch/bigmon_chain.py ansible-format-automatic-specification
-lib/ansible/modules/network/bigswitch/bigmon_policy.py ansible-format-automatic-specification
-lib/ansible/modules/network/cloudengine/ce_file_copy.py ansible-format-automatic-specification
-lib/ansible/modules/network/eos/eos_interface.py ansible-format-automatic-specification
-lib/ansible/modules/network/eos/eos_l3_interface.py ansible-format-automatic-specification
-lib/ansible/modules/network/eos/eos_linkagg.py ansible-format-automatic-specification
-lib/ansible/modules/network/eos/eos_logging.py ansible-format-automatic-specification
-lib/ansible/modules/network/eos/eos_static_route.py ansible-format-automatic-specification
-lib/ansible/modules/network/ios/ios_l3_interface.py ansible-format-automatic-specification
-lib/ansible/modules/network/iosxr/iosxr_banner.py ansible-format-automatic-specification
-lib/ansible/modules/network/iosxr/iosxr_interface.py ansible-format-automatic-specification
-lib/ansible/modules/network/nxos/nxos_logging.py ansible-format-automatic-specification
-lib/ansible/modules/network/nxos/nxos_snapshot.py ansible-format-automatic-specification
-lib/ansible/modules/network/vyos/vyos_vlan.py ansible-format-automatic-specification
-lib/ansible/modules/notification/cisco_spark.py ansible-format-automatic-specification
-lib/ansible/modules/notification/logentries_msg.py ansible-format-automatic-specification
-lib/ansible/modules/remote_management/foreman/_foreman.py ansible-format-automatic-specification
-lib/ansible/modules/remote_management/foreman/_katello.py ansible-format-automatic-specification
-lib/ansible/modules/source_control/github_deploy_key.py ansible-format-automatic-specification
-lib/ansible/modules/source_control/github_key.py ansible-format-automatic-specification
-lib/ansible/modules/storage/infinidat/infini_export.py ansible-format-automatic-specification
-lib/ansible/modules/storage/infinidat/infini_export_client.py ansible-format-automatic-specification
-lib/ansible/modules/storage/infinidat/infini_fs.py ansible-format-automatic-specification
-lib/ansible/modules/storage/infinidat/infini_host.py ansible-format-automatic-specification
-lib/ansible/modules/storage/infinidat/infini_vol.py ansible-format-automatic-specification
-lib/ansible/modules/storage/purestorage/purefa_host.py ansible-format-automatic-specification
-lib/ansible/modules/storage/purestorage/purefa_pg.py ansible-format-automatic-specification
-lib/ansible/modules/system/firewalld.py ansible-format-automatic-specification
test/units/modules/system/test_known_hosts.py ansible-bad-function