-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathawx-proxmox-start-vm.yml
55 lines (47 loc) · 1.84 KB
/
awx-proxmox-start-vm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
- name: "Proxmox: start VM"
connection: local
hosts: all
gather_facts: False
vars:
collected_proxmox_vms: {}
tasks:
- name: Include Proxmox common discovery
include_tasks: "ansible-tasks/collect-proxmox-vms.yml"
- name: Start specified VM
community.general.proxmox_kvm:
#node: "{{ proxmox_env_info.node }}"
api_user: "{{ proxmox_env_info.api_user }}"
api_token_id: "{{ proxmox_env_info.api_token_id }}"
api_token_secret: "{{ proxmox_env_info.api_token_secret }}"
api_host: "{{ proxmox_env_info.api_host }}"
name: "{{ vm_config['name'] }}"
state: started
when: vm_config['name'] in collected_proxmox_vms
register: start_vm_job
async: 180
poll: 0
- name: Wait for VM start process to finish
async_status:
jid: "{{ start_vm_job.ansible_job_id }}"
when: vm_config['name'] in collected_proxmox_vms
register: _sjobs_alias_vc_0
until: _sjobs_alias_vc_0.finished
retries: 100
delay: 10
- name: Discover Proxmox started VM on node
community.general.proxmox_vm_info:
api_host: "{{ proxmox_env_info.api_host | default(omit) }}"
api_user: "{{ proxmox_env_info.api_user | default(omit) }}"
api_token_id: "{{ proxmox_env_info.api_token_id | default(omit) }}"
api_token_secret: "{{ proxmox_env_info.api_token_secret | default(omit) }}"
node: "{{ proxmox_env_info.node }}"
name: "{{ vm_config['name'] }}"
config: "current"
register: proxmox_started_vm
- name: Show started VM info
debug:
msg: "started vm info: {{ proxmox_started_vm }}"
# - name: Wait for SSH on VMs to become available
# wait_for: host="{{ nb_vm_interface_assigned_ip[item] | regex_replace('/.*$', '') }}" port=22 delay=10 timeout=300
# with_items: "{{ proxmox_all_vm_interfaces }}"
# when: proxmox_all_vm_interfaces[item].primary