infra VMs: use wait_for rather than wait_for_connection

wait_for_connection requires a python interpreter to be available, which
may not be the case in some images (CentOS Stream cloud images, cirros
etc.). Instead, use wait_for to wait for the SSH port to open, then rely
on the bootstrapping process to install an interpreter. This is the same
method used for the seed VM.

This change also syncs the SSH wait timeout for infra VMs which the one
used for seed VM provisioning (360 seconds).

Change-Id: I758aff1d3ef714f1c8ef82d29dd2217734a9aae6
This commit is contained in:
Mark Goddard 2021-10-08 16:52:19 +01:00
parent bf440c5dd2
commit b87d89aae3
1 changed files with 7 additions and 12 deletions

View File

@ -29,17 +29,12 @@
tags:
- infra-vm-provision
tasks:
- name: Wait for a connection to VM with bootstrap user
wait_for_connection:
- name: Wait for SSH access to the infra VM
wait_for:
host: "{{ hostvars[inventory_hostname].ansible_host }}"
port: 22
state: started
# NOTE: Ensure we exceed the 5 minute DHCP timeout of the eth0
# interface if necessary.
timeout: 600
vars:
# NOTE(wszumski): ansible_host_key_checking variable doesn't seem to
# work, But it would be nice not to fail if the host_key changes.
# We check the hostkey during host configure.
# https://github.com/ansible/ansible/blob/1c34492413dec09711c430745034db0c108227a9/lib/ansible/plugins/connection/ssh.py#L49
# https://github.com/ansible/ansible/issues/49254
ansible_ssh_extra_args: '{{ infra_vm_wait_connection_ssh_extra_args }}'
ansible_user: "{{ bootstrap_user }}"
ansible_python_interpreter: /usr/bin/python3
timeout: 360
delegate_to: localhost