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

ec2_eip: add support of updating reverse dns record for eip #2292

Merged

Conversation

mandar242
Copy link
Contributor

SUMMARY

Add support of updating reverse dns record for eip
Fixes #1296

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ec2_eip

ADDITIONAL INFORMATION

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/modify_address_attribute.html


Copy link

github-actions bot commented Sep 10, 2024

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/f0dc43057ffd4f1e9334163e7a4a3127

⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection
build-ansible-collection FAILURE in 4m 55s
✔️ ansible-test-splitter SUCCESS in 4m 22s
⚠️ integration-amazon.aws-1 SKIPPED Skipped due to failed job build-ansible-collection
Skipped 43 jobs

Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/b7a996f9f16547b58387b76c9136c8a8

✔️ ansible-galaxy-importer SUCCESS in 4m 23s
✔️ build-ansible-collection SUCCESS in 11m 39s
✔️ ansible-test-splitter SUCCESS in 4m 16s
✔️ integration-amazon.aws-1 SUCCESS in 9m 20s
Skipped 43 jobs

Copy link
Contributor

@abikouo abikouo left a comment

Choose a reason for hiding this comment

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

I think what we expect here is just the possibility to modify an EIP attribute that is either newly created or already existing.

- name: Create new EIP and update DNS Record
  ec2_eip:
     state: present
     domain_name: example.net

or

- name: Update PTR Record of existing EIP
  ec2_eip:
     public_ip: 1.2.3.4
     domain_name: example.net

plugins/modules/ec2_eip.py Outdated Show resolved Hide resolved
plugins/modules/ec2_eip.py Outdated Show resolved Hide resolved
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/82d97e378baa4387959999d14ff39a14

✔️ ansible-galaxy-importer SUCCESS in 5m 00s
✔️ build-ansible-collection SUCCESS in 10m 30s
✔️ ansible-test-splitter SUCCESS in 4m 17s
✔️ integration-amazon.aws-1 SUCCESS in 10m 57s
Skipped 43 jobs

@mandar242 mandar242 requested review from abikouo and removed request for abikouo September 16, 2024 19:24
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/7b642fb0f72b45a5b5d540a4eb2d7aff

✔️ ansible-galaxy-importer SUCCESS in 5m 06s
✔️ build-ansible-collection SUCCESS in 10m 31s
✔️ ansible-test-splitter SUCCESS in 4m 17s
✔️ integration-amazon.aws-1 SUCCESS in 11m 31s
Skipped 43 jobs

Copy link
Contributor

@abikouo abikouo left a comment

Choose a reason for hiding this comment

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

Looks good to me!!
Could you please add integration tests to validate the new feature?

plugins/modules/ec2_eip.py Show resolved Hide resolved
plugins/modules/ec2_eip.py Outdated Show resolved Hide resolved
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/9a961645095d47f5bf9fa000171cc2e9

✔️ ansible-galaxy-importer SUCCESS in 4m 40s
✔️ build-ansible-collection SUCCESS in 10m 33s
✔️ ansible-test-splitter SUCCESS in 4m 17s
✔️ integration-amazon.aws-1 SUCCESS in 12m 57s
Skipped 43 jobs

@mandar242
Copy link
Contributor Author

@abikouo added tests, waiting on terminator for permissions PR to merge
mattclay/aws-terminator#310

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/44c62b2c6ba34344ac5228d107b81a21

✔️ ansible-galaxy-importer SUCCESS in 4m 13s
✔️ build-ansible-collection SUCCESS in 10m 48s
✔️ ansible-test-splitter SUCCESS in 4m 22s
integration-amazon.aws-1 FAILURE in 18m 31s
Skipped 43 jobs

vars:
has_no_new_eip: true

- name: Allocate a new EIP and modify it's reverse DNS record
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you also please add an idempotency check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to slack channel for discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alinabuzachis I have updated the tested to include more testing. The tests pass locally

        "ec2:DescribeVpcs",
        "ec2:DeleteVpc"
    ],
    "vpc": {}
}

PLAY RECAP *********************************************************************
testhost                   : ok=45   changed=17   unreachable=0    failed=0    skipped=16   rescued=0    ignored=0   

