-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(idrac_os_deployment): added support for ubuntu installation #784
base: collections
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,17 @@ Role to deploy operating system and version on the servers.</br> | |
|
||
The role perform the following operations: | ||
1. Downloads or copies the source ISO as a local copy in the ansible controller machine tmp folder. | ||
1. Create a kickstart file using jinja template based on the os name and version . | ||
1. Extract the ISO using the `xorriso` library. | ||
1. Enable the extracted ISO to use kickstart file by modifying the boot configurations for bios and uefi. | ||
1. Compile the iso to generate a custom iso by embedding the kickstart file in an iso using the `mkisofs`, `isohybrid` and `implantisomd5` commands. | ||
1. Copy the custom ISO generated to destination share location as specfied to the role input. Based on the input a following method is used to copy the destination to a shared repository. | ||
2. Create a kickstart file using jinja template based on the os name and version . | ||
3. Extract the ISO using the `xorriso` library, in case of ubuntu we use `7z`. | ||
4. Enable the extracted ISO to use kickstart file by modifying the boot configurations for bios and uefi. | ||
5. Compile the iso to generate a custom iso by embedding the kickstart file in an iso using the `mkisofs`, `isohybrid` and `implantisomd5` commands. | ||
6. Copy the custom ISO generated to destination share location as specfied to the role input. Based on the input a following method is used to copy the destination to a shared repository. | ||
- CIFS/NFS uses the local file mount to copy the ISO to a location. | ||
- HTTP/HTTPS uses the SSH to copy/transfer the ISO to a location where the web server content is served. | ||
1. Using an iDRAC `idrac_virtual_media` module mount the custom ISO as virtual media (virtual CD) in an iDRAC. | ||
1. Using an iDRAC `idrac_boot` module set the boot target to CD and enable a reboot to CD once. | ||
1. Track for the OS deployment for the specified amount of user input time. | ||
1. Eject the virtual media after the specfied time is finished. | ||
7. Using an iDRAC `idrac_virtual_media` module mount the custom ISO as virtual media (virtual CD) in an iDRAC. | ||
8. Using an iDRAC `idrac_boot` module set the boot target to CD and enable a reboot to CD once. | ||
9. Track for the OS deployment for the specified amount of user input time. | ||
10. Eject the virtual media after the specfied time is finished. | ||
|
||
Requirements | ||
------------ | ||
|
@@ -32,6 +32,7 @@ xorriso | |
syslinux | ||
isomd5sum | ||
wget | ||
7z | ||
``` | ||
### Production | ||
Requirements to use the role. | ||
|
@@ -42,6 +43,7 @@ xorriso | |
syslinux | ||
isomd5sum | ||
wget | ||
7z | ||
``` | ||
|
||
### Ansible collections | ||
|
@@ -423,7 +425,7 @@ Role Variables | |
</tr> | ||
<tr> | ||
<td>idrac_os_deployment_supported_os</td> | ||
<td>{ RHEL: ["8", "9"], ESXI: ["8"] }</td> | ||
<td>{ RHEL: ["8", "9"], ESXI: ["8"], UBUNTU: ["jammy"] }</td> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i wonder naming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since in the versioning format, he has not considered patch, both seems to be ok. Still if we have chanceof having different kickstsrt template based on versions, i would recommend to go with |
||
<td>Hold the map data of supported os name and version</td> | ||
</tr> | ||
</tbody> | ||
|
@@ -456,7 +458,7 @@ Example Playbook | |
destination: | ||
protocol: https | ||
hostname: 198.192.0.1 | ||
mountpath: /user/www/myrepo | ||
mountpoint: /user/www/myrepo | ||
os_type: linux | ||
iso_path: /to/iso | ||
``` | ||
|
@@ -480,7 +482,7 @@ Example Playbook | |
destination: | ||
protocol: https | ||
hostname: 198.192.0.1 | ||
mountpath: /user/www/myrepo | ||
mountpoint: /user/www/myrepo | ||
os_type: linux | ||
iso_path: /to/iso | ||
``` | ||
|
@@ -501,6 +503,30 @@ Example Playbook | |
iso_name: custom-rhel.iso | ||
is_custom_iso: true | ||
``` | ||
``` | ||
- name: Generate custom iso using a kickstart file and install UBUNTU OS | ||
ansible.builtin.import_role: | ||
name: idrac_os_deployment | ||
vars: | ||
hostname: 192.168.0.1 | ||
username: root | ||
password: password | ||
ca_path: path/to/ca | ||
os_name: UBUNTU | ||
os_version: jammy | ||
source: | ||
protocol: https | ||
hostname: 198.192.0.1 | ||
ks_path: /to/iso/ks_ubuntu.cfg | ||
path: /to/iso | ||
iso_name: ubuntu.iso | ||
destination: | ||
protocol: https | ||
hostname: 198.192.0.1 | ||
mountpoint: /user/www/myrepo | ||
os_type: linux | ||
iso_path: /to/iso | ||
``` | ||
Author Information | ||
------------------ | ||
Dell Technologies <br> | ||
|
Sakethanne marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ubuntu_update_installer: true | ||
ubuntu_preserve_sources_list: false | ||
ubuntu_primary_mirror: "http://archive.ubuntu.com/ubuntu" | ||
ubuntu_primary_arches: [i386, amd64] | ||
ubuntu_secondary_mirror: "http://ports.ubuntu.com/ubuntu-ports" | ||
ubuntu_secondary_arches: [s390x, arm64, armhf, powerpc, ppc64el, riscv64] | ||
ubuntu_fallback_strategy: "abort" | ||
ubuntu_geoip: true | ||
ubuntu_git_ppa: "ppa:git-core/ppa" | ||
ubuntu_hostname: "ubuntu" | ||
# Initial user password "ubuntu" (hashed using SHA-512) | ||
ubuntu_user_password: "$6$xlpCfETR.9nMepDn$0GDk0yuTOOMXrxFQacjQdbTNwCys.wMlo.EDzfKJGvLhy61R8IxaSCNveo247McGthyg7vBUgDlmTS3wF.64k1" | ||
ubuntu_realname: "ubuntu" | ||
ubuntu_username: "ubuntu" | ||
ubuntu_keyboard: "us" | ||
ubuntu_keyboard_toggle: "" | ||
ubuntu_keyboard_variant: "" | ||
ubuntu_locale: "en_US" | ||
ubuntu_allow_pw: true | ||
ubuntu_authorized_keys: [] # Add public keys here as a YAML list | ||
ubuntu_install_ssh: true | ||
ubuntu_storage_layout: "lvm" | ||
ubuntu_match_size: "largest" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,14 +37,14 @@ argument_specs: | |||||
type: str | ||||||
description: | ||||||
- The operating system name to match the jinja template of the kickstart file. | ||||||
- Supported os name is versions for RHEL and ESXI. | ||||||
- Supported os name is versions for RHEL and ESXI and UBUNTU. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- Jinja template file should exists in the format <os_name_upper>_<os_version_major>.j2 | ||||||
- This is required when I(is_custom_iso) is C(false). | ||||||
os_version: | ||||||
type: str | ||||||
description: | ||||||
- The operating system version to match the jinja template of the kickstart file. | ||||||
- Supported versions for RHEL are 9.x and 8.x and for ESXi is 8.x. | ||||||
- Supported versions for RHEL are 9.x and 8.x and for ESXi is 8.x and for UBUNTU is jammy. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- Jinja template file should exists in the format <os_name_upper>_<os_version_major>.j2 | ||||||
- This is required when I(is_custom_iso) is C(false) | ||||||
source: | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
- name: Create 'server' folder inside the extract directory | ||
delegate_to: "{{ idrac_os_deployment_delegate }}" | ||
ansible.builtin.file: | ||
path: "{{ idrac_os_deployment_iso_extract_dir }}/server" | ||
state: directory | ||
mode: "{{ idrac_os_deployment_copy_mode }}" | ||
|
||
- name: Create an empty 'meta-data' file inside the server folder | ||
delegate_to: "{{ idrac_os_deployment_delegate }}" | ||
ansible.builtin.copy: | ||
content: "" | ||
dest: "{{ idrac_os_deployment_iso_extract_dir }}/server/meta-data" | ||
mode: "{{ idrac_os_deployment_copy_mode }}" | ||
|
||
- name: Copy KS user-data to extracted | ||
delegate_to: "{{ idrac_os_deployment_delegate }}" | ||
ansible.builtin.copy: | ||
src: "{{ idrac_os_deployment_kickstart_file }}" | ||
dest: "{{ idrac_os_deployment_iso_extract_dir }}/server/{{ idrac_os_deployment_ubuntu_ks_filename }}" | ||
mode: "{{ idrac_os_deployment_copy_mode }}" | ||
|
||
- name: Append autoinstall menu entry to grub.cfg | ||
delegate_to: "{{ idrac_os_deployment_delegate }}" | ||
ansible.builtin.lineinfile: | ||
path: "{{ idrac_os_deployment_iso_extract_dir }}/boot/grub/grub.cfg" | ||
insertafter: "^set menu_color_highlight=black/light-gray" | ||
line: | | ||
menuentry 'Install Ubuntu with Kickstart' { | ||
set gfxpayload=keep | ||
linux /casper/vmlinuz quiet autoinstall ds=nocloud\;s={{ idrac_os_deployment_ubuntu_ks_location }}server/ --- | ||
initrd /casper/initrd | ||
} | ||
|
||
- name: Get iso LABEL | ||
delegate_to: "{{ idrac_os_deployment_delegate }}" | ||
ansible.builtin.command: "blkid -s LABEL -o value {{ idrac_os_deployment_iso_file }}" | ||
register: idrac_os_deployment_blkid_output | ||
changed_when: idrac_os_deployment_blkid_output.rc != 0 | ||
|
||
- name: Set iso LABEL | ||
ansible.builtin.set_fact: | ||
idrac_os_deployment_iso_label: "{{ idrac_os_deployment_blkid_output.stdout | trim }}" | ||
|
||
- name: Compile custom ISO | ||
delegate_to: "{{ idrac_os_deployment_delegate }}" | ||
ansible.builtin.command: | ||
chdir: "{{ idrac_os_deployment_iso_extract_dir }}" | ||
cmd: "{{ idrac_os_deployment_ubuntu_mkiso_cmd | format(idrac_os_deployment_custom_iso_file, idrac_os_deployment_iso_label) }}" | ||
register: idrac_os_deployment_mkisofs_output | ||
changed_when: idrac_os_deployment_mkisofs_output.rc == 0 | ||
failed_when: idrac_os_deployment_mkisofs_output.rc != 0 |
sachin-apa marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#cloud-config | ||
# vim: ft=yaml: | ||
autoinstall: | ||
version: 1 | ||
early-commands: | ||
- ["cat", "/autoinstall.yaml"] | ||
refresh-installer: | ||
update: {{ ubuntu_update_installer }} | ||
apt: | ||
preserve_sources_list: {{ ubuntu_preserve_sources_list }} | ||
mirror-selection: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have to set this at all? maybe just remove this section and see if it works... ? |
||
primary: | ||
- country-mirror | ||
- uri: "{{ ubuntu_primary_mirror }}" | ||
arches: {{ ubuntu_primary_arches }} | ||
- uri: "{{ ubuntu_secondary_mirror }}" | ||
arches: {{ ubuntu_secondary_arches }} | ||
fallback: {{ ubuntu_fallback_strategy }} | ||
geoip: {{ ubuntu_geoip }} | ||
sources: | ||
git-ppa: | ||
source: {{ ubuntu_git_ppa }} | ||
identity: | ||
hostname: "{{ ubuntu_hostname }}" | ||
password: "{{ ubuntu_user_password }}" | ||
realname: "{{ ubuntu_realname }}" | ||
username: "{{ ubuntu_username }}" | ||
keyboard: | ||
layout: "{{ ubuntu_keyboard }}" | ||
toggle: "{{ ubuntu_keyboard_toggle }}" | ||
variant: "{{ ubuntu_keyboard_variant }}" | ||
locale: "{{ ubuntu_locale }}" | ||
ssh: | ||
allow-pw: {{ ubuntu_allow_pw }} | ||
authorized-keys: {{ ubuntu_authorized_keys }} | ||
install-server: {{ ubuntu_install_ssh }} | ||
storage: | ||
layout: | ||
name: "{{ ubuntu_storage_layout }}" | ||
match: | ||
size: "{{ ubuntu_match_size }}" | ||
late-commands: | ||
- 'echo ''APT::Install-Recommends "false";'' >/target/etc/apt/apt.conf.d/02InstallRecommends' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it possible to use xorriso library for ubuntu too, as again we shall have new dependency on 7z, can you check and confirm once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sakethanne I see blog that is using xorriso with ubuntu
https://www.reddit.com/r/Ubuntu/comments/1cxotah/going_mad_cant_get_options_for_xorriso_to_work/
please try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to acheive the same functionality with the xorisso command to unpack the ubuntu 22.04 version iso as compared to the 7z command.
The unpacked files were completely different between xorisso and 7z.