You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
921 B
30 lines
921 B
2 years ago
|
- block:
|
||
|
- name: call pvesh command
|
||
|
command:
|
||
|
cmd: "pvesh get /cluster/resources --type vm --output-format yaml"
|
||
|
register: res
|
||
|
failed_when: no
|
||
|
changed_when: no
|
||
|
delegate_to: "{{ node }}"
|
||
|
no_log: yes
|
||
|
|
||
|
- block:
|
||
|
- name: set temp pvesh result
|
||
|
set_fact:
|
||
|
temp_node_result: "{{ res.stdout | from_yaml | selectattr('vmid', 'equalto', container_id) | list }}"
|
||
|
|
||
|
- name: fail if node is empty or more than one container was found
|
||
|
fail:
|
||
|
when: ((temp_node_result | length) != 1) or (temp_node_result[0].node is not defined)
|
||
|
|
||
|
- name: set selected node
|
||
|
set_fact:
|
||
|
selected_node: "{{ temp_node_result[0].node }}"
|
||
|
|
||
|
- name: set node found result
|
||
|
set_fact:
|
||
|
is_node_found: yes
|
||
|
|
||
|
when: (res.stdout is string) and (res.stdout | length > 0)
|
||
|
|
||
|
when: is_node_found == false
|