From 615126e7710f1e6856a4f02388ec1d5fd3697cd5 Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 4 Sep 2025 13:10:19 +0300 Subject: [PATCH] replace_ansible_pause_module --- roles/asg_management/README.md | 1 + roles/asg_management/defaults/main.yml | 2 +- roles/asg_management/tasks/asg_target_health.yml | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/asg_management/README.md b/roles/asg_management/README.md index f9f4db80..e7ff0132 100644 --- a/roles/asg_management/README.md +++ b/roles/asg_management/README.md @@ -6,6 +6,7 @@ In order to manipulate an AWS Autoscaling Group (ASG) your `deploy` user must ha * `autoscaling:SuspendProcesses` * `autoscaling:DescribeScalingProcessTypes` * `autoscaling:DescribeAutoScalingGroups` +* `autoscaling:StartInstanceRefresh` Set the `asg_management.name` to the machine name of your ASG in order to automatically suspend and resume autoscaling on build. diff --git a/roles/asg_management/defaults/main.yml b/roles/asg_management/defaults/main.yml index ab54916e..0c5dbd46 100644 --- a/roles/asg_management/defaults/main.yml +++ b/roles/asg_management/defaults/main.yml @@ -7,4 +7,4 @@ asg_management: #profile: "example" # optional, the boto profile name to use if not the system default region: "eu-west-1" suspend_processes: "Launch Terminate HealthCheck" # space separated string, see https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-suspend-resume-processes.html - pause: 5 # how long in seconds to wait before polling the AWS API again for instance statuses + pause: 10 # localhost ping count, to wait before polling the AWS API again for instance statuses (instead of ansible 'pause' module which seems to be buggy and hangs sometimes) diff --git a/roles/asg_management/tasks/asg_target_health.yml b/roles/asg_management/tasks/asg_target_health.yml index 78f3b21b..26b58f97 100644 --- a/roles/asg_management/tasks/asg_target_health.yml +++ b/roles/asg_management/tasks/asg_target_health.yml @@ -1,7 +1,8 @@ --- - name: Pause so as to not hammer the AWS API. - ansible.builtin.pause: - seconds: "{{ asg_management.pause }}" + ansible.builtin.command: + cmd: "ping localhost -c {{ asg_management.pause }}" + failed_when: false - name: Empty the target list. ansible.builtin.set_fact: