forked from rhos-infra/dellemc-idrac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.yaml
More file actions
98 lines (92 loc) · 3.47 KB
/
Copy pathmain.yaml
File metadata and controls
98 lines (92 loc) · 3.47 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
- hosts: "{{ hosts_pattern }}"
connection: local
name: Dell iDRAC Hosts
gather_facts: False
any_errors_fatal: True
vars:
# Placeholder variables
idrac_query: False
bios_attributes: False
boot_mode: False
boot_order: False
power_action: False
pre_tasks:
- name: Build A List Of Variables For iDRAC
set_fact:
host_play_variables: "{{ hostvars[inventory_hostname] }}"
# This allows us to override variables for individual hosts
- name: Append Extra Vars To host_play_variables If Supplied
set_fact:
host_play_variables: "{{ host_play_variables | combine(hostvars[inventory_hostname][inventory_hostname]) }}"
when: "inventory_hostname in hostvars[inventory_hostname]"
- name: Check if can authenticate with iDRAC
include_role:
name: configuration
tasks_from: healthcheck
when: |-
'idrac_query' in host_play_variables or
'bios_attributes' in host_play_variables or
'boot_mode' in host_play_variables or
'boot_order' in host_play_variables or
'power_action' in host_play_variables
tasks:
- name: Query iDRAC
include_role:
name: configuration
tasks_from: query
when: "'idrac_query' in host_play_variables"
- name: Configure Bioss
vars:
host_bios_attributes: >-
{%- if 'bios_attributes' in host_play_variables -%}
{{ host_play_variables['bios_attributes'] }}
{%- else -%}
{{ bios_attributes }}
{%- endif -%}
host_boot_mode: >-
{%- if 'boot_mode' in host_play_variables -%}
{{ host_play_variables['boot_mode'] }}
{%- else -%}
{{ boot_mode }}
{%- endif -%}
host_boot_order: >-
{%- if 'boot_order' in host_play_variables -%}
{%- if (host_play_variables['boot_order'] | type_debug) == 'str' -%}
{{ host_play_variables['boot_order'].split(',') }}
{%- elif (host_play_variables['boot_order'] | type_debug) == 'list' -%}
{{ host_play_variables['boot_order'] }}
{%- endif -%}
{%- else -%}
{{ boot_order }}
{%- endif -%}
host_bios_configuration: >-
{%- set bios_dict=dict() -%}
{%- if host_bios_attributes -%}
{{ bios_dict.update(host_bios_attributes) }}
{%- endif -%}
{%- if host_boot_mode -%}
{{ bios_dict.update({'BootMode': host_boot_mode}) }}
{%- endif -%}
{{ bios_dict }}
block:
- name: Check BIOS Configuration Status
include_role:
name: configuration
tasks_from: check_bios
- name: Update BIOS Configuration
include_role:
name: configuration
tasks_from: configure_bios
# We parse each BIOS attribute individually in order to build a correct config
when: >-
(host_bios_attributes) and (host_bios_attributes | type_debug == 'dict') or
(host_boot_mode) and (host_boot_mode in ['Bios', 'Uefi']) or
(host_boot_order) and (host_boot_order | type_debug == 'list')
- name: Power Action
include_role:
name: configuration
tasks_from: power_action
when:
- "'power_action' in host_play_variables"
- host_play_variables['power_action'] in ['PowerOn', 'PowerForceOff', 'PowerForceRestart','PowerGracefulRestart', 'PowerGracefulShutdown', 'PowerReboot']