summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/aws/plugins/modules/codepipeline.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
commit7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch)
treeefb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/community/aws/plugins/modules/codepipeline.py
parentReleasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff)
downloadansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz
ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/aws/plugins/modules/codepipeline.py')
-rw-r--r--ansible_collections/community/aws/plugins/modules/codepipeline.py106
1 files changed, 55 insertions, 51 deletions
diff --git a/ansible_collections/community/aws/plugins/modules/codepipeline.py b/ansible_collections/community/aws/plugins/modules/codepipeline.py
index 5c5935cb9..b1fe60476 100644
--- a/ansible_collections/community/aws/plugins/modules/codepipeline.py
+++ b/ansible_collections/community/aws/plugins/modules/codepipeline.py
@@ -1,13 +1,10 @@
#!/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)
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-
-DOCUMENTATION = r'''
+DOCUMENTATION = r"""
---
module: codepipeline
version_added: 1.0.0
@@ -75,16 +72,16 @@ options:
choices: ['present', 'absent']
type: str
extends_documentation_fragment:
- - amazon.aws.aws
- - amazon.aws.ec2
+ - amazon.aws.common.modules
+ - amazon.aws.region.modules
- amazon.aws.boto3
-'''
+"""
-EXAMPLES = r'''
+EXAMPLES = r"""
# Note: These examples do not set authentication details, see the AWS Guide for details.
# Example for creating a pipeline for continuous deploy of Github code to an ECS cluster (container)
-- community.aws.aws_codepipeline:
+- community.aws.codepipeline:
name: my_deploy_pipeline
role_arn: arn:aws:iam::123456:role/AWS-CodePipeline-Service
artifact_store:
@@ -147,9 +144,9 @@ EXAMPLES = r'''
FileName: imagedefinitions.json
region: us-east-1
state: present
-'''
+"""
-RETURN = r'''
+RETURN = r"""
pipeline:
description: Returns the dictionary describing the CodePipeline configuration.
returned: success
@@ -194,7 +191,7 @@ pipeline:
- This number is auto incremented when CodePipeline params are changed.
returned: always
type: int
-'''
+"""
import copy
@@ -205,20 +202,21 @@ except ImportError:
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
-from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
-from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code
-from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_policies
+from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
+from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies
+
+from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
def create_pipeline(client, name, role_arn, artifact_store, stages, version, module):
- pipeline_dict = {'name': name, 'roleArn': role_arn, 'artifactStore': artifact_store, 'stages': stages}
+ pipeline_dict = {"name": name, "roleArn": role_arn, "artifactStore": artifact_store, "stages": stages}
if version:
- pipeline_dict['version'] = version
+ pipeline_dict["version"] = version
try:
resp = client.create_pipeline(pipeline=pipeline_dict)
return resp
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
- module.fail_json_aws(e, msg="Unable create pipeline {0}".format(pipeline_dict['name']))
+ module.fail_json_aws(e, msg=f"Unable create pipeline {pipeline_dict['name']}")
def update_pipeline(client, pipeline_dict, module):
@@ -226,7 +224,7 @@ def update_pipeline(client, pipeline_dict, module):
resp = client.update_pipeline(pipeline=pipeline_dict)
return resp
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
- module.fail_json_aws(e, msg="Unable update pipeline {0}".format(pipeline_dict['name']))
+ module.fail_json_aws(e, msg=f"Unable update pipeline {pipeline_dict['name']}")
def delete_pipeline(client, name, module):
@@ -234,7 +232,7 @@ def delete_pipeline(client, name, module):
resp = client.delete_pipeline(name=name)
return resp
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
- module.fail_json_aws(e, msg="Unable delete pipeline {0}".format(name))
+ module.fail_json_aws(e, msg=f"Unable delete pipeline {name}")
def describe_pipeline(client, name, version, module):
@@ -246,63 +244,69 @@ def describe_pipeline(client, name, version, module):
else:
pipeline = client.get_pipeline(name=name)
return pipeline
- except is_boto3_error_code('PipelineNotFoundException'):
+ except is_boto3_error_code("PipelineNotFoundException"):
return pipeline
- except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: # pylint: disable=duplicate-except
+ except (
+ botocore.exceptions.BotoCoreError,
+ botocore.exceptions.ClientError,
+ ) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e)
def main():
argument_spec = dict(
- name=dict(required=True, type='str'),
- role_arn=dict(required=True, type='str'),
- artifact_store=dict(required=True, type='dict'),
- stages=dict(required=True, type='list', elements='dict'),
- version=dict(type='int'),
- state=dict(choices=['present', 'absent'], default='present')
+ name=dict(required=True, type="str"),
+ role_arn=dict(required=True, type="str"),
+ artifact_store=dict(required=True, type="dict"),
+ stages=dict(required=True, type="list", elements="dict"),
+ version=dict(type="int"),
+ state=dict(choices=["present", "absent"], default="present"),
)
module = AnsibleAWSModule(argument_spec=argument_spec)
- client_conn = module.client('codepipeline')
+ client_conn = module.client("codepipeline")
- state = module.params.get('state')
+ state = module.params.get("state")
changed = False
# Determine if the CodePipeline exists
- found_code_pipeline = describe_pipeline(client=client_conn, name=module.params['name'], version=module.params['version'], module=module)
+ found_code_pipeline = describe_pipeline(
+ client=client_conn, name=module.params["name"], version=module.params["version"], module=module
+ )
pipeline_result = {}
- if state == 'present':
- if 'pipeline' in found_code_pipeline:
- pipeline_dict = copy.deepcopy(found_code_pipeline['pipeline'])
+ if state == "present":
+ if "pipeline" in found_code_pipeline:
+ pipeline_dict = copy.deepcopy(found_code_pipeline["pipeline"])
# Update dictionary with provided module params:
- pipeline_dict['roleArn'] = module.params['role_arn']
- pipeline_dict['artifactStore'] = module.params['artifact_store']
- pipeline_dict['stages'] = module.params['stages']
- if module.params['version'] is not None:
- pipeline_dict['version'] = module.params['version']
+ pipeline_dict["roleArn"] = module.params["role_arn"]
+ pipeline_dict["artifactStore"] = module.params["artifact_store"]
+ pipeline_dict["stages"] = module.params["stages"]
+ if module.params["version"] is not None:
+ pipeline_dict["version"] = module.params["version"]
pipeline_result = update_pipeline(client=client_conn, pipeline_dict=pipeline_dict, module=module)
- if compare_policies(found_code_pipeline['pipeline'], pipeline_result['pipeline']):
+ if compare_policies(found_code_pipeline["pipeline"], pipeline_result["pipeline"]):
changed = True
else:
pipeline_result = create_pipeline(
client=client_conn,
- name=module.params['name'],
- role_arn=module.params['role_arn'],
- artifact_store=module.params['artifact_store'],
- stages=module.params['stages'],
- version=module.params['version'],
- module=module)
+ name=module.params["name"],
+ role_arn=module.params["role_arn"],
+ artifact_store=module.params["artifact_store"],
+ stages=module.params["stages"],
+ version=module.params["version"],
+ module=module,
+ )
changed = True
- elif state == 'absent':
+ elif state == "absent":
if found_code_pipeline:
- pipeline_result = delete_pipeline(client=client_conn, name=module.params['name'], module=module)
+ pipeline_result = delete_pipeline(client=client_conn, name=module.params["name"], module=module)
changed = True
module.exit_json(changed=changed, **camel_dict_to_snake_dict(pipeline_result))
-if __name__ == '__main__':
+if __name__ == "__main__":
main()