Skip to content

Commit

Permalink
feat: add fedora server (#892)
Browse files Browse the repository at this point in the history
Adds Fedora Server Linux (40, latest) distribution.

Ref: #885

Signed-off-by: Ryan Johnson <[email protected]>
  • Loading branch information
tenthirtyam committed Apr 23, 2024
1 parent 0a09670 commit a89903f
Show file tree
Hide file tree
Showing 23 changed files with 1,193 additions and 94 deletions.
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ CentOS-Linux-7:

##############################################################################

Fedora-Server-40:
extends: .packer-build
variables:
INPUT_PATH: "$SCRIPT_PATH/builds/linux/fedora/40/"
BUILD_VARS: "linux-fedora-40.pkrvars.hcl"
EXTRA_VAR_FILES: "-var-file=$CONFIG_PATH/network.pkrvars.hcl -var-file=$CONFIG_PATH/linux-storage.pkrvars.hcl"

##############################################################################

SUSE-Linux-Enterprise-Server-15:
extends: .packer-build
variables:
Expand Down
1 change: 1 addition & 0 deletions .trunk/tools
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"[md]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"editor.formatOnType": true,
"editor.trimAutoWhitespace": true,
"editor.wordWrap": "bounded",
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
**Enhancement**:

- Adds Ubuntu Server 24.04 LTS to the project.
[#891](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/891)
- Adds a script (`./download.sh`) and a configuration (`project.json`) to assist in the download of
the guest operating systems.
[#874](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/874),
[#877](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/877)
- Adds Ubuntu Server 24.04 LTS to the project.
[#891](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/891)
- Adds Fedora Server 40 Linux distribution to the project.
[#xxx](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/xxx)
- Adds option to enable cloud-init on Debian 12.
[#883](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/883)
- Adds option to enable cloud-init on Red Hat Enterprise Linux 9.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This project supports the following guest operating systems:
| CentOS Stream | 9 |
| CentOS Stream | 8 |
| CentOS Linux | 7 |
| Fedora Server | 39 |
| SUSE Linux Enterprise Server | 15 |

## Microsoft Windows
Expand Down
27 changes: 15 additions & 12 deletions ansible/roles/base/tasks/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,35 +76,38 @@

- block:
- name: "Updating the operating system."
yum:
dnf:
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."
yum:
dnf:
name: "{{ additional_packages[ansible_os_family] }}"
state: latest # noqa package-latest
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int < 8
when:
- ansible_distribution == 'Fedora' and ansible_distribution_major_version | int >= 40
- ansible_os_family == 'RedHat' and ansible_distribution_major_version | int >= 8

- block:
- name: "Updating the operating system."
dnf:
yum:
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:
yum:
name: "{{ additional_packages[ansible_os_family] }}"
state: latest # noqa package-latest
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int >= 8
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int < 8


# SUSE Linux Enterprise Server

Expand Down
4 changes: 3 additions & 1 deletion ansible/roles/configure/tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
when: ansible_distribution == 'RedHat'

# Tasks for configuring SSH for public key authentication.
- name: "Configuring SSH for Public Key Authentication."
- name: "Configuring SSH for Public Key Authentication without cloud-init."
block:
- lineinfile:
path: /etc/ssh/sshd_config
Expand All @@ -17,6 +17,8 @@
regexp: '^PubkeyAuthentication'
line: 'PubkeyAuthentication yes'
when: enable_cloudinit == 'false'

- name: "Configuring SSH for Public Key Authentication without cloud-init."
block:
- lineinfile:
path: /etc/ssh/sshd_config
Expand Down
101 changes: 70 additions & 31 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,43 @@ menu_option_19() {
}

menu_option_20() {
INPUT_PATH="$SCRIPT_PATH"/builds/linux/fedora/40/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"

echo -e "\nCONFIRM: Build a Fedora Server 40 Template for VMware vSphere?"
echo -e "\nContinue? (y/n)"
read -r REPLY
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi

### Build a Fedora Server 40 Template for VMware vSphere. ###
echo "Building a Fedora Server 40 Template for VMware vSphere..."

### Initialize HashiCorp Packer and required plugins. ###
echo "Initializing HashiCorp Packer and required plugins..."
packer init "$INPUT_PATH"

### Start the Build. ###
echo "Starting the build...."
echo "packer build -force -on-error=ask $debug_option"
packer build -force -on-error=ask $debug_option \
-var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
-var-file="$CONFIG_PATH/proxy.pkrvars.hcl" \
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
-var-file="$CONFIG_PATH/$BUILD_VARS" \
"$INPUT_PATH"

### Build Complete. ###
echo "Build Complete."
}

menu_option_21() {
INPUT_PATH="$SCRIPT_PATH"/builds/linux/sles/15/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -798,7 +835,7 @@ menu_option_20() {
}


menu_option_21() {
menu_option_22() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2025/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -833,7 +870,7 @@ menu_option_21() {
echo "Build Complete."
}

menu_option_22() {
menu_option_23() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2025/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -869,7 +906,7 @@ menu_option_22() {
echo "Build Complete."
}

menu_option_23() {
menu_option_24() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2025/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -905,7 +942,7 @@ menu_option_23() {
echo "Build Complete."
}

menu_option_24() {
menu_option_25() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -940,7 +977,7 @@ menu_option_24() {
echo "Build Complete."
}

menu_option_25() {
menu_option_26() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -976,7 +1013,7 @@ menu_option_25() {
echo "Build Complete."
}

menu_option_26() {
menu_option_27() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1012,7 +1049,7 @@ menu_option_26() {
echo "Build Complete."
}

menu_option_27() {
menu_option_28() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1047,7 +1084,7 @@ menu_option_27() {
echo "Build Complete."
}

menu_option_28() {
menu_option_29() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1083,7 +1120,7 @@ menu_option_28() {
echo "Build Complete."
}

menu_option_29() {
menu_option_30() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1119,7 +1156,7 @@ menu_option_29() {
echo "Build Complete."
}

menu_option_30() {
menu_option_31() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1154,7 +1191,7 @@ menu_option_30() {
echo "Build Complete."
}

menu_option_31() {
menu_option_32() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1190,7 +1227,7 @@ menu_option_31() {
echo "Build Complete."
}

menu_option_32() {
menu_option_33() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1226,7 +1263,7 @@ menu_option_32() {
echo "Build Complete."
}

menu_option_33() {
menu_option_34() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/10/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1261,7 +1298,7 @@ menu_option_33() {
echo "Build Complete."
}

menu_option_34() {
menu_option_35() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/10/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1297,7 +1334,7 @@ menu_option_34() {
echo "Build Complete."
}

menu_option_35() {
menu_option_36() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/10/
BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"}
BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl"
Expand Down Expand Up @@ -1378,25 +1415,26 @@ until [ "$selection" = "0" ]; do
echo " 17 - CentOS Stream 9"
echo " 18 - CentOS Stream 8"
echo " 19 - CentOS Linux 7"
echo " 20 - SUSE Linux Enterprise Server 15"
echo " 20 - Fedora Server 40"
echo " 21 - SUSE Linux Enterprise Server 15"
echo ""
echo " Microsoft Windows:"
echo ""
echo " 21 - Windows Server 2025 - All"
echo " 22 - Windows Server 2025 - Standard Only"
echo " 23 - Windows Server 2025 - Datacenter Only"
echo " 24 - Windows Server 2022 - All"
echo " 25 - Windows Server 2022 - Standard Only"
echo " 26 - Windows Server 2022 - Datacenter Only"
echo " 27 - Windows Server 2019 - All"
echo " 28 - Windows Server 2019 - Standard Only"
echo " 29 - Windows Server 2019 - Datacenter Only"
echo " 30 - Windows 11 - All"
echo " 31 - Windows 11 - Enterprise Only"
echo " 32 - Windows 11 - Professional Only"
echo " 33 - Windows 10 - All"
echo " 34 - Windows 10 - Enterprise Only"
echo " 35 - Windows 10 - Professional Only"
echo " 22 - Windows Server 2025 - All"
echo " 23 - Windows Server 2025 - Standard Only"
echo " 24 - Windows Server 2025 - Datacenter Only"
echo " 25 - Windows Server 2022 - All"
echo " 26 - Windows Server 2022 - Standard Only"
echo " 27 - Windows Server 2022 - Datacenter Only"
echo " 28 - Windows Server 2019 - All"
echo " 29 - Windows Server 2019 - Standard Only"
echo " 30 - Windows Server 2019 - Datacenter Only"
echo " 31 - Windows 11 - All"
echo " 32 - Windows 11 - Enterprise Only"
echo " 33 - Windows 11 - Professional Only"
echo " 34 - Windows 10 - All"
echo " 35 - Windows 10 - Enterprise Only"
echo " 36 - Windows 10 - Professional Only"
echo ""
echo " Other:"
echo ""
Expand Down Expand Up @@ -1441,6 +1479,7 @@ until [ "$selection" = "0" ]; do
33 ) clear ; menu_option_33 ; press_enter ;;
34 ) clear ; menu_option_34 ; press_enter ;;
35 ) clear ; menu_option_35 ; press_enter ;;
36 ) clear ; menu_option_36 ; press_enter ;;
i|I ) clear ; info ; press_enter ;;
q|Q ) clear ; exit ;;
* ) clear ; incorrect_selection ; press_enter ;;
Expand Down
6 changes: 6 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ menu:
var_files:
- "network.pkrvars.hcl"
- "linux-storage.pkrvars.hcl"
- entry: "Fedora Server 40"
build:
path: "builds/linux/fedora/40/"
var_files:
- "network.pkrvars.hcl"
- "linux-storage.pkrvars.hcl"
- entry: "SUSE Linux Enterprise Server 15"
build:
path: "builds/linux/sles/15/"
Expand Down
Loading

0 comments on commit a89903f

Please sign in to comment.