Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New module: manage CodeDeploy applications and deployment groups (cloud/amazon/aws_codedeploy_application) #25214

Open
wants to merge 16 commits into
base: devel
from

Conversation

@KurtKnudsen
Copy link

commented May 31, 2017

This module allows users to create/modify CodeDeploy applications and deployment groups.

SUMMARY

This module allows users to create/modify CodeDeploy applications and deployment groups. It requires boto3.

Fixes #30031

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

lib/ansible/modules/extras/cloud/amazon/aws_codedeploy_application.py

ANSIBLE VERSION
ansible 2.1.2.0
ADDITIONAL INFORMATION

I've not done a PR before, so let me know if I messed something up.

Module for managing CodeDeploy applications
This module allows users to create/modify CodeDeploy applications and deployment groups.
@KurtKnudsen

This comment has been minimized.

Copy link
Author

commented May 31, 2017

I'm not too sure what I need to do to make it not fail.

cda = get_codedeploy_application(connection, name, module)
module.exit_json(changed=changed, **camel_dict_to_snake_dict(cda))

from ansible.module_utils.basic import *

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

No need to import here. You already imported everything at top.

module)
elif state == 'absent':
changed = delete_codedeploy_application(connection, name)
module.exit_json( changed = changed )

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

Remove whitespace after and before round brackets.

def main():
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
application_name = dict(required=True, type='str'),

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

remove spaces around =

@@ -0,0 +1,414 @@
#!/usr/bin/python

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

GNU GPL Licence missing.

@@ -0,0 +1,414 @@
#!/usr/bin/python

import sys

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

Unused imports

short_description: Creates/modifies a CodeDeploy application and deployment group.
description:
- Creates/modifies a CodeDeploy application and deployment group.
version_added: 0.0

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

s/0.0/2.4/

required: false
state:
description:
- register or deregister the application

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

s/deregister/de-register/

return None
else:
module.fail_json(msg=e.message, **camel_dict_to_snake_dict(e.response))
return None

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

Blank line required.

newApplicationName=new_name)
changed = True
except ClientError as e:
changed = False

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

Remove extra indentation.

newApplicationName=new_name)
changed = True
except ClientError as e:
changed = False

This comment has been minimized.

Copy link
@Akasurde

Akasurde May 31, 2017

Member

changed = False is already set

@KurtKnudsen

This comment has been minimized.

Copy link
Author

commented May 31, 2017

@Akasurde I have made all the recommended changes and moved the file to the proper place, I'm guessing the web interface didn't let me select where it should go. Thanks for taking the time on this, this is all new to me.

Generic Ansible
@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 31, 2017

The test ansible-test sanity --test pep8 failed with the following errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:319:25: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:319:27: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:320:25: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:320:27: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:321:25: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:321:27: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:322:25: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:322:27: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:323:14: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:323:16: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:324:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:324:28: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:325:29: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:325:31: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:326:29: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:326:31: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:327:24: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:327:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:328:27: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:328:29: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:329:28: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:329:30: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:330:24: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:330:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:331:28: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:331:30: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:332:29: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:332:31: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:333:29: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:333:31: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:334:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:334:28: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:359:78: E231 missing whitespace after ','
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:368:26: E225 missing whitespace around operator
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:388:30: E225 missing whitespace around operator
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:390:26: E225 missing whitespace around operator
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:396:33: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:399:34: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:408:26: E225 missing whitespace around operator
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:426:33: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:426:35: E251 unexpected spaces around keyword / parameter equals

The test ansible-test sanity --test validate-modules failed with the following errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.alarm_configuration.type: not a valid value for dictionary value @ data['options']['alarm_configuration']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.auto_rollback_config.type: not a valid value for dictionary value @ data['options']['auto_rollback_config']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.bg_deployment_config.type: not a valid value for dictionary value @ data['options']['bg_deployment_config']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.load_balance_info.type: not a valid value for dictionary value @ data['options']['load_balance_info']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.on_premise_filters.type: not a valid value for dictionary value @ data['options']['on_premise_filters']['type']. Got 'list'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.trigger_configs.type: not a valid value for dictionary value @ data['options']['trigger_configs']['type']. Got 'list'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E314 No ANSIBLE_METADATA provided
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application_id.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application_name.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.create_time.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.create_time.type: not a valid value for dictionary value @ data['type']. Got 'datetime'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.linked_to_github.returned: required key not provided @ data['returned']. Got None

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 31, 2017

