Debian Codegraph @

ansible_collections/dellemc/openmanage/playbooks/ome/ome_group_device_action.yml

raw symbols SCIP
1 ---
2 - name: Dell OpenManage Ansible group device operations.
3 hosts: ome
4 gather_facts: false
5 vars:
6 group_name: Dell iDRAC Servers
7 device_action: refresh_inventory # other options are clear_idrac_job_queue, reset_idrac
8 validate_certs: true
9 ca_path: "/path/to/ca_cert.pem"
10
11 tasks:
12 - name: Retrieve group ID based on group name.
13 ansible.builtin.uri:
14 url: "https://{{ hostname }}/api/GroupService/Groups?Name={{ group_name }}"
15 user: "{{ username }}"
16 password: "{{ password }}"
17 method: "GET"
18 use_proxy: true
19 status_code: 200
20 return_content: true
21 validate_certs: "{{ validate_certs }}"
22 ca_path: "{{ ca_path }}"
23 force_basic_auth: true
24 headers:
25 Content-Type: "application/json"
26 Accept: "application/json"
27 register: group_id
28 delegate_to: localhost
29
30 - name: Assign group ID to a variable.
31 ansible.builtin.set_fact:
32 group_id_value: "{{ group_id.json.value[0].Id }}"
33 delegate_to: localhost
34
35 - name: Retrieve all devices under the group ID.
36 ansible.builtin.uri:
37 url: "https://{{ hostname }}/api/GroupService/Groups({{ group_id_value }})/AllLeafDevices"
38 user: "{{ username }}"
39 password: "{{ password }}"
40 method: "GET"
41 use_proxy: true
42 status_code: 200
43 return_content: true
44 validate_certs: "{{ validate_certs }}"
45 ca_path: "{{ ca_path }}"
46 force_basic_auth: true
47 headers:
48 Content-Type: "application/json"
49 Accept: "application/json"
50 register: all_devices
51 delegate_to: localhost
52
53 - name: Empty list to store device IDs.
54 ansible.builtin.set_fact:
55 devices_list: []
56 delegate_to: localhost
57
58 - name: Add devices retrieved from a group to the list.
59 ansible.builtin.set_fact:
60 devices_list: "{{ devices_list + [item.Id] }}"
61 with_items:
62 - "{{ all_devices.json.value }}"
63 delegate_to: localhost
64
65 - name: Perform device action tasks on devices. # noqa: args[module]
66 dellemc.openmanage.ome_devices:
67 hostname: "{{ hostname }}"
68 username: "{{ username }}"
69 password: "{{ password }}"
70 validate_certs: "{{ validate_certs }}"
71 ca_path: "{{ ca_path }}"
72 device_action: "{{ device_action }}"
73 device_ids: "{{ devices_list }}"
74 delegate_to: localhost