Skip to content
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

enhance: Add support for SLES 15 (SP3) machine image #227

Merged
merged 8 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following builds are available:
* CentOS Stream 9
* CentOS Stream 8
* CentOS Linux 7
* SUSE Linux Enterprise 15

### Microsoft Windows - _Core and Desktop Experience_

Expand Down Expand Up @@ -367,6 +368,7 @@ The directory structure of the repository.
│ ├── common.pkvars.hcl.example
│ ├── proxy.pkvars.hcl.example
│ ├── rhsm.pkvars.hcl.example
| |── scc.pkvars.hcl.example
│ ├── vsphere.pkvars.hcl.example
│ ├── linux
│ │ └── <distribution>
Expand Down Expand Up @@ -438,6 +440,8 @@ The files are distributed in the following directories.
* [Download][download-linux-centos-stream-8] the latest release of the **FULL** `.iso` image. (_e.g.,_ `CentOS-Stream-8-x86_64-latest-dvd1.iso`)
* CentOS Linux 7
* [Download][download-linux-centos-server-7] the latest release of the **FULL** `.iso` image. (_e.g.,_ `CentOS-7-x86_64-DVD.iso`)
* SUSE Linux Enterprise 15
* [Download][download-suse-linux-enterprise-15] the latest release of the **FULL** `.iso` image. (_e.g.,_ `SLE-15-SP3-Full-x86_64-GM-Media1.iso`)

Microsoft Windows:

