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

Improve route53_facts to modern Ansible standards #31860

Closed
wants to merge 1 commit into from

Conversation

willthames
Copy link
Contributor

@willthames willthames commented Oct 18, 2017

SUMMARY
  • Use built in retries, pagination
  • Return snake case
  • Document returns
  • Better tag handling

Fixes #49457

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

route53_facts

ANSIBLE VERSION
ansible 2.5.0 (devel 7623c2fbda) last updated 2017/10/18 12:38:39 (GMT +1000)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/will/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/will/src/ansible/lib/ansible
  executable location = /home/will/src/ansible/bin/ansible
  python version = 2.7.13 (default, Sep  5 2017, 08:53:59) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]

@willthames
Copy link
Contributor Author

There are a lot of changes here, but given the module's current return values are undocumented and the module is in preview status, I hope that the changes are acceptable.

I have tested them against my existing route53 resources, they seem to work

@ansibot
Copy link
Contributor

ansibot commented Oct 18, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 aws cloud community_review In order to be merged, this PR must follow the community review workflow. feature_pull_request module This issue/PR relates to a module. module_utils/ needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Oct 18, 2017
@willthames
Copy link
Contributor Author

@mikedlr this PR contains a change to module_utils.aws.core to support the deprecate method.

@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Oct 18, 2017
@weisslj
Copy link
Contributor

weisslj commented Oct 19, 2017

I have tested this with our current route53 setup, which works.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 27, 2017
try:
return list_record_sets_with_backoff(client, params)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Couldn't list record sets")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If providing a hosted_zone_id that has been removed, this fails. Should it fail, or should record sets just be an empty dict if e.response['Error']['Code'] == 'NoSuchHostedZone' in list_record_sets_with_backoff()? Wondered something similar throughout reading this PR in a number of other places too.

Copy link
Contributor Author

@willthames willthames Nov 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this spot @s-hertel - it's a great catch. To be honest I think it's a flaw with AWSRetry that this happens - retries for not found should be handled by calling functions.

But until there's consensus on that, I'll add a fix for this.

Edit: Ah, I'm thinking of retries for NotFound codes, this is a different situation. It's a tough call - I'm not sure whether it's better to return an empty result for a non existent hosted zone - in some ways the error message is clearer.


results = client.list_reusable_delegation_sets(**params)
else:
if module.params.get('delegation_set_id'):
params['DelegationSetId'] = module.params.get('delegation_set_id')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 'DelegationSetId' needs to be 'Id'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I did not change this, how long has this bug been present! (Thanks again for spotting this)

next_marker: "{{ first_facts.NextMarker }}"
max_items: 1
when: "{{ 'NextMarker' in first_facts }}"
RETURN = '''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hurrah for RETURN docs :)

* Use built in retries, pagination
* Return snake case
* Document returns
* Better tag handling
* Deprecate resource_id parameter
* Deprecate tags query method
* Fail on multiple resource_ids
@willthames
Copy link
Contributor Author

@s-hertel I've fixed the delegation set id bug. I think a module failure for a non existent hosted zone seems reasonable.

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 1, 2017
@@ -43,15 +43,8 @@
required: false
max_items:
description:
- Maximum number of items to return for various get/list requests
required: false
next_marker:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete the docs for the next_marker? IMO we should entirely remove the max_items and next_marker settings and use pagination internally, there doesn't seem to be a good reason to expose these. Obviously needs to be supported still for the deprecation cycle, but it seems like unnecessary complexity.

- name: setup of example for using next_marker
route53_facts:
query: hosted_zone
max_items: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get de-emphasizing next marker, but we shouldn't remove the example entirely I don't think.

resource_id = module.params.get('resource_id')
if resource_id:
if len(resource_id) > 1:
module.fail_json(msg='Using multiple resource_ids is no longer supported. Use a loop')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can fail out on this without a deprecation cycle first.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Nov 7, 2017
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 15, 2017
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Nov 23, 2017
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Feb 14, 2018
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 2, 2018
@ansibot ansibot added needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 5, 2018
@ansibot ansibot removed the needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) label Nov 10, 2018
@ansibot ansibot added new_module This PR includes a new module. new_plugin This PR includes a new plugin. labels Jun 11, 2019
@bkmeneguello
Copy link
Contributor

Hey, there is something preventing this PR to be merged? I usually need to workaround the route53 info module because of this problem, and this PR works very well.

@ansibot
Copy link
Contributor

ansibot commented Jan 31, 2020

@ansibot ansibot removed the new_module This PR includes a new module. label Mar 28, 2020
@ansibot ansibot added collection Related to Ansible Collections work collection:amazon.aws collection:community.aws needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Apr 29, 2020
@ansibot
Copy link
Contributor

ansibot commented Aug 16, 2020

Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.

For further information, please see:
https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md

@ansibot ansibot closed this Aug 16, 2020
@ansible ansible locked and limited conversation to collaborators Sep 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 aws bot_closed cloud collection:amazon.aws collection:community.aws collection Related to Ansible Collections work feature This issue/PR relates to a feature request. module_utils/ module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_plugin This PR includes a new plugin. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

route53_facts can't return a list of max_items > 100
7 participants