The test ansible-test sanity --test validate-modules failed with the following errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.alarm_configuration.type: not a valid value for dictionary value @ data['options']['alarm_configuration']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.auto_rollback_config.type: not a valid value for dictionary value @ data['options']['auto_rollback_config']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.bg_deployment_config.type: not a valid value for dictionary value @ data['options']['bg_deployment_config']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.load_balance_info.type: not a valid value for dictionary value @ data['options']['load_balance_info']['type']. Got 'dict'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.on_premise_filters.type: not a valid value for dictionary value @ data['options']['on_premise_filters']['type']. Got 'list'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E305 DOCUMENTATION.options.trigger_configs.type: not a valid value for dictionary value @ data['options']['trigger_configs']['type']. Got 'list'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E314 No ANSIBLE_METADATA provided
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application_id.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application_name.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.create_time.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.create_time.type: not a valid value for dictionary value @ data['type']. Got 'datetime'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.linked_to_github.returned: required key not provided @ data['returned']. Got None

click here for bot help

@ansibot ansibot removed the ci_verified label May 31, 2017

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 31, 2017

The test ansible-test sanity --test validate-modules failed with the following errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E314 No ANSIBLE_METADATA provided
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application_id.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application_name.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.create_time.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.create_time.type: not a valid value for dictionary value @ data['type']. Got 'datetime'
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.linked_to_github.returned: required key not provided @ data['returned']. Got None

click here for bot help

@ansibot ansibot added the ci_verified label May 31, 2017

@ansibot ansibot removed the ci_verified label May 31, 2017

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 31, 2017

The test ansible-test sanity --test validate-modules failed with the following errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.application_id: extra keys not allowed @ data['application_id']. Got {'type': 'string', 'sample': '81293494', 'description': 'The application ID.'}
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.application_name: extra keys not allowed @ data['application_name']. Got {'type': 'string', 'sample': 'TestApplication', 'description': 'The application name.'}
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.create_time: extra keys not allowed @ data['create_time']. Got {'type': 'datetime', 'sample': '2017-05-30 010:00:00-05:00', 'description': 'The time at which the application was created.'}
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.description: required key not provided @ data['description']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.linked_to_github: extra keys not allowed @ data['linked_to_github']. Got {'type': 'boolean', 'sample': False, 'description': 'True if the user has authenticated with GitHub for the specified application; otherwise, false.'}
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E319 RETURN.application.type: required key not provided @ data['type']. Got None

click here for bot help

@ansibot ansibot added the ci_verified label May 31, 2017

Generic Ansible

@ansibot ansibot removed the ci_verified label May 31, 2017

@ansibot ansibot removed the ci_verified label Apr 3, 2018

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2018

The test ansible-test sanity --test pylint [explain] failed with 6 errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:188:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:230:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:231:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:241:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:255:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:256:0: trailing-whitespace Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 15 errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:188:154: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:189:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:230:150: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:231:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:231:154: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:232:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:241:21: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:241:145: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:242:21: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:246:21: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:247:21: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:255:147: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:256:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:256:146: W291 trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:257:9: E128 continuation line under-indented for visual indent

The test ansible-test sanity --test validate-modules [explain] failed with 16 errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "access_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "access_token" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "aws_access_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "aws_region" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "aws_secret_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_access_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_region" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_secret_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_url" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "profile" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "region" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "secret_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "security_token" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "validate_certs" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E324 Value for "default" from the argument_spec (True) for "validate_certs" does not match the documentation (False)
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E325 argument_spec for "validate_certs" defines type="bool" but documentation does not

click here for bot help

@ansibot ansibot added the ci_verified label Apr 3, 2018

Generic Ansible

@ansibot ansibot removed the ci_verified label Apr 3, 2018

@KurtKnudsen

This comment has been minimized.

Copy link
Author

commented Apr 3, 2018

I'm not really sure how to fix the EXXX errors, is there some new protocol that is being enforced for new modules? My module doesn't use anything related to EC2, so seeing those is a bit confusing.

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 16 errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "access_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "access_token" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "aws_access_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "aws_region" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "aws_secret_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_access_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_region" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_secret_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "ec2_url" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "profile" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "region" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "secret_key" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "security_token" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E322 "validate_certs" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E324 Value for "default" from the argument_spec (True) for "validate_certs" does not match the documentation (False)
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:0:0: E325 argument_spec for "validate_certs" defines type="bool" but documentation does not

click here for bot help

@ansibot ansibot added ci_verified and removed ci_verified labels Apr 3, 2018

@@ -83,6 +83,9 @@
description:
- Information about the load balancer used in a deployment.
required: false
extends_documentation_fragment:
- aws
- ec2

This comment has been minimized.

Copy link
@Akasurde

Akasurde Apr 3, 2018

Member

Those ec2_* warnings are related to this documentation fragment.

This comment has been minimized.

Copy link
@KurtKnudsen

KurtKnudsen Apr 3, 2018

Author

I added that after I saw the errors and did some research on it. They appeared even without it and I thought that that inclusion would silence those errors, unless I'm doing it wrong, I'm not really sure why they're still appearing. It is odd that ansibot said it failed when the Shippable test below shows it passed. Maybe I'm confused, but I don't know what else to do.

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

As you say, shippable is showing all the tests as passing - ansibot must have still been processing the previous shippable failure.

if not HAS_BOTO3:
module.fail_json(msg='boto required for this module')

region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True)

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

use AnsibleAWSModule and then

connection = module.client('codedeploy')

is enough to connect.

load_balance_info = module.params.get('load_balance_info')

if not HAS_BOTO3:
module.fail_json(msg='boto required for this module')

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

Not required with AnsibleAWSModule

load_balance_info,
module)
else:
cd_properties = create_codedeploy_deployment_group(

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

These should probably be keyword parameters - a massive length of ordered parameters is an easy source of bugs.

bg_deployment_config=dict(required=False, type='dict', default=None),
load_balance_info=dict(required=False, type='dict', default=None)
))
module = AnsibleModule(argument_spec=argument_spec)

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

Should be AnsibleAWSModule now you're using fail_json_aws

on_premises_filters, auto_scaling_groups, service_role_arn, trigger_configs, alarm_configuration,
auto_rollback_config, deployment_style, bluegreen_deployment_config, load_balancer_info, module)
except ClientError as e:
module.fail_json(msg=e.message, **camel_dict_to_snake_dict(e.response))

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

Use fail_json_aws here

sample: false
'''

from ansible.module_utils.basic import AnsibleModule

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

Remove this line

'''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import boto3_conn, get_aws_connection_info, ec2_argument_spec, camel_dict_to_snake_dict

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

Once you use module.client, boto3_conn and get_aws_connection_info are no longer required

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import boto3_conn, get_aws_connection_info, ec2_argument_spec, camel_dict_to_snake_dict
from ansible.module_utils.aws.core import AnsibleAWSModule
import traceback

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

Should be able to remove this import and just use fail_json_aws

import traceback

try:
import boto3

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

No need to import boto3

try:
import boto3
from botocore.exceptions import ClientError, NoCredentialsError, BotoCoreError
HAS_BOTO3 = True

This comment has been minimized.

Copy link
@willthames

willthames Apr 3, 2018

Contributor

No need to set HAS_BOTO3 - the presence of boto3 and botocore are checked when constructing an AnsibleAWSModule object.

This comment has been minimized.

Copy link
@KurtKnudsen

KurtKnudsen Apr 3, 2018

Author