Expand Down Expand Up @@ -856,6 +860,7 @@ Need help customizing the configuration files?
```

* **Red Hat Enterprise Linux** (_as well as CentOS Linux/Stream, AlmaLinux OS, and Rocky Linux_) - Use the [Red Hat Kickstart Generator][redhat-kickstart].
* **SUSE Linux Enterprise Server** - Use the [SUSE Configuration Management System][suse-autoyast].
* **Microsoft Windows** - Use the Microsoft Windows [Answer File Generator][microsoft-windows-afg] if you need to customize the provided examples further.

## Build
Expand Down Expand Up @@ -953,6 +958,7 @@ Happy building!!!
[download-linux-redhat-server-9]: https://access.redhat.com/downloads/content/479/ver=/rhel---9/9.0/x86_64/product-software
[download-linux-rocky-server-9]: https://download.rockylinux.org/pub/rocky/9/isos/x86_64/
[download-linux-rocky-server-8]: https://download.rockylinux.org/pub/rocky/8/isos/x86_64/
[download-suse-linux-enterprise-15]: https://www.suse.com/download/sles/#
[download-linux-ubuntu-server-18-04-lts]: http://cdimage.ubuntu.com/ubuntu/releases/18.04.5/release/
[download-linux-ubuntu-server-20-04-lts]: https://releases.ubuntu.com/20.04/
[download-linux-ubuntu-server-22-04-lts]: https://releases.ubuntu.com/22.04/
Expand All @@ -971,6 +977,7 @@ Happy building!!!
[packer-variables]: https://www.packer.io/docs/templates/hcl_templates/variables
[photon-kickstart]: https://vmware.github.io/photon/docs/user-guide/kickstart-through-http/packer-template/
[redhat-kickstart]: https://access.redhat.com/labs/kickstartconfig/
[suse-autoyast]: https://documentation.suse.com/sles/15-SP3/single-html/SLES-autoyast/index.html#CreateProfile-CMS
[ssh-keygen]: https://www.ssh.com/ssh/keygen/
[terraform-install]: https://www.terraform.io/docs/cli/install/apt.html
[vmware-pvscsi]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.hostclient.doc/GUID-7A595885-3EA5-4F18-A6E7-5952BFC341CC.html
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/base/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
- name: "Prepare {{ ansible_facts['os_family'] }} guest operating system."
include_tasks: "{{ ansible_facts['lsb']['codename'] | lower }}.yml"
when: "ansible_facts['os_family'] == 'VMware Photon OS'"
- name: "Prepare {{ ansible_facts['distribution'] }} guest operating system."
include_tasks: sles.yml
when: "ansible_facts['distribution'] == 'SLES'"
13 changes: 13 additions & 0 deletions ansible/roles/base/tasks/sles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

---
- name: "Installing additional packages."
zypper:
name:
- bash-completion
- curl
- wget
- git-core
- net-tools
- unzip
- ca-certificates
state: latest
3 changes: 3 additions & 0 deletions ansible/roles/clean/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
- name: "Prepare {{ ansible_facts['os_family'] }} guest operating system."
include_tasks: "{{ ansible_facts['lsb']['codename'] | lower }}.yml"
when: "ansible_facts['os_family'] == 'VMware Photon OS'"
- name: "Prepare {{ ansible_facts['distribution'] }} guest operating system."
include_tasks: sles.yml
when: "ansible_facts['distribution'] == 'SLES'"
58 changes: 58 additions & 0 deletions ansible/roles/clean/tasks/sles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
- name: "Cleaning all audit logs."
shell: |
if [ -f /var/log/audit/audit.log ]; then
cat /dev/null > /var/log/audit/audit.log
fi
if [ -f /var/log/wtmp ]; then
cat /dev/null > /var/log/wtmp
fi
if [ -f /var/log/lastlog ]; then
cat /dev/null > /var/log/lastlog
fi
args:
warn: false
- name: "Cleaning persistent udev rules."
shell: |
if [ -f /etc/udev/rules.d/70-persistent-net.rules ]; then
rm /etc/udev/rules.d/70-persistent-net.rules
fi
args:
warn: false
- name: "Cleaning the /tmp directories"
shell: |
rm -rf /tmp/*
rm -rf /var/tmp/*
rm -rf /var/cache/zypp/*
rm -f /var/log/zypper.log
args:
warn: false
- name: "Cleaning the SCC files."
shell: |
rm -rf /etc/SUSEConnect
args:
warn: false
- name: "Cleaning the SSH host keys."
shell: |
rm -f /etc/ssh/ssh_host_*
args:
warn: false
- name: "Cleaning the machine-id."
when: "ansible_facts['distribution_major_version'] >= \"9\""
shell: |
truncate -s 0 /etc/machine-id
args:
warn: false
- name: "Cleaning the shell history."
shell: |
unset HISTFILE
history -cw
echo > ~/.bash_history
rm -fr /root/.bash_history
args:
warn: false
- name: "Running a sync."
shell: |
sync && sync
args:
warn: false
4 changes: 3 additions & 1 deletion ansible/roles/configure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
- name: "Prepare {{ ansible_facts['os_family'] }} guest operating system."
include_tasks: "{{ ansible_facts['lsb']['codename'] | lower }}.yml"
when: "ansible_facts['os_family'] == 'VMware Photon OS'"

- name: "Prepare {{ ansible_facts['distribution'] }} guest operating system."
include_tasks: sles.yml
when: "ansible_facts['distribution'] == 'SLES'"
24 changes: 24 additions & 0 deletions ansible/roles/configure/tasks/sles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: "Configure SSH for Public Key Authentication."
shell: |
sudo sed -i 's/.*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
sudo sed -i 's/.*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
args:
warn: false
- name: "Setting hostname to localhost."
shell: |
cat /dev/null > /etc/hostname
hostnamectl set-hostname localhost
args:
warn: false
- name: "Restarting the SSH daemon."
shell: |
sudo systemctl restart sshd
args:
warn: false
- name: "Unregistering from SUSE Customer Center."
shell: |
sudo SUSEConnect -d
sudo SUSEConnect --cleanup
args:
warn: false
3 changes: 3 additions & 0 deletions ansible/roles/users/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
- name: "Configure users on {{ ansible_facts['os_family'] }} guest operating system."
include_tasks: linux.yml
when: "ansible_facts['os_family'] == 'VMware Photon OS'"
- name: "Configure users on {{ ansible_facts['distribution'] }} guest operating system."
include_tasks: linux.yml
when: "ansible_facts['distribution'] == 'SLES'"
66 changes: 50 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,40 @@ menu_option_14() {
echo "Done."
}


menu_option_15() {
INPUT_PATH="$SCRIPT_PATH"/builds/linux/sles/15/
echo -e "\nCONFIRM: Build a SUSE Linux Enterprise Server 15 Template for VMware vSphere?"
echo -e "\nContinue? (y/n)"
read -r REPLY
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi

### Build a SUSE Linux Enterprise Server 15 Template for VMware vSphere. ###
echo "Building a SUSE Linux Enterprise Server 15 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...."
packer build -force \
-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/scc.pkrvars.hcl" \
"$INPUT_PATH"

### All done. ###
echo "Done."
}


menu_option_16() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/
echo -e "\nCONFIRM: Build all Windows Server 2022 Templates for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -486,7 +518,7 @@ menu_option_15() {
echo "Done."
}

menu_option_16() {
menu_option_17() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/
echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Standard Templates for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -516,7 +548,7 @@ menu_option_16() {
echo "Done."
}

menu_option_17() {
menu_option_18() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/
echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -546,7 +578,7 @@ menu_option_17() {
echo "Done."
}

menu_option_18() {
menu_option_19() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/
echo -e "\nCONFIRM: Build all Windows Server 2019 Templates for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -575,7 +607,7 @@ menu_option_18() {
echo "Done."
}

menu_option_19() {
menu_option_20() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/
echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Standard Templates for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -605,7 +637,7 @@ menu_option_19() {
echo "Done."
}

menu_option_20() {
menu_option_21() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/
echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -635,7 +667,7 @@ menu_option_20() {
echo "Done."
}

menu_option_21() {
menu_option_22() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/
echo -e "\nCONFIRM: Build a Windows 11 Template for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -664,7 +696,7 @@ menu_option_21() {
echo "Done."
}

menu_option_22() {
menu_option_23() {
INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/10/
echo -e "\nCONFIRM: Build a Windows 10 Template for VMware vSphere?"
echo -e "\nContinue? (y/n)"
Expand Down Expand Up @@ -740,17 +772,18 @@ until [ "$selection" = "0" ]; do
echo " 12 - CentOS Stream 9"
echo " 13 - CentOS Stream 8"
echo " 14 - CentOS Linux 7"
echo " 15 - SUSE Linux Enterprise Server 15"
echo ""
echo " Microsoft Windows:"
echo ""
echo " 15 - Windows Server 2022 - All"
echo " 16 - Windows Server 2022 - Standard Only"
echo " 17 - Windows Server 2022 - Datacenter Only"
echo " 18 - Windows Server 2019 - All"
echo " 19 - Windows Server 2019 - Standard Only"
echo " 20 - Windows Server 2019 - Datacenter Only"
echo " 21 - Windows 11"
echo " 22 - Windows 10"
echo " 16 - Windows Server 2022 - All"
echo " 17 - Windows Server 2022 - Standard Only"
echo " 18 - Windows Server 2022 - Datacenter Only"
echo " 19 - Windows Server 2019 - All"
echo " 20 - Windows Server 2019 - Standard Only"
echo " 21 - Windows Server 2019 - Datacenter Only"
echo " 22 - Windows 11"
echo " 23 - Windows 10"
echo ""
echo " Other:"
echo ""
Expand Down Expand Up @@ -782,6 +815,7 @@ until [ "$selection" = "0" ]; do
20 ) clear ; menu_option_20 ; press_enter ;;
21 ) clear ; menu_option_21 ; press_enter ;;
22 ) clear ; menu_option_22 ; press_enter ;;
23 ) clear ; menu_option_23 ; press_enter ;;
I ) clear ; info ; press_enter ;;
Q ) clear ; exit ;;
* ) clear ; incorrect_selection ; press_enter ;;
Expand Down
5 changes: 5 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ menu:
- entry: "CentOS Linux 7"
build:
path: "builds/linux/centos/7/"
- entry: "SUSE Linux Enterprise Server 15"
build:
path: "builds/linux/sles/15/"
var_files:
- "scc.pkrvars.hcl"
- entry: "Microsoft Windows"
build:
var_files:
Expand Down
Loading