From a86d828553d4d724d4ad3ca5335711b6bb1c0eb5 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 10 Aug 2023 17:50:50 +0200 Subject: cloud_init_wait: factor out to file_wait --- roles/cloud_init_wait/defaults/main.yml | 1 - roles/cloud_init_wait/tasks/check.yml | 23 ----------------------- roles/cloud_init_wait/tasks/main.yml | 10 +++++----- 3 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 roles/cloud_init_wait/tasks/check.yml (limited to 'roles/cloud_init_wait') diff --git a/roles/cloud_init_wait/defaults/main.yml b/roles/cloud_init_wait/defaults/main.yml index e5971c9..b857f1d 100644 --- a/roles/cloud_init_wait/defaults/main.yml +++ b/roles/cloud_init_wait/defaults/main.yml @@ -1,3 +1,2 @@ cloud_init_wait_path: /var/lib/cloud/instance/boot-finished cloud_init_wait_seconds: 300 -cloud_init_wait_delay: 10 diff --git a/roles/cloud_init_wait/tasks/check.yml b/roles/cloud_init_wait/tasks/check.yml deleted file mode 100644 index 2dc20aa..0000000 --- a/roles/cloud_init_wait/tasks/check.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Make a playbook usable immediately after creating a VM - even before -# the SSH server is started. -- name: Wait for SSH connection - ansible.builtin.wait_for_connection: - timeout: '{{ cloud_init_wait_seconds }}' - -# Again, make a playbook usable immediately after creating a VM - that includes -# waiting until cloud-init is done. -- name: Wait until cloud-init is finished - ansible.builtin.file: - path: '{{ cloud_init_wait_path }}' - state: file - register: boot_finished - until: boot_finished is succeeded - # About 5 minutes worth of attempts. - retries: '{{ cloud_init_wait_seconds // cloud_init_wait_delay }}' - delay: '{{ cloud_init_wait_delay }}' - ignore_unreachable: true - ignore_errors: true - -- ansible.builtin.include_tasks: check.yml - when: - - boot_finished is unreachable diff --git a/roles/cloud_init_wait/tasks/main.yml b/roles/cloud_init_wait/tasks/main.yml index dec4162..22c258d 100644 --- a/roles/cloud_init_wait/tasks/main.yml +++ b/roles/cloud_init_wait/tasks/main.yml @@ -1,5 +1,5 @@ -- ansible.builtin.include_tasks: check.yml - -- ansible.builtin.fail: - msg: Failed to wait until cloud-init is done - when: boot_finished is not defined or boot_finished is not succeeded +- ansible.builtin.include_role: + name: file_wait + vars: + file_wait_path: '{{ cloud_init_wait_path }}' + file_wait_seconds: '{{ cloud_init_wait_seconds }}' -- cgit v1.2.3