From 5e18e0dcd496593912ac9c7aa6d5dd7e24fcfd05 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 21 Apr 2023 13:17:11 +0200 Subject: [PATCH 1/4] Fstring cleanup We've dropped support for Python <3.6, bulk migrate to fstrings and perform some general string cleanup A combination of * `black --preview` * `flynt` * some manual cleanup --- plugins/inventory/aws_ec2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inventory/aws_ec2.py b/plugins/inventory/aws_ec2.py index 4295546df41..260ad03d51f 100644 --- a/plugins/inventory/aws_ec2.py +++ b/plugins/inventory/aws_ec2.py @@ -416,7 +416,7 @@ def _prepare_host_vars( if use_contrib_script_compatible_ec2_tag_keys: for k, v in host_vars["tags"].items(): - host_vars["ec2_tag_%s" % k] = v + host_vars[f"ec2_tag_{k}"] = v if hostvars_prefix or hostvars_suffix: for hostvar, hostval in host_vars.copy().items(): From 5c8ef3698d7dd6ae77aea6187ebea229d8f7f3f2 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sun, 7 May 2023 13:39:08 +0200 Subject: [PATCH 2/4] Bump Fedora image --- tests/integration/targets/inventory_aws_ec2/tasks/setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml b/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml index 36e8a1f8559..47e7f4c88a1 100644 --- a/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml +++ b/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml @@ -7,7 +7,7 @@ owner-id: '125523088429' virtualization-type: hvm root-device-type: ebs - name: 'Fedora-Cloud-Base-34-1.2.x86_64*' + name: 'Fedora-Cloud-Base-37-1.2.x86_64*' register: fedora_images - name: Set image id, vpc cidr and subnet cidr From 18de7dee90d77aa180e1b9f064f562553be99f7c Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sun, 7 May 2023 13:43:34 +0200 Subject: [PATCH 3/4] changelog --- changelogs/fragments/fstring-ec2_inv.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/fstring-ec2_inv.yml diff --git a/changelogs/fragments/fstring-ec2_inv.yml b/changelogs/fragments/fstring-ec2_inv.yml new file mode 100644 index 00000000000..e207c7d9459 --- /dev/null +++ b/changelogs/fragments/fstring-ec2_inv.yml @@ -0,0 +1,3 @@ +# 1483 includes a fragment and links to 1513 +trivial: +- bulk migration of ``%`` and ``.format()`` to fstrings (https://github.com/ansible-collections/amazon.aws/pull/1526). From c6a997c5787bba26ad5602b3d99ff48d1b6e6578 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sun, 7 May 2023 15:02:31 +0200 Subject: [PATCH 4/4] Retry getting initial details of subnet when waiting if we're not passed any --- changelogs/fragments/fstring-ec2_inv.yml | 2 ++ plugins/modules/ec2_vpc_subnet.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/changelogs/fragments/fstring-ec2_inv.yml b/changelogs/fragments/fstring-ec2_inv.yml index e207c7d9459..130c494209c 100644 --- a/changelogs/fragments/fstring-ec2_inv.yml +++ b/changelogs/fragments/fstring-ec2_inv.yml @@ -1,3 +1,5 @@ # 1483 includes a fragment and links to 1513 trivial: - bulk migration of ``%`` and ``.format()`` to fstrings (https://github.com/ansible-collections/amazon.aws/pull/1526). +minor_changes: +- ec2_vpc_subnet - retry fetching subnet details after creation if the first attempt fails (https://github.com/ansible-collections/amazon.aws/pull/1526). diff --git a/plugins/modules/ec2_vpc_subnet.py b/plugins/modules/ec2_vpc_subnet.py index 98aedf4c7c1..c61d9df2bd0 100644 --- a/plugins/modules/ec2_vpc_subnet.py +++ b/plugins/modules/ec2_vpc_subnet.py @@ -481,6 +481,11 @@ def ensure_subnet_present(conn, module): subnet = get_matching_subnet(conn, module, module.params["vpc_id"], module.params["cidr"]) if not module.check_mode and module.params["wait"]: + for _rewait in range(0, 5): + if subnet: + break + time.sleep(2) + subnet = get_matching_subnet(conn, module, module.params["vpc_id"], module.params["cidr"]) # GET calls are not monotonic for map_public_ip_on_launch and assign_ipv6_address_on_creation # so we only wait for those if necessary just before returning the subnet subnet = ensure_final_subnet(conn, module, subnet, start_time)