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

Commit

Permalink
Merge pull request #1 from sky-joker/v3.0.0
Browse files Browse the repository at this point in the history
Support async in instance creation
  • Loading branch information
sky-joker authored Jan 10, 2021
2 parents 1b07dcf + 905c71b commit 991d542
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@
wait_for_ip_address: true
wait_for_customization: true
state: poweredon
register: server
async: 7200
poll: 0
register: async_results
loop: "{{ molecule_yml.platforms }}"

- name: Check the test instance creation status
async_status:
jid: "{{ item.ansible_job_id }}"
loop: "{{ async_results.results }}"
register: server
until: server.finished
delay: 10
retries: 300

- name: Create ssh directory and public key in guest OS
vmware_vm_shell:
hostname: "{{ molecule_yml.driver.vcenter_hostname }}"
Expand All @@ -50,14 +61,16 @@
- name: Populate instance config dict
set_fact:
instance_conf_dict: {
'instance': "{{ item.item.name }}",
'address': "{{ item.instance.ipv4 }}",
'instance': "{{ instance_info.item.item.name }}",
'address': "{{ instance_info.instance.ipv4 }}",
'user': "{{ molecule_yml.driver.vm_username }}",
'port': 22,
'identity_file': "{{ keypair_path }}",
'instance_os_type': "{{ molecule_yml.driver.instance_os_type }}"
}
loop: "{{ server.results }}"
loop_control:
loop_var: instance_info
register: instance_config_dict
when: server is changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@
wait_for_ip_address: true
wait_for_customization: true
state: poweredon
register: server
async: 7200
poll: 0
register: async_results
loop: "{{ molecule_yml.platforms }}"

- name: Check the test instance creation status
async_status:
jid: "{{ item.ansible_job_id }}"
loop: "{{ async_results.results }}"
register: server
until: server.finished
delay: 10
retries: 300

- name: Enable WinRM
vmware_vm_shell:
hostname: "{{ molecule_yml.driver.vcenter_hostname }}"
Expand Down Expand Up @@ -84,8 +95,8 @@
- name: Populate instance config dict
set_fact:
instance_conf_dict: {
'instance': "{{ item.item.name }}",
'address': "{{ item.instance.ipv4 }}",
'instance': "{{ instance_info.item.item.name }}",
'address': "{{ instance_info.instance.ipv4 }}",
'port': "{{ molecule_yml.driver.winrm_port | default(5986) }}",
'connection': "{{ molecule_yml.driver.connection | default('winrm') }}",
'user': "{{ molecule_yml.driver.vm_username }}",
Expand All @@ -95,6 +106,8 @@
'instance_os_type': "{{ molecule_yml.driver.instance_os_type }}"
}
loop: "{{ server.results }}"
loop_control:
loop_var: instance_info
register: instance_config_dict
when: server is changed

Expand Down

0 comments on commit 991d542

Please sign in to comment.