Skip to content

Instantly share code, notes, and snippets.

@murrahjm
Created October 11, 2018 19:38
Show Gist options
  • Save murrahjm/c4d38b0667655052eb75feb828bc9644 to your computer and use it in GitHub Desktop.
Save murrahjm/c4d38b0667655052eb75feb828bc9644 to your computer and use it in GitHub Desktop.
Ansible tasks for bare metal provisioning of ML110 via the ilo 5 redfish REST API
---
- hosts: localhost
connection: local
gather_facts: no
vars:
- ilo_username: Administrator
- ilo_password: somesecretvalue
- serial_number: 1A2B3C456
- ilo_license: "12345-ABCDE-67890-FGHIJ-KLMNO"
tasks:
- name: install ilo advanced license key
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Managers/1/LicenseService/"
method: POST
body: |
{
"LicenseKey": "{{ilo_license}}"
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
status_code: 201
- name: enable raid controller
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/bios/settings/"
method: PUT
body: |
{
"Attributes": {
"EmbeddedSata": "Raid"
}
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
- name: reset system
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/"
method: POST
body: |
{
"ResetType": "ForceRestart"
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
- name: wait for POST
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/"
method: GET
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
register: system_status
until: (system_status.json.Oem.Hpe.PostState == 'InPostDiscoveryComplete') or
(system_status.json.Oem.Hpe.PostState == 'FinishedPost')
retries: 50
delay: 5
- name: create logical drives
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/SmartStorageConfig/Settings/"
method: PUT
body: |
{
"DataGuard": "Strict",
"LogicalDrives": [
{
"DataDrives": [
"3I:0:10"
],
"Raid": "Raid0"
},
{
"DataDrives": [
"1I:0:1"
],
"Raid": "Raid0"
}
]
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
- name: reset system
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/"
method: POST
body: |
{
"ResetType": "ForceRestart"
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
- name: wait for POST
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/"
method: GET
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
register: system_status
until: (system_status.json.Oem.Hpe.PostState == 'InPostDiscoveryComplete') or
(system_status.json.Oem.Hpe.PostState == 'FinishedPost')
retries: 50
delay: 5
- name: set HTTP boot URL
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/bios/settings/"
method: PUT
body: |
{
"Attributes": {
"UrlBootFile": "http://mdt_ansible.domain.com/MDT_ANSIBLE_UNATTENDED.iso"
}
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
- name: reset system
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/"
method: POST
body: |
{
"ResetType": "ForceRestart"
}
body_format: json
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
- name: wait for POST
uri:
url: "https://ilo{{serial_number}}.domain.com/redfish/v1/Systems/1/"
method: GET
force_basic_auth: yes
user: "{{ilo_username}}"
password: "{{ilo_password}}"
validate_certs: false
register: system_status
until: (system_status.json.Oem.Hpe.PostState == 'InPostDiscoveryComplete') or
(system_status.json.Oem.Hpe.PostState == 'FinishedPost')
retries: 50
delay: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment