|
6 | 6 | when: ubuntu_install_method is defined and ubuntu_install_method == "simulation" |
7 | 7 |
|
8 | 8 | # Wait for autoinstall start message in serial port output file |
9 | | -- include_tasks: ../../../common/vm_wait_log_msg.yml |
10 | | - vars: |
11 | | - vm_wait_log_name: "{{ vm_serial_port_output_file | basename }}" |
12 | | - vm_wait_log_msg: "{{ autoinstall_start_msg }}" |
13 | | - vm_wait_log_retries: 150 |
14 | | - vm_wait_log_delay: 5 |
| 9 | +- name: "Wait for Ubuntu autoinstall is started successfully" |
15 | 10 | when: ubuntu_install_method is defined and ubuntu_install_method == "cloud-init" |
| 11 | + block: |
| 12 | + - name: "Wait for autoinstall start message" |
| 13 | + include_tasks: ../../../common/vm_wait_log_msg.yml |
| 14 | + vars: |
| 15 | + vm_wait_log_name: "{{ vm_serial_port_output_file | basename }}" |
| 16 | + vm_wait_log_msg: "{{ autoinstall_start_msg }}[^\\r\\n]*" |
| 17 | + vm_wait_log_retries: 150 |
| 18 | + vm_wait_log_delay: 5 |
| 19 | + |
| 20 | + # Ubuntu autoinstall with cloud configs requires network connection. |
| 21 | + # When autoinstall start message is detected, its must be followed with an IPv4 |
| 22 | + # address get at early-commands in the unattend install config file. |
| 23 | + # Otherwise, we can stop autoinstall immediately. |
| 24 | + - name: "Get the IPv4 address when Ubuntu autoinstall started" |
| 25 | + ansible.builtin.set_fact: |
| 26 | + ubuntu_autoinstall_start_ipv4: >- |
| 27 | + {{ |
| 28 | + vm_wait_log_msg_list | |
| 29 | + map('replace', autoinstall_start_msg, '') | |
| 30 | + map('trim') | |
| 31 | + ansible.utils.ipaddr('address') |
| 32 | + }} |
| 33 | +
|
| 34 | + - name: "Check VM obtains IPv4 address" |
| 35 | + ansible.builtin.assert: |
| 36 | + that: |
| 37 | + - ubuntu_autoinstall_start_ipv4 |
| 38 | + - ubuntu_autoinstall_start_ipv4 | length > 0 |
| 39 | + - ubuntu_autoinstall_start_ipv4[0] is ansible.utils.ipv4 |
| 40 | + fail_msg: "Ubuntu autoinstall failed to start due to no IPv4 address obtained." |
| 41 | + success_msg: "Ubuntu autoinstall is started with IPv4 address {{ ubuntu_autoinstall_start_ipv4 }}" |
0 commit comments