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

route53 - Refactor to use boto3 #405

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

pjrm
Copy link
Contributor

@pjrm pjrm commented Feb 11, 2021

  • Refactor route53 module to use boto3 instead of boto
SUMMARY
  • Migrate boto to boto3
  • Update requirements in documentation
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

route53 - Refactor to use boto3

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review feature This issue/PR relates to a feature request module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) labels Feb 11, 2021
@ansibullbot ansibullbot added docs needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Feb 11, 2021
@pjrm pjrm force-pushed the refactor_route53 branch 2 times, most recently from 17df4a1 to 94705bd Compare February 11, 2021 02:50
@ansibullbot ansibullbot added community_review and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Feb 11, 2021
Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to migrate this module to boto3. That the integration tests pass is certainly a good start.

I've not had chance to run through most of the code, but there are a number of helpers which should make things easier for you.
See also: https://docs.ansible.com/ansible/devel/dev_guide/platforms/aws_guidelines.html

In general:

plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Feb 11, 2021
@pjrm
Copy link
Contributor Author

pjrm commented Feb 11, 2021

Hi @tremble,

Thank you very much for the help and quick reply.

I have performed the changes based on the guide and your suggestions.

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

I'd like to see the paginated queries split into their own small functions, just doing the pagination, and we can use scrub_non_params rather than our own function. But other than that I think this PR is ready to roll. Thanks for working on this.

plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
plugins/modules/route53.py Show resolved Hide resolved
plugins/modules/route53.py Outdated Show resolved Hide resolved
resource_record_set['ResourceRecords'] = sorted(resource_record_set['ResourceRecords'], key=itemgetter('Value'))

if command_in == 'create' and aws_record == resource_record_set:
module.exit_json(changed=False)

if command_in == 'get':
Copy link
Contributor

Choose a reason for hiding this comment

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

You mentioned being interested in helping with community.aws in general. Not as part of this PR, but a separate PR we should probably deprecate the 'get' command here.

You'll notice that in tests/sanity/ignore-2.11.txt there's an entry

plugins/modules/route53.py validate-modules:parameter-state-invalid-choice

https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_best_practices.html#scoping-your-module-s

Do not add get, list or info state options to an existing module - create a new _info or _facts module

'get' commands are generally better handled by a dedicated _info module. I believe route53_info can be used to do this so if you're willing to raise a follow up PR it would be appreciated

* Refactor route53 module to use boto3 instead of boto
@ansibullbot ansibullbot added community_review and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Feb 12, 2021
@tremble tremble merged commit 08d0b9c into ansible-collections:main Feb 12, 2021
@tremble
Copy link
Contributor

tremble commented Feb 12, 2021

Thanks for you work on this. Should be available in community.aws:1.4.0

ethemcemozkan pushed a commit to ethemcemozkan/community.aws that referenced this pull request Feb 18, 2021
* route53 - Refactor to use boto3
* Changelog

Co-authored-by: Mark Chappell <[email protected]>
@eRadical
Copy link
Contributor

eRadical commented Mar 15, 2021

Just re-downloaded community.aws:1.4.0 and it complains that

    "msg": "The config profile (companyAccount-dev) could not be found"

While the following is ok:

$ aws configure get region --profile companyAccount-dev
eu-west-1

@eRadical
Copy link
Contributor

eRadical commented Mar 15, 2021

@tremble is there anyway I can help you to debug this?

[Having route53 work with profiles will be a huge plus as I'll delete a huge chunk of ansible code that does sts_assume_role saves the result in a variable... etc... ]

@tremble
Copy link
Contributor

tremble commented Mar 15, 2021

@eRadical, WFM...

(ansible-dev) [17:21:16+0100] ~/vcs/ansible 
[✔ ansible] $ ansible-playbook test.yml 
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]. This
 feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly
changing source of code and can become unstable at any point.
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] **************************************************************************************************************************************************************************************************

TASK [community.aws.route53] **************************************************************************************************************************************************************************************
changed: [localhost]

TASK [community.aws.route53] **************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

(ansible-dev) [17:21:23+0100] ~/vcs/ansible 
[✔ ansible] $ cat test.yml 
- hosts: localhost
  gather_facts: False
  connection: local
  collections:
  - amazon.aws
  - community.aws
  tasks:
  - community.aws.route53:
      zone: example.test
      record: home-sweet-home.example.test
      type: A
      value: 127.0.0.1
      state: present
      profile: myprofile
  - community.aws.route53:
      zone: example.test
      record: home-sweet-home.example.test
      type: A
      value: 127.0.0.1
      state: absent
      profile: myprofile

One key piece is that "profile" is passed directly to the boto3 library, if you don't use "local", then you'll need to make sure that the profile is available wherever the module is actually being executed (note: this will be the Ansible target not the controller.)

@eRadical
Copy link
Contributor

eRadical commented Mar 15, 2021

Yup... my bad.

I was inheriting become: true from the playbook/role.
Needless to say that on my machine there is no AWS profile under root.

Thank you @tremble for your time... and thanx @pjrm & @tremble for enhancing community.aws.route53!

alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request Jul 19, 2021
* route53 - Refactor to use boto3
* Changelog

Co-authored-by: Mark Chappell <[email protected]>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request Jul 19, 2021
* route53 - Refactor to use boto3
* Changelog

Co-authored-by: Mark Chappell <[email protected]>
danielcotton pushed a commit to danielcotton/community.aws that referenced this pull request Nov 23, 2021
* route53 - Refactor to use boto3
* Changelog

Co-authored-by: Mark Chappell <[email protected]>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
…e-collections#405)

Remove "missing credentials" tests from ec2_group/ec2_vpc_net

SUMMARY
AWS Client creation is now done inside a helper module which is more thoroughly tested.  Remove the extra tests from ec2_vpc_net and ec2_group.  They bring no significant value but do bump up the login failure count, which can result in the IPs getting temporarily black-listed
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_group
ec2_vpc_net
ADDITIONAL INFORMATION
For more thorough tests look at the module_utils_core tests

Reviewed-by: Jill R <None>
Reviewed-by: None <None>
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
* route53 - Refactor to use boto3
* Changelog

Co-authored-by: Mark Chappell <[email protected]>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections@08d0b9c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review docs feature This issue/PR relates to a feature request module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants