mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Assorted pylint fixes
This commit is contained in:
parent
8e0f95951d
commit
f9ab9b4d68
65 changed files with 343 additions and 473 deletions
|
@ -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
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
# -*- 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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Michael J. Schultz <mjschultz@gmail.com>
|
||||
# Copyright: (c) 2014, Michael J. Schultz <mjschultz@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
|
||||
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2017 Julien Stroheker, <juliens@microsoft.com>
|
||||
#
|
||||
# -*- coding: utf-8 -*
|
||||
|
||||
# Copyright: (c) 2017, Julien Stroheker <juliens@microsoft.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
|
||||
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016 Julien Stroheker, <juliens@microsoft.com>
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2016, Julien Stroheker <juliens@microsoft.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
|
||||
|
@ -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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016 Thomas Stringer, <tomstr@microsoft.com>
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2016, Thomas Stringer <tomstr@microsoft.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
|
||||
|
@ -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
|
||||
)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# Copyright (c) 2016 Thomas Stringer, <tomstr@microsoft.com>
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2016, Thomas Stringer <tomstr@microsoft.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
|
||||
|
@ -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,
|
||||
|
|
|
@ -1,22 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016 Thomas Stringer, <tomstr@microsoft.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2016, Thomas Stringer <tomstr@microsoft.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
|
||||
__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:
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016 Bruno Medina Bolanos Cacho, <bruno.medina@microsoft.com>
|
||||
#
|
||||
# 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 <bruno.medina@microsoft.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
|
||||
__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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2017 Sertac Ozercan, <seozerca@microsoft.com>
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2017, Sertac Ozercan <seozerca@microsoft.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
|
||||
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Hiroaki Nakamura <hnakamur@gmail.com>
|
||||
# Copyright: (c) 2016, Hiroaki Nakamura <hnakamur@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
|
||||
|
@ -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)
|
||||
),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Hiroaki Nakamura <hnakamur@gmail.com>
|
||||
# Copyright: (c) 2016, Hiroaki Nakamura <hnakamur@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
|
||||
|
@ -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)
|
||||
),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Abdoul Bah (@helldorado) <bahabdoul at gmail.com>
|
||||
# Copyright: (c) 2016, Abdoul Bah (@helldorado) <bahabdoul at 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
|
||||
|
@ -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__':
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Ryan Scott Brown <ryansb@redhat.com>
|
||||
# Copyright: (c) 2016, Ryan Scott Brown <ryansb@redhat.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
|
||||
|
@ -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,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# 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(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# 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(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# 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(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# 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,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# 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(
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue