|
1 | 1 | --- |
2 | | -- name: Eject |
3 | | - block: |
4 | | - - name: DELL Eject Virtual Media (if any) |
5 | | - community.general.redfish_command: |
6 | | - category: Manager |
7 | | - command: VirtualMediaEject |
8 | | - baseuri: "{{ bmc_address }}" |
9 | | - username: "{{ bmc_user }}" |
10 | | - password: "{{ bmc_password }}" |
11 | | - virtual_media: |
12 | | - image_url: "{{ boot_iso_url }}" |
13 | | - resource_id: iDRAC.Embedded.1 |
14 | | - rescue: |
15 | | - - name: Get Virtual Media information |
16 | | - community.general.redfish_info: |
17 | | - category: Manager |
18 | | - command: GetVirtualMedia |
19 | | - baseuri: "{{ bmc_address }}" |
20 | | - username: "{{ bmc_user }}" |
21 | | - password: "{{ bmc_password }}" |
22 | | - register: result |
| 2 | +- name: Get Virtual Media information |
| 3 | + community.general.redfish_info: |
| 4 | + category: Manager |
| 5 | + command: GetVirtualMedia |
| 6 | + baseuri: "{{ bmc_address }}" |
| 7 | + username: "{{ bmc_user }}" |
| 8 | + password: "{{ bmc_password }}" |
| 9 | + timeout: 120 |
| 10 | + retries: 3 |
| 11 | + register: result |
| 12 | + delay: 10 |
| 13 | + until: result is succeeded |
23 | 14 |
|
24 | | - - name: Get blocking virtual_media |
25 | | - ansible.builtin.set_fact: |
26 | | - blocking_virtual_media: "{{ result.redfish_facts.virtual_media.entries |
27 | | - | flatten(levels=2) |
28 | | - | selectattr('ConnectedVia', 'defined') | list |
29 | | - | json_query('[?( |
30 | | - ConnectedVia == `URI` |
31 | | - && Image != null |
32 | | - && ( |
33 | | - contains(MediaTypes, `CD`) |
34 | | - || contains(MediaTypes, `DVD`) |
35 | | - || contains(MediaTypes, `VCD-DVD`) |
36 | | - ) |
37 | | - )]' |
38 | | - ) | from_yaml |
39 | | - }}" |
40 | | - |
41 | | - - name: Debug |
42 | | - ansible.builtin.debug: |
43 | | - var: blocking_virtual_media |
44 | | - verbosity: 1 |
45 | | - |
46 | | - - name: Attempting to eject blocking media |
47 | | - community.general.redfish_command: |
48 | | - category: Manager |
49 | | - command: VirtualMediaEject |
50 | | - baseuri: "{{ bmc_address }}" |
51 | | - username: "{{ bmc_user }}" |
52 | | - password: "{{ bmc_password }}" |
53 | | - virtual_media: |
54 | | - image_url: "{{ item.Image }}" |
55 | | - resource_id: iDRAC.Embedded.1 |
56 | | - loop: "{{ blocking_virtual_media }}" |
57 | | - no_log: true |
| 15 | +- name: Attempting to eject blocking media (if any) |
| 16 | + vars: |
| 17 | + blocking_virtual_media: "{{ result.redfish_facts.virtual_media.entries |
| 18 | + | flatten(levels=2) |
| 19 | + | selectattr('ConnectedVia', 'defined') | list |
| 20 | + | json_query('[?( |
| 21 | + ConnectedVia == `URI` |
| 22 | + && Image != null |
| 23 | + && ( |
| 24 | + contains(MediaTypes, `CD`) |
| 25 | + || contains(MediaTypes, `DVD`) |
| 26 | + || contains(MediaTypes, `VCD-DVD`) |
| 27 | + ) |
| 28 | + )]' |
| 29 | + ) | from_yaml |
| 30 | + }}" |
| 31 | + community.general.redfish_command: |
| 32 | + category: Manager |
| 33 | + command: VirtualMediaEject |
| 34 | + baseuri: "{{ bmc_address }}" |
| 35 | + username: "{{ bmc_user }}" |
| 36 | + password: "{{ bmc_password }}" |
| 37 | + timeout: 120 |
| 38 | + virtual_media: |
| 39 | + image_url: "{{ item.Image }}" |
| 40 | + resource_id: iDRAC.Embedded.1 |
| 41 | + loop: "{{ blocking_virtual_media }}" |
| 42 | + retries: 3 |
| 43 | + delay: 10 |
| 44 | + until: result is succeeded |
| 45 | + register: result |
| 46 | + no_log: true |
58 | 47 | ... |
0 commit comments