-
Notifications
You must be signed in to change notification settings - Fork 398
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
Add ec2_asg_tag module #482
Conversation
ansible/check failure seems to be unrelated to the change. |
recheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
dunno if you get the 1.4.0 train. maybe it is to late.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you need also a changelog fragment.
Can you please advise what a new module fragment looks like? I've been unable to find any such occurrence in the git log. |
9619414
to
03c7023
Compare
ready_for_review |
A new module to manage ASG tags, analogous to the `ec2_tag` module in `amazon.aws` collection. Fixes ansible-collections#481
Take a look in the |
Reading that document suggests otherwise:
|
recheck |
/rebuild_failed |
/rebuild |
@markuman can I please get another review on this? The Shippable check if failing for unrelated reasons to this PR/change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR @jsok. We just recently migrated off of Shippable CI and onto Zuul (the ansible/check
Checks) and it looks like this PR just got caught in that transition time, no need to worry about those failures.
return tag_list | ||
|
||
|
||
def compare_asg_tags(current_tags_dict, new_tags_dict, purge_tags=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please import and use the compare_aws_tags
function from the module utility?
https://github.com/ansible-collections/amazon.aws/blob/main/plugins/module_utils/ec2.py#L783
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jillr this and the other requested changes weren't possible based on my testing.
ASG tags aren't just K/V pairs (as expected by compare_aws_tags
, boto3_tag_list_to_ansible_dict
and ansible_dict_to_boto3_tag_list
), they're a list of dicts instead. The ramification here is that if propagate_at_launch
is changed but the K/V doesn't, the module won't detect any tag changes which I believe is not the desired behaviour.
Another issue I ran into was that the to_text
and to_native
functions did some odd things, particularly around None
values. Hence why compare_asg_tags
doesn't use them like compare_aws_tags
.
From memory you can't roundtrip None
like to_native(to_text(None))
... or maybe it was the other way around? 🤔
return tags_to_set, tag_keys_to_unset | ||
|
||
|
||
def tag_list_to_dict(tag_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for boto3_tag_list_to_ansible_dict
:
https://github.com/ansible-collections/amazon.aws/blob/main/plugins/module_utils/ec2.py#L465
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry | ||
|
||
|
||
def to_boto3_tag_list(tags, group_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please import and use the ansible_dict_to_boto3_tag_list
function from the module utility?
@@ -247,6 +247,124 @@ | |||
- "output.tags | length == 1" | |||
- output is changed | |||
|
|||
# ============================================================ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add some tests for adding and removing tags in check_mode?
Hi all, thanks for the reviews but unfortunately I won't have time to follow up on the requested changes (this PR was to help implement something at my previous role, however I've moved roles since raising the PR). I'm going to close this PR but happy for someone else to pick up where I left off. Sorry for the inconvenience ❤️ |
ec2_asg: Add purge_tags to AutoScalingGroups. SUMMARY Add purge_tags to ec2_asg module. Fixes #481. ISSUE TYPE Feature Pull Request COMPONENT NAME ec2_asg ADDITIONAL INFORMATION There was another PR (currently closed) #482 - with similar functionality but I'm not sure if having modules to handle tags for individual services/modules is a good way to have this functionality. It will certainly cause increase in number of modules. Hence tried modifying existing ec2_asg module to be able to do this. This utilizes underlying API calls to: https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeTags.html https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CreateOrUpdateTags.html https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DeleteTags.html Reviewed-by: Alina Buzachis <None> Reviewed-by: Jill R <None> Reviewed-by: Mandar Kulkarni <[email protected]>
ec2_asg: Add purge_tags to AutoScalingGroups. SUMMARY Add purge_tags to ec2_asg module. Fixes ansible-collections#481. ISSUE TYPE Feature Pull Request COMPONENT NAME ec2_asg ADDITIONAL INFORMATION There was another PR (currently closed) ansible-collections#482 - with similar functionality but I'm not sure if having modules to handle tags for individual services/modules is a good way to have this functionality. It will certainly cause increase in number of modules. Hence tried modifying existing ec2_asg module to be able to do this. This utilizes underlying API calls to: https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeTags.html https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CreateOrUpdateTags.html https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DeleteTags.html Reviewed-by: Alina Buzachis <None> Reviewed-by: Jill R <None> Reviewed-by: Mandar Kulkarni <[email protected]>
…#483) ec2_vol: Fix incorrectly returned changed result SUMMARY When modify_volume is used but no new disk is being attached, the module incorrectly reports that no change has occurred even when disks have been modified (iops, throughput, type, etc.). This is due to the attach function overwriting the changed variable even if no disks are attached. Fixes ansible-collections#482 The integration test has been fixed so that when the gp3 modifications are tested, the volume is already in an attached state (previously detached) when reporting back changed. The detach tests are moved further down now, allowing this case to be properly covered by the existing assert: amazon.aws/tests/integration/targets/ec2_vol/tasks/tests.yml Lines 384 to 387 in e8df917 - name: check that volume_type has changed assert: that: - changed_gp3_volume.changed ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_vol Reviewed-by: Alina Buzachis <None> Reviewed-by: None <None> Reviewed-by: Mark Chappell <None> Reviewed-by: None <None>
SUMMARY
A new module to manage ASG tags, analogous to the
ec2_tag
module inamazon.aws
collection.Fixes #481
ISSUE TYPE
COMPONENT NAME
ec2_asg_tag
ADDITIONAL INFORMATION
Motivation is outlined in #481, but this module provides a more declarative approach to managing ASG tags, e.g.:
The module utilises underlying API calls to: