-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(os): added scripts to install ubuntu on servers
Signed-off-by: sakethanne <[email protected]>
- Loading branch information
1 parent
4a4dfaa
commit 80e490c
Showing
2 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
- name: Debug IDRAC credentials | ||
ansible.builtin.debug: | ||
msg: "iDRAC User: {{ idrac_user }}, iDRAC Password: {{ ansible_password }}" | ||
|
||
- name: Find the URL for the DellOSDeploymentService | ||
ansible.builtin.uri: | ||
url: "https://{{ ansible_host }}/redfish/v1/Systems/System.Embedded.1" | ||
user: "{{ idrac_user }}" | ||
password: "{{ ansible_password }}" | ||
method: GET | ||
headers: | ||
Accept: "application/json" | ||
OData-Version: "4.0" | ||
status_code: 200 | ||
validate_certs: "{{ validate_certs }}" | ||
force_basic_auth: "{{ force_basic_auth }}" | ||
register: result | ||
delegate_to: localhost | ||
|
||
- name: Find the URL for the DellOSDeploymentService2 | ||
ansible.builtin.set_fact: | ||
idrac_osd_service_url: "{{ result.json.Links.Oem.Dell.DellOSDeploymentService['@odata.id'] }}" | ||
when: | ||
- result.json.Links.Oem.Dell.DellOSDeploymentService is defined | ||
|
||
- name: Get ISO image attach status | ||
when: | ||
- idrac_osd_service_url is defined | ||
- idrac_osd_service_url|length > 0 | ||
block: | ||
- name: Get ISO attach status | ||
ansible.builtin.uri: | ||
url: "https://{{ ansible_host }}{{ idrac_osd_service_url }}/Actions/DellOSDeploymentService.GetAttachStatus" | ||
user: "{{ idrac_user }}" | ||
password: "{{ ansible_password }}" | ||
method: POST | ||
headers: | ||
Accept: "application/json" | ||
Content-Type: "application/json" | ||
OData-Version: "4.0" | ||
body: "{}" | ||
status_code: 200 | ||
validate_certs: "{{ validate_certs }}" | ||
force_basic_auth: "{{ force_basic_auth }}" | ||
register: attach_status | ||
delegate_to: localhost | ||
|
||
- name: Set ISO attach status as a fact variable | ||
ansible.builtin.set_fact: | ||
idrac_iso_attach_status: "{{ idrac_iso_attach_status | default({}) | combine({item.key: item.value}) }}" | ||
with_dict: | ||
drivers_attach_status: "{{ attach_status.json.DriversAttachStatus }}" | ||
iso_attach_status: "{{ attach_status.json.ISOAttachStatus }}" | ||
|
||
- name: Detatch ISO image if attached | ||
when: | ||
- idrac_osd_service_url is defined and idrac_osd_service_url|length > 0 | ||
- idrac_iso_attach_status | ||
- idrac_iso_attach_status.iso_attach_status == "Attached" or idrac_iso_attach_status.drivers_attach_status == "Attached" | ||
block: | ||
- name: Detach ISO image if attached | ||
ansible.builtin.uri: | ||
url: "https://{{ ansible_host }}{{ idrac_osd_service_url }}/Actions/DellOSDeploymentService.DetachISOImage" | ||
user: "{{ idrac_user }}" | ||
password: "{{ ansible_password }}" | ||
method: POST | ||
headers: | ||
Accept: "application/json" | ||
Content-Type: "application/json" | ||
OData-Version: "4.0" | ||
body: "{}" | ||
status_code: 200 | ||
validate_certs: "{{ validate_certs }}" | ||
force_basic_auth: "{{ force_basic_auth }}" | ||
register: detach_status | ||
delegate_to: localhost | ||
|
||
- name: Print a message | ||
ansible.builtin.debug: | ||
msg: "Successfuly detached the ISO image" | ||
|
||
- name: Install Ubuntu OS using ISO | ||
ansible.builtin.import_role: | ||
name: dellemc.openmanage.idrac_os_deployment | ||
vars: | ||
hostname: "{{ ansible_host }}" | ||
username: "{{ idrac_user }}" | ||
password: "{{ ansible_password }}" | ||
os_name: RHEL | ||
os_version: 9 | ||
source: | ||
protocol: http | ||
hostname: "{{ ip_address }}" | ||
iso_path: "" | ||
iso_name: "{{ ubuntu_iso }}" | ||
is_custom_iso: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
- name: Run OS installation on selected servers | ||
hosts: hostbmcs | ||
gather_facts: false | ||
vars: | ||
ansible_python_interpreter: "/root/.local/share/pipx/venvs/omsdk/bin/python" | ||
idrac_osd_command_allowable_values: | ||
- "BootToNetworkISO" | ||
- "GetAttachStatus" | ||
- "DetachISOImage" | ||
idrac_osd_command_default: "GetAttachStatus" | ||
get_attach_status_code: | ||
drivers_attach_status: | ||
"0": "NotAttached" | ||
"1": "Attached" | ||
iso_attach_status: | ||
"0": "NotAttached" | ||
"1": "Attached" | ||
idrac_https_port: 443 | ||
expose_duration: 1080 | ||
command: "{{ idrac_osd_command_default }}" | ||
validate_certs: false | ||
force_basic_auth: true | ||
idrac_user: "root" | ||
ansible_password: "{{ ansible_password }}" | ||
ip_address: "172.22.0.1" | ||
ubuntu_iso: ubuntu-22.04-autoinstall.iso | ||
|
||
tasks: | ||
- name: Fail if no target servers are provided | ||
ansible.builtin.fail: | ||
msg: "No target servers specified." | ||
when: target_servers | length == 0 | ||
|
||
- name: Skip non-target servers | ||
ansible.builtin.debug: | ||
msg: "Skipping {{ inventory_hostname }} as it is not in target servers." | ||
when: inventory_hostname not in target_servers | ||
|
||
- name: Include Dell OS installation tasks | ||
ansible.builtin.include_tasks: dell_os_install.yml | ||
when: inventory_hostname in ['dh1bmc', 'dh4bmc'] and inventory_hostname in target_servers |