Skip to content

Commit

Permalink
update meta/runtime.yml, modules and tests
Browse files Browse the repository at this point in the history
add changelog file
  • Loading branch information
abikouo committed Oct 16, 2024
1 parent b0e8b32 commit b2ac534
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
major_changes:
- autoscaling_instance_refresh - The module has been migrated from the ``community.aws``
collection. Playbooks using the Fully Qualified Collection Name for this module
should be updated to use ``amazon.aws.autoscaling_instance_refresh`` (https://github.com/ansible-collections/amazon.aws/pull/2338).
- autoscaling_instance_refresh_info - The module has been migrated from the ``community.aws``
collection. Playbooks using the Fully Qualified Collection Name for this module
should be updated to use ``amazon.aws.autoscaling_instance_refresh_info`` (https://github.com/ansible-collections/amazon.aws/pull/2338).
18 changes: 13 additions & 5 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ action_groups:
aws:
- autoscaling_group
- autoscaling_group_info
- autoscaling_instance_refresh
- autoscaling_instance_refresh_info
- aws_az_info
- aws_caller_info
- aws_region_info
Expand Down Expand Up @@ -146,6 +148,12 @@ plugin_routing:
ec2_asg_info:
# Deprecation for this alias should not *start* prior to 2024-09-01
redirect: amazon.aws.autoscaling_group_info
ec2_asg_instance_refresh:
# Deprecation for this alias should not *start* prior to 2024-09-01
redirect: amazon.aws.autoscaling_instance_refresh
ec2_asg_instance_refresh_info:
# Deprecation for this alias should not *start* prior to 2024-09-01
redirect: amazon.aws.autoscaling_instance_refresh_info
ec2_elb_lb:
# Deprecation for this alias should not *start* prior to 2024-09-01
redirect: amazon.aws.elb_classic_lb
Expand All @@ -164,14 +172,14 @@ plugin_routing:
rds_param_group:
redirect: amazon.aws.rds_instance_param_group
deprecation:
removal_version: 10.0.0
warning_text: >-
rds_param_group has been renamed to rds_instance_param_group.
Please update your tasks.
removal_version: 10.0.0
warning_text: >-
rds_param_group has been renamed to rds_instance_param_group.
Please update your tasks.
lookup:
aws_ssm:
# Deprecation for this alias should not *start* prior to 2024-09-01
redirect: amazon.aws.ssm_parameter
aws_secret:
# Deprecation for this alias should not *start* prior to 2024-09-01
redirect: amazon.aws.secretsmanager_secret
redirect: amazon.aws.secretsmanager_secret
12 changes: 6 additions & 6 deletions plugins/modules/autoscaling_instance_refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
---
module: autoscaling_instance_refresh
version_added: 3.2.0
version_added_collection: community.aws
short_description: Start or cancel an EC2 Auto Scaling Group (ASG) instance refresh in AWS
description:
- Start or cancel an EC2 Auto Scaling Group instance refresh in AWS.
- Can be used with M(community.aws.autoscaling_instance_refresh_info) to track the subsequent progress.
- Can be used with M(amazon.aws.autoscaling_instance_refresh_info) to track the subsequent progress.
- Prior to release 5.0.0 this module was called M(community.aws.ec2_asg_instance_refresh).
The usage did not change.
author:
Expand Down Expand Up @@ -84,17 +85,17 @@
# Note: These examples do not set authentication details, see the AWS Guide for details.
- name: Start a refresh
community.aws.autoscaling_instance_refresh:
amazon.aws.autoscaling_instance_refresh:
name: some-asg
state: started
- name: Cancel a refresh
community.aws.autoscaling_instance_refresh:
amazon.aws.autoscaling_instance_refresh:
name: some-asg
state: cancelled
- name: Start a refresh and pass preferences
community.aws.autoscaling_instance_refresh:
amazon.aws.autoscaling_instance_refresh:
name: some-asg
state: started
preferences:
Expand Down Expand Up @@ -185,10 +186,9 @@
from ansible_collections.amazon.aws.plugins.module_utils.autoscaling import cancel_instance_refresh
from ansible_collections.amazon.aws.plugins.module_utils.autoscaling import describe_instance_refreshes
from ansible_collections.amazon.aws.plugins.module_utils.autoscaling import start_instance_refresh
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


def validate_healthy_percentage(preferences: Dict[str, Union[bool, int]]) -> Optional[str]:
min_healthy_percentage = preferences.get("min_healthy_percentage")
Expand Down
12 changes: 6 additions & 6 deletions plugins/modules/autoscaling_instance_refresh_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
---
module: autoscaling_instance_refresh_info
version_added: 3.2.0
version_added_collection: community.aws
short_description: Gather information about EC2 Auto Scaling Group (ASG) Instance Refreshes in AWS
description:
- Describes one or more instance refreshes.
Expand Down Expand Up @@ -47,23 +48,23 @@
# Note: These examples do not set authentication details, see the AWS Guide for details.
- name: Find an refresh by ASG name
community.aws.autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: somename-asg
- name: Find an refresh by ASG name and one or more refresh-IDs
community.aws.autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: somename-asg
ids: ['some-id-123']
register: asgs
- name: Find an refresh by ASG name and set max_records
community.aws.autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: somename-asg
max_records: 4
register: asgs
- name: Find an refresh by ASG name and NextToken, if received from a previous call
community.aws.autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: somename-asg
next_token: 'some-token-123'
register: asgs
Expand Down Expand Up @@ -151,8 +152,7 @@

from ansible_collections.amazon.aws.plugins.module_utils.autoscaling import AnsibleAutoScalingError
from ansible_collections.amazon.aws.plugins.module_utils.autoscaling import describe_instance_refreshes

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule


def format_response(response: Dict[str, Any]) -> Dict[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
---
- name: Test getting info for an ASG name
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
register: output

- name: Assert that the correct number of records are returned
assert:
ansible.builtin.assert:
that:
- output.instance_refreshes | map(attribute='instance_refresh_id') | unique | length == 7

- name: Test using fake refresh ID
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
ids: ['0e367f58-blabla-bla-bla-ca870dc5dbfe']
register: output

- name: Assert that no record is returned
assert:
ansible.builtin.assert:
that:
- output.instance_refreshes | length == 0

- name: Test using a real refresh ID
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
ids: [ '{{ refreshout.instance_refreshes.instance_refresh_id }}' ]
register: output

- name: Assert that the correct record is returned
assert:
ansible.builtin.assert:
that:
- output.instance_refreshes | length == 1

- name: Test getting info for an ASG name which doesn't exist
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: n0n3x1stentname27b
ignore_errors: true
register: output

- name: Assert that module failed to return record
assert:
ansible.builtin.assert:
that:
- "'Failed to describe InstanceRefreshes: An error occurred (ValidationError) when calling the DescribeInstanceRefreshes operation: AutoScalingGroup name not found - AutoScalingGroup n0n3x1stentname27b not found' in output.msg"

- name: Retrieve instance refresh info
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
register: output

- name: Assert that the correct number of records are returned
assert:
ansible.builtin.assert:
that:
- output.instance_refreshes | length == 7

- name: Retrieve instance refresh info using next_token
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
next_token: "fake-token-123"
ignore_errors: true
register: output

- name: Assert that valid message with fake-token is returned
assert:
ansible.builtin.assert:
that:
- '"Failed to describe InstanceRefreshes: An error occurred (InvalidNextToken) when calling the DescribeInstanceRefreshes operation: The token ''********'' is invalid." in output.msg'

- name: Retrieve instance refresh info using max_records
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
max_records: 1
register: output_with_token

- name: Assert that max records=1 returns no more than one record
assert:
ansible.builtin.assert:
that:
- output_with_token.instance_refreshes | length == 1

- name: Retrieve instance refresh using valid token
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
next_token: "{{ output_with_token.next_token }}"
register: output

- name: Assert that valid message with real-token is returned
assert:
ansible.builtin.assert:
that:
- output.instance_refreshes | length == 6

- name: Test using both real nextToken and max_records=1
autoscaling_instance_refresh_info:
amazon.aws.autoscaling_instance_refresh_info:
name: "{{ asg_name }}"
max_records: 1
next_token: "{{ output_with_token.next_token }}"
register: output

- name: Assert that only one instance refresh is returned
assert:
ansible.builtin.assert:
that:
- output.instance_refreshes | length == 1
Loading

0 comments on commit b2ac534

Please sign in to comment.