AWS ACTIONS: ['ec2:AllocateAddress', 'ec2:AttachInternetGateway', 'ec2:AuthorizeSecurityGroupIngress', 'ec2:CreateInternetGateway', 'ec2:CreateNetworkInterface', 'ec2:CreateSecurityGroup', 'ec2:CreateSubnet', 'ec2:CreateVpc', 'ec2:DeleteInternetGateway', 'ec2:DeleteNetworkInterface', 'ec2:DeleteSecurityGroup', 'ec2:DeleteSubnet', 'ec2:DeleteVpc', 'ec2:DescribeAddresses', 'ec2:DescribeAddressesAttribute', 'ec2:DescribeAvailabilityZones', 'ec2:DescribeInternetGateways', 'ec2:DescribeNetworkInterfaces', 'ec2:DescribeSecurityGroups', 'ec2:DescribeSubnets', 'ec2:DescribeTags', 'ec2:DescribeVpcAttribute', 'ec2:DescribeVpcs', 'ec2:DetachInternetGateway', 'ec2:ModifyAddressAttribute', 'ec2:ModifyVpcAttribute', 'ec2:ReleaseAddress', 'ec2:ResetAddressAttribute', 'route53:ChangeResourceRecordSets', 'route53:GetChange', 'route53:ListHostedZones', 'route53:ListResourceRecordSets', 'sts:GetCallerIdentity']
Command exited with status 0 after 435.9944279193878 seconds.

But, for now, I have disabled the tests for reverse DNS record feature as it requires use of registered domain and a corresponding hosted zone to successfully add reverse DNS record to an EIP.
Slack thread started for discussion on how to handle this.

Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/3dc02259415746e28575b9c409c5eda7

✔️ ansible-galaxy-importer SUCCESS in 4m 37s
✔️ build-ansible-collection SUCCESS in 10m 43s
✔️ ansible-test-splitter SUCCESS in 5m 15s
✔️ integration-amazon.aws-1 SUCCESS in 12m 41s
Skipped 43 jobs

tags: "{{ eip_test_tags }}"
register: eip

- name: Add EIP IP address an A record
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this step to test the newly added parameter? While it is beneficial to have an additional test for full functionality, I believe that if ec2_eip supports adding or modifying the EIP with a domain name and runs correctly in our CI account, we might not need to do the Route53 testing. What do you think? cc @alinabuzachis @abikouo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from what I understand if A record is not present in the hosted zone of domain being added to EIP reverse DNS recrod,

  1. The reverse DNS record does not get applied and fails
  2. There will be no way to test idempotency as there will be no successful EIP with domain applied
    that's why initially I had skipped adding idempotency test @GomathiselviS @alinabuzachis

- eip.public_ip is defined and ( eip.public_ip | ansible.utils.ipaddr )
- eip.allocation_id is defined and eip.allocation_id.startswith("eipalloc-")

- name: Wait for reverse DNS record update to complete
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, update takes more than a minute to complete, if not completed and we move to next task then the next task fails saying another request already pending on EIP

Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/38d32a88b45f4fe18015c53e6d82d042

✔️ ansible-galaxy-importer SUCCESS in 4m 46s
✔️ build-ansible-collection SUCCESS in 10m 40s
✔️ ansible-test-splitter SUCCESS in 4m 14s
✔️ integration-amazon.aws-1 SUCCESS in 11m 07s
Skipped 43 jobs

Copy link
Collaborator

@alinabuzachis alinabuzachis left a comment

Choose a reason for hiding this comment

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

Please ensure linter tests are green in the CI.

description: The domain name to attach to the IP address.
required: false
type: str
version_added: 9.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not including this feature into 8.3.0?

Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/8ca5b1afdaa543b4ab5685d7262e8f5b

✔️ ansible-galaxy-importer SUCCESS in 5m 16s
✔️ build-ansible-collection SUCCESS in 11m 11s
✔️ ansible-test-splitter SUCCESS in 4m 31s
✔️ integration-amazon.aws-1 SUCCESS in 12m 00s
Skipped 43 jobs

@mandar242 mandar242 added the mergeit Merge the PR (SoftwareFactory) label Sep 27, 2024
Copy link
Contributor

Build succeeded (gate pipeline).
https://ansible.softwarefactory-project.io/zuul/buildset/269aafb0e690429184ab23cfc3988e72

✔️ ansible-galaxy-importer SUCCESS in 6m 08s
✔️ build-ansible-collection SUCCESS in 11m 16s
✔️ ansible-test-splitter SUCCESS in 4m 26s
✔️ integration-amazon.aws-1 SUCCESS in 12m 38s
Skipped 43 jobs

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit efcaf86 into ansible-collections:main Sep 27, 2024
37 checks passed
braydencw1 pushed a commit to braydencw1/amazon.aws that referenced this pull request Oct 3, 2024
…collections#2292)

SUMMARY

Add support of updating reverse dns record for eip
Fixes ansible-collections#1296

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_eip
ADDITIONAL INFORMATION


https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/modify_address_attribute.html

Reviewed-by: Bikouo Aubin
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Alina Buzachis
Reviewed-by: GomathiselviS
@mandar242 mandar242 deleted the aaws-1296 branch October 29, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mergeit Merge the PR (SoftwareFactory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PTR Record (reverse DNS) on Elastic IP (ec2_eip)
4 participants