Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 905c71b

Browse files
committed
support async in instance creation
1 parent 1b07dcf commit 905c71b

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

molecule_vmware/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create_linux_instance.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@
2828
wait_for_ip_address: true
2929
wait_for_customization: true
3030
state: poweredon
31-
register: server
31+
async: 7200
32+
poll: 0
33+
register: async_results
3234
loop: "{{ molecule_yml.platforms }}"
3335

36+
- name: Check the test instance creation status
37+
async_status:
38+
jid: "{{ item.ansible_job_id }}"
39+
loop: "{{ async_results.results }}"
40+
register: server
41+
until: server.finished
42+
delay: 10
43+
retries: 300
44+
3445
- name: Create ssh directory and public key in guest OS
3546
vmware_vm_shell:
3647
hostname: "{{ molecule_yml.driver.vcenter_hostname }}"
@@ -50,14 +61,16 @@
5061
- name: Populate instance config dict
5162
set_fact:
5263
instance_conf_dict: {
53-
'instance': "{{ item.item.name }}",
54-
'address': "{{ item.instance.ipv4 }}",
64+
'instance': "{{ instance_info.item.item.name }}",
65+
'address': "{{ instance_info.instance.ipv4 }}",
5566
'user': "{{ molecule_yml.driver.vm_username }}",
5667
'port': 22,
5768
'identity_file': "{{ keypair_path }}",
5869
'instance_os_type': "{{ molecule_yml.driver.instance_os_type }}"
5970
}
6071
loop: "{{ server.results }}"
72+
loop_control:
73+
loop_var: instance_info
6174
register: instance_config_dict
6275
when: server is changed
6376

molecule_vmware/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create_windows_instance.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,20 @@
2424
wait_for_ip_address: true
2525
wait_for_customization: true
2626
state: poweredon
27-
register: server
27+
async: 7200
28+
poll: 0
29+
register: async_results
2830
loop: "{{ molecule_yml.platforms }}"
2931

32+
- name: Check the test instance creation status
33+
async_status:
34+
jid: "{{ item.ansible_job_id }}"
35+
loop: "{{ async_results.results }}"
36+
register: server
37+
until: server.finished
38+
delay: 10
39+
retries: 300
40+
3041
- name: Enable WinRM
3142
vmware_vm_shell:
3243
hostname: "{{ molecule_yml.driver.vcenter_hostname }}"
@@ -84,8 +95,8 @@
8495
- name: Populate instance config dict
8596
set_fact:
8697
instance_conf_dict: {
87-
'instance': "{{ item.item.name }}",
88-
'address': "{{ item.instance.ipv4 }}",
98+
'instance': "{{ instance_info.item.item.name }}",
99+
'address': "{{ instance_info.instance.ipv4 }}",
89100
'port': "{{ molecule_yml.driver.winrm_port | default(5986) }}",
90101
'connection': "{{ molecule_yml.driver.connection | default('winrm') }}",
91102
'user': "{{ molecule_yml.driver.vm_username }}",
@@ -95,6 +106,8 @@
95106
'instance_os_type': "{{ molecule_yml.driver.instance_os_type }}"
96107
}
97108
loop: "{{ server.results }}"
109+
loop_control:
110+
loop_var: instance_info
98111
register: instance_config_dict
99112
when: server is changed
100113

0 commit comments

Comments
 (0)