Skip to content

Commit 849a1ba

Browse files
committed
After rebooting add pause so that vm looses ip
1 parent 98c6ec4 commit 849a1ba

File tree

2 files changed

+46
-49
lines changed

2 files changed

+46
-49
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- name: Shutdown VM
2+
scale_computing.hypercore.vm_params:
3+
vm_name: "{{ cloned_vm_name }}"
4+
power_state: reboot
5+
6+
- name: Pause for 30 seconds, so that VM looses the IP
7+
ansible.builtin.pause:
8+
seconds: 30
9+
10+
- name: Wait until VM reports its IP address
11+
scale_computing.hypercore.vm_info:
12+
vm_name: "{{ cloned_vm_name }}"
13+
register: cloned_vm_info
14+
until: cloned_vm_info.records.0.nics.0.ipv4_addresses
15+
retries: 60
16+
delay: 10

examples/vm_os_upgrade/main.yml

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
---
22
# Run as:
33
# ansible-playbook -i examples/vm_os_upgrade/inventory.yml -e @examples/vm_os_upgrade/vars.yml examples/vm_os_upgrade/main.yml
4-
- name: Create VM
5-
hosts: localhost
6-
connection: local
7-
gather_facts: false
8-
tasks:
9-
- name: Create SSH key
10-
ansible.builtin.include_tasks: 01_create_ssh_key.yml
11-
- name: Upload ISO image
12-
ansible.builtin.include_tasks: 02_upload_iso.yml
13-
- name: Create source VM
14-
ansible.builtin.include_tasks: 03_create_source_vm.yml
4+
# - name: Create VM
5+
# hosts: localhost
6+
# connection: local
7+
# gather_facts: false
8+
# tasks:
9+
# - name: Create SSH key
10+
# ansible.builtin.include_tasks: 01_create_ssh_key.yml
11+
# - name: Upload ISO image
12+
# ansible.builtin.include_tasks: 02_upload_iso.yml
13+
# - name: Create source VM
14+
# ansible.builtin.include_tasks: 03_create_source_vm.yml
1515

16-
- name: Inject data into VM
17-
hosts: "{{ source_vm_name }}"
18-
tasks:
19-
- name: Setup source VM
20-
ansible.builtin.include_tasks: 04_setup_source_vm.yml
16+
# - name: Inject data into VM
17+
# hosts: "{{ source_vm_name }}"
18+
# tasks:
19+
# - name: Setup source VM
20+
# ansible.builtin.include_tasks: 04_setup_source_vm.yml
2121

22-
- name: Clone VM
23-
hosts: localhost
24-
connection: local
25-
gather_facts: false
26-
tasks:
27-
- name: Create clone from source VM
28-
ansible.builtin.include_tasks: 05_clone_from_source.yml
22+
# - name: Clone VM
23+
# hosts: localhost
24+
# connection: local
25+
# gather_facts: false
26+
# tasks:
27+
# - name: Create clone from source VM
28+
# ansible.builtin.include_tasks: 05_clone_from_source.yml
2929

3030
- name: Upgrade all the packages and kernel before upgrading the distribution version
3131
hosts: "{{ cloned_vm_name }}"
@@ -37,21 +37,12 @@
3737
ansible.builtin.apt:
3838
upgrade: dist
3939

40-
- name: Reboot VM
40+
- name: Reboot cloned VM
4141
hosts: localhost
4242
connection: local
4343
tasks:
44-
- name: Reboot VM after dist-upgrade, since some of them require reboot
45-
scale_computing.hypercore.vm_params:
46-
vm_name: "{{ cloned_vm_name }}"
47-
power_state: reboot
48-
- name: Wait until cloned VM reports its IP address
49-
scale_computing.hypercore.vm_info:
50-
vm_name: "{{ cloned_vm_name }}"
51-
register: cloned_vm_info
52-
until: cloned_vm_info.records.0.nics.0.ipv4_addresses
53-
retries: 60
54-
delay: 10
44+
- name: Reboot VM
45+
ansible.builtin.include_tasks: 06_reboot_cloned_vm.yml
5546

5647
- name: Upgrade distribution version
5748
hosts: "{{ cloned_vm_name }}"
@@ -60,23 +51,14 @@
6051
- name: Upgrade distribution version
6152
ansible.builtin.shell: do-release-upgrade -f DistUpgradeViewNonInteractive
6253

63-
- name: Reboot VM
54+
- name: Reboot cloned VM
6455
hosts: localhost
6556
connection: local
6657
tasks:
67-
- name: Reboot VM after distribution version upgrade
68-
scale_computing.hypercore.vm_params:
69-
vm_name: "{{ cloned_vm_name }}"
70-
power_state: reboot
71-
- name: Wait until cloned VM reports its IP address
72-
scale_computing.hypercore.vm_info:
73-
vm_name: "{{ cloned_vm_name }}"
74-
register: cloned_vm_info
75-
until: cloned_vm_info.records.0.nics.0.ipv4_addresses
76-
retries: 60
77-
delay: 10
58+
- name: Reboot VM
59+
ansible.builtin.include_tasks: 06_reboot_cloned_vm.yml
7860

79-
- name: Check distribution version and upload index.html
61+
- name: Check distribution version and index.html
8062
hosts: "{{ cloned_vm_name }}"
8163
gather_facts: true
8264
tasks:
@@ -89,4 +71,3 @@
8971
delegate_to: localhost
9072
register: url_data
9173
failed_when: "'test-html-for-scale-computing-demo' not in url_data.content"
92-
- meta: end_play

0 commit comments

Comments
 (0)