Thanks for these. I have them all done except the keyword args part, I need to look into how that's done.

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2018

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:334:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:354:42: undefined-variable Undefined variable 'get_aws_connection_info'

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:154:0: ImportError: No module named botocore.exceptions

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:154:0: ImportError: No module named botocore.exceptions

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:154:0: ImportError: No module named 'botocore'

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:154:0: ModuleNotFoundError: No module named 'botocore'

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:154:0: ModuleNotFoundError: No module named 'botocore'

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:156:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/cloud/amazon/aws_codedeploy_application.py:334:1: W293 blank line contains whitespace

click here for bot help

@ansibot ansibot added the ci_verified label Apr 3, 2018

Generic Ansible added 2 commits Apr 3, 2018
Generic Ansible
Generic Ansible

@ansibot ansibot removed the ci_verified label Apr 3, 2018

@KurtKnudsen

This comment has been minimized.

Copy link
Author

commented Apr 4, 2018

@willthames thanks again for all your help. Please let me know if you find anything else.

@willthames willthames requested a review from s-hertel Apr 10, 2018

@willthames

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2018

Looks good to me now. The argument_spec can be tidied a little (defaults are type='str', required=False and default=None - so no need to set any of those explicitly) but it's not really a blocker.

@s-hertel
Copy link
Contributor

left a comment

Since 2.5 new modules should also have integration tests. https://github.com/ansible/community/blob/master/group-aws/integration.md#policy

ec2_group has a good test suite you could check out.

"""Get the details of the CodeDeploy application."""
try:
return client.get_application(applicationName=name)
except (ClientError, NoCredentialsError) as e:

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jul 12, 2018

Contributor

You just need to catch ClientError and BotoCoreError. If you want, you can rebase on devel and use the pattern

from ansible.aws.core import is_boto3_error_code

try:
    return client.get_application(applicationName=name)
except is_boto3_error_code('ApplicationDoesNotExistException'):
    return None
except (BotoCoreError, ClientError) as e:
    module.fail_json_aws(e, "Could not get CodeDeploy application.")

Note: BotoCoreError does not have a .response so if you don't want to use the pattern above you should add

except BotoCoreError as e:

on line 169

sample: false
'''

from ansible.module_utils.ec2 import ec2_argument_spec, camel_dict_to_snake_dict

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jul 12, 2018

Contributor

AnsibleAWSModule incorporates ec2_argument_spec so you could remove this import and specify the arg spec as a dict.

try:
return client.get_deployment_group(applicationName=name, deploymentGroupName=deployment_group)
except (ClientError, BotoCoreError) as e:
if e.response['Error']['Code'] == 'ApplicationDoesNotExistException':

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jul 12, 2018

Contributor

Only ClientError has a .response so this will raise an AttributeError for BotoCoreError. A nice pattern to manage this is using the is_boto3_error_code() util like I suggested above.

serviceRoleArn=service_role_arn,
**dg_params)
changed = True
except (ClientError, NoCredentialsError) as e:

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jul 12, 2018

Contributor

This doesn't need to handle NoCredentialsError but it should handle BotoCoreError. And this will have the same issue above with e.response.

changed = update_codedeploy_deployment_group(client, name, module, deployment_group, new_deployment_group_name, deployment_config, ec2_tag_filters,
on_premises_filters, auto_scaling_groups, service_role_arn, trigger_configs, alarm_configuration,
auto_rollback_config, deployment_style, bluegreen_deployment_config, load_balancer_info)
except ClientError as e:

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jul 12, 2018

Contributor

All the boto3 client methods in this module should handle BotoCoreError. There are a number of places that need this added.

# Check if the deployment group already exists, if it does, update it.
has_deployment_group = get_codedeploy_application_deployment_group(connection, name, deployment_group, module)
if not has_application:
kwargs = {'deployment_group': deployment_group,

This comment has been minimized.

Copy link
@s-hertel

s-hertel Jul 12, 2018

Contributor

These three dicts are almost identical. I feel like you could generate some of it in common code.

@faabiosr

This comment has been minimized.

Copy link

commented Dec 20, 2018

Awesome contribution! I will wait!
@KurtKnudsen you have some news about this PR?

@ansibot ansibot removed the stale_review label Jul 1, 2019

@ansibot ansibot added the stale_review label Jul 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.