Skip to content

Commit

Permalink
feat: added cloud-init to almalinux 8 and 9 (#898)
Browse files Browse the repository at this point in the history
- Added the cloud-init option for Almalinux OS 9.
- Added the cloud-init option for Almalinux OS 8.

Signed-off-by: Jared Burns <jared.burns@broadcom.com>
  • Loading branch information
burnsjared0415 committed Apr 23, 2024
1 parent 8a1f41e commit a08c7d8
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
[#897](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/897)
- Adds option to enable cloud-init on CentOS Stream 9.
[#897](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/897)
- Adds option to enable cloud-init on AlmaLinux OS 8.
[#898](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/898)
- Adds option to enable cloud-init on AlmaLinux OS 9.
[#898](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/898)

**Chore**:

Expand Down
13 changes: 11 additions & 2 deletions ansible/roles/base/tasks/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@
when: ansible_distribution == 'RedHat'

- name: "Upgrade almalinux-release package."
ansible.builtin.command:
cmd: dnf upgrade -y almalinux-release
dnf:
name: almalinux-release
state: latest
become: true
when: ansible_distribution == 'AlmaLinux'

- name: "Installing Cloud-init."
dnf:
name: cloud-init
state: latest
when: ansible_distribution == 'AlmaLinux' and ansible_distribution_version | int >= 8 and enable_cloudinit == 'true'

- block:
- name: "Updating the operating system."
yum:
Expand All @@ -59,11 +66,13 @@
name: "*"
state: latest # noqa package-latest
update_cache: true

- name: "Installing Cloud-init."
dnf:
name: cloud-init
state: latest
when: enable_cloudinit == 'true'

- name: "Installing additional packages."
dnf:
name: "{{ additional_packages[ansible_os_family] }}"
Expand Down
2 changes: 2 additions & 0 deletions builds/linux/almalinux/8/linux-almalinux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ locals {
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
vm_guest_os_timezone = var.vm_guest_os_timezone
vm_guest_os_cloudinit = var.vm_guest_os_cloudinit
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
device = var.vm_network_device
ip = var.vm_ip_address
Expand Down Expand Up @@ -213,6 +214,7 @@ build {
"--extra-vars", "build_key='${var.build_key}'",
"--extra-vars", "ansible_username=${var.ansible_username}",
"--extra-vars", "ansible_key='${var.ansible_key}'",
"--extra-vars", "enable_cloudinit=${var.vm_guest_os_cloudinit}",
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ vm_guest_os_version = "8.9"

// Virtual Machine Guest Operating System Setting
vm_guest_os_type = "other4xLinux64Guest"
vm_guest_os_cloudinit = false

// Virtual Machine Hardware Settings
vm_firmware = "efi-secure"
Expand Down
11 changes: 11 additions & 0 deletions builds/linux/almalinux/8/variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ variable "vm_guest_os_type" {
description = "The guest operating system type, also know as guestid."
}

variable "vm_guest_os_cloudinit" {
type = bool
description = "Enable cloud-init for the guest operating system."
default = false
}

variable "vm_firmware" {
type = string
description = "The virtual machine firmware."
Expand Down Expand Up @@ -276,6 +282,11 @@ variable "common_iso_datastore" {
description = "The name of the target vSphere datastore for the guest operating system ISO."
}

variable "iso_datastore_path" {
type = string
description = "The path on the source vSphere datastore for the guest operating system ISO."
}

variable "iso_file" {
type = string
description = "The file name of the guest operating system ISO."
Expand Down
2 changes: 2 additions & 0 deletions builds/linux/almalinux/9/linux-almalinux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ locals {
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
vm_guest_os_timezone = var.vm_guest_os_timezone
vm_guest_os_cloudinit = var.vm_guest_os_cloudinit
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
device = var.vm_network_device
ip = var.vm_ip_address
Expand Down Expand Up @@ -212,6 +213,7 @@ build {
"--extra-vars", "build_key='${var.build_key}'",
"--extra-vars", "ansible_username=${var.ansible_username}",
"--extra-vars", "ansible_key='${var.ansible_key}'",
"--extra-vars", "enable_cloudinit=${var.vm_guest_os_cloudinit}",
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ vm_guest_os_version = "9.3"

// Virtual Machine Guest Operating System Setting
vm_guest_os_type = "other5xLinux64Guest"
vm_guest_os_cloudinit = false

// Virtual Machine Hardware Settings
vm_firmware = "efi-secure"
Expand Down
6 changes: 6 additions & 0 deletions builds/linux/almalinux/9/variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ variable "vm_guest_os_type" {
description = "The guest operating system type, also know as guestid."
}

variable "vm_guest_os_cloudinit" {
type = bool
description = "Enable cloud-init for the guest operating system."
default = false
}

variable "vm_firmware" {
type = string
description = "The virtual machine firmware."
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ This project supports the following guest operating systems:
| :fontawesome-brands-redhat: &nbsp;&nbsp; Red Hat Enterprise Linux @span | 9 | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| | 8 | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| | 7 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24: | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| :fontawesome-brands-linux: &nbsp;&nbsp; AlmaLinux OS @span | 9 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24: | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| | 8 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24: | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| :fontawesome-brands-linux: &nbsp;&nbsp; AlmaLinux OS @span | 9 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| | 8 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| :simple-rockylinux: &nbsp;&nbsp; Rocky Linux @span | 9 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| | 8 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24:{ .green } | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
| :simple-oracle: &nbsp;&nbsp; Oracle Linux @span | 9 | :octicons-check-circle-24:{ .green } | :octicons-x-circle-24: | :octicons-check-circle-24:{ .green } | :octicons-check-circle-24:{ .green } |
Expand Down

0 comments on commit a08c7d8

Please sign in to comment.