From 0c9ccbf28a8dee8165b5ba20d3acb79de7a4998d Mon Sep 17 00:00:00 2001 From: Sandwich Date: Thu, 12 Mar 2026 05:57:11 +0100 Subject: [PATCH] fix(bootstrap): move SSH switchover to main.yml between roles, guard become with default --- main.yml | 22 +++++++++++++++++++ .../environment/tasks/_configure_network.yml | 16 -------------- roles/environment/tasks/main.yml | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/main.yml b/main.yml index 6fce4e0..5ea1357 100644 --- a/main.yml +++ b/main.yml @@ -129,6 +129,28 @@ ansible.builtin.include_role: name: environment + - name: Switch to SSH connection for VMware + when: + - hypervisor_type == "vmware" + - hypervisor_cfg.ssh | default(false) | bool + - system_cfg.network.ip | default('') | string | length > 0 + block: + - name: Set SSH connection variables + ansible.builtin.set_fact: + ansible_connection: ssh + ansible_user: root + ansible_password: "" + ansible_host: "{{ system_cfg.network.ip }}" + ansible_ssh_extra_args: "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" + + - name: Reset VMware Tools connection + ansible.builtin.meta: reset_connection + + - name: Verify SSH connectivity + ansible.builtin.wait_for_connection: + timeout: 30 + delay: 2 + - name: Partition disks ansible.builtin.include_role: name: partitioning diff --git a/roles/environment/tasks/_configure_network.yml b/roles/environment/tasks/_configure_network.yml index 8e56586..d42781e 100644 --- a/roles/environment/tasks/_configure_network.yml +++ b/roles/environment/tasks/_configure_network.yml @@ -83,19 +83,3 @@ ansible.builtin.service: name: sshd state: reloaded - - - name: Switch to SSH connection - ansible.builtin.set_fact: - ansible_connection: ssh - ansible_user: root - ansible_password: "" - ansible_host: "{{ system_cfg.network.ip }}" - ansible_ssh_extra_args: "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" - - - name: Reset connection to apply SSH switch - ansible.builtin.meta: reset_connection - - - name: Wait for SSH connection - ansible.builtin.wait_for_connection: - timeout: 30 - delay: 2 diff --git a/roles/environment/tasks/main.yml b/roles/environment/tasks/main.yml index ce72093..eda86c7 100644 --- a/roles/environment/tasks/main.yml +++ b/roles/environment/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Configure work environment - become: "{{ hypervisor_type != 'vmware' }}" + become: "{{ (hypervisor_type | default('none')) != 'vmware' }}" block: - name: Detect and validate live environment ansible.builtin.include_tasks: _detect_live.yml