diff --git a/README.md b/README.md index d687ba835..394284a30 100644 --- a/README.md +++ b/README.md @@ -58,18 +58,22 @@ The following builds are available: **Operating Systems**: * Ubuntu Server 20.04 LTS * macOS Big Sur (Intel) -* Microsoft Windows Server 2019 > Operating systems and versions tested with the repository examples. **Additional Software Packages**: * [Git][download-git] command line tools. + - Ubuntu: `apt-get install git` + - macOS: `brew install git` +* [Ansible][ansible-docs] 2.9 or higher. + - Ubuntu: `apt-get install ansible` + - macOS: `brew install ansible` * A command-line .iso creator. Packer will use one of the following: - - **xorriso** (Ubuntu: `apt-get install xorriso`) - - **mkisofs** (Ubuntu: `apt-get install mkisofs`) - - **hdiutil** (macOS) - - **oscdimg** (Windows: requires Windows ADK) -* Coreutils (macOS `brew install coreutils`) + - **xorriso** on Ubuntu: `apt-get install xorriso` + - **mkisofs** on Ubuntu: `apt-get install mkisofs` + - **hdiutil** on macOS: native +* Coreutils + - macOS: `brew install coreutils` **Platform**: * VMware Cloud Foundation 4.2 or higher, or @@ -97,6 +101,24 @@ The directory structure of the repository. ├── LICENSE ├── NOTICE ├── README.md +├── ansible +│ ├── roles +│ │ └── +│ │ ├── defaults +│ │ │ └── main.yml +│ │ ├── files +│ │ │ └── root-ca.p7b.example +│ │ ├── handlers +│ │ │ └── main.yml +│ │ ├── meta +│ │ │ └── main.yml +│ │ ├── tasks +│ │ │ └── main.yml +│ │ │ └── *.yml +│ │ └── vars +│ │ └── main.yml +│ ├── ansible.cfg +│ └── main.yml ├── builds │ ├── ansible.pkvars.hcl.example │ ├── build.pkvars.hcl.example @@ -105,19 +127,18 @@ The directory structure of the repository. │ ├── rhsm.pkvars.hcl.example │ ├── vsphere.pkvars.hcl.example │ ├── linux -│ │ └── distribution-version +│ │ └── │ │ ├── *.pkr.hcl │ │ ├── *.auto.pkrvars.hcl │ │ └── data │ │ └── ks.pkrtpl.hcl │ └── windows -│ └── version +│ └── │ ├── *.pkr.hcl │ ├── *.auto.pkrvars.hcl │ └── data │ └── autounattend.pkrtpl.hcl ├── certificates -│ ├── root-ca.crt.example │ └── root-ca.p7b.example ├── manifests └── scripts @@ -127,10 +148,13 @@ The directory structure of the repository. └── *.ps1 ``` The files are distributed in the following directories. -* **`builds`** - contains the build templates, variables, and configuration files. -* **`scripts`** - contains scripts that are used to initialize and prepare the machine image builds. -* **`certificates`** - contains the Trusted Root Authority certificates. -* **`manifests`** - manifests created after the completion of each build. +* **`ansible`** - contains the Ansible roles to initialize and prepare the machine image build. +* **`builds`** - contains the templates, variables, and configuration files for the machine image build. +* **`scripts`** - contains the scripts to initialize and prepare the machine image build. +* **`certificates`** - contains the Trusted Root Authority certificates for Windows build. +* **`manifests`** - manifests created after the completion of the machine image build. + +> **NOTE**: The project is transitioning to use Ansible instead of scripts, where possible. ### Step 2 - Download the Guest Operating Systems ISOs @@ -370,7 +394,7 @@ rhsm_username = "rainpole" rhsm_password = "" ``` -These variables are **only** used if you are performing a Red Hat Enterprise Linux Server build to register the image with Red Hat Subscription Manager and run a `sudo dnf update -y` within the shell provisioner. Before the build completes, the machine image is unregistered from Red Hat Subscription Manager. +These variables are **only** used if you are performing a Red Hat Enterprise Linux Server build and are used to register the image with Red Hat Subscription Manager during the build for system updates and package installation. Before the build completes, the machine image is unregistered from Red Hat Subscription Manager. #### **vSphere Variables** @@ -464,15 +488,15 @@ By default, each unattended file set the **Product Key** to use the [KMS client ### Step 5 - Configure Certificates -Save a copy of your Root Certificate Authority certificate to `/certificates` in `.crt` and `.p7b` formats. - -These files are copied to the guest operating systems with a Packer file provisioner; after which, the a shell provisioner adds the certificate to the Trusted Certificate Authority of the guest operating system. +Save a copy of your Root Certificate Authority certificate to the following in `.crt` and `.p7b` formats. +- `/ansible/roles/base/files` for Linux machine images. +- `/certificates` for Windows machine images. ->**NOTE**: If you do not wish to install the certificates on the guest operating systems, comment or remove the portion of the associated script in the `/scripts` directory and the file provisioner from the `prk.hcl` file for each build. If you need to add an intermediate certificate, add the certificate to `/certificates` and update the shell provisioner scripts in the `scripts` directory with your requirements. +These files are copied to the guest operating systems and added the certificate to the Trusted Certificate Authority of the guest operating system. Linux distributions uses the Ansible provisioner, but Windows still uses the shell provisioner at this time. ## Build -Start a pre-defined build by running the build script (`./build.sh`). The script presents a menu the which simply calls Packer and the respective build(s). +Start a build by running the build script (`./build.sh`). The script presents a menu the which simply calls Packer and the respective build(s). Example: Menu for `./build.sh`. ``` @@ -541,7 +565,7 @@ rainpole@macos windows-server-2022> packer build -force \ ``` Happy building!!! - -- Your friends at rainpole.io. + -- Your friends at github.com/rainpole. ## Troubleshoot @@ -558,6 +582,7 @@ Happy building!!! [//]: Links +[ansible-docs]: https://docs.ansible.com [cloud-init]: https://cloudinit.readthedocs.io/en/latest/ [credits-maher-alasfar-twitter]: https://twitter.com/vmwarelab [credits-maher-alasfar-github]: https://github.com/vmwarelab/cloud-init-scripts diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 000000000..8f4642928 --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +command_warnings = false +display_skipped_hosts = false +ansible_python_interpreter = /usr/bin/python3 \ No newline at end of file diff --git a/ansible/main.yml b/ansible/main.yml new file mode 100644 index 000000000..454263cc7 --- /dev/null +++ b/ansible/main.yml @@ -0,0 +1,14 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +- hosts: all + debugger: never + gather_facts: yes + become: yes + become_method: sudo + roles: + - base \ No newline at end of file diff --git a/ansible/roles/base/defaults/main.yml b/ansible/roles/base/defaults/main.yml new file mode 100644 index 000000000..7c5a0ebb0 --- /dev/null +++ b/ansible/roles/base/defaults/main.yml @@ -0,0 +1,8 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Defaults for base. \ No newline at end of file diff --git a/certificates/root-ca.crt.example b/ansible/roles/base/files/root-ca.crt.example similarity index 100% rename from certificates/root-ca.crt.example rename to ansible/roles/base/files/root-ca.crt.example diff --git a/ansible/roles/base/handlers/main.yml b/ansible/roles/base/handlers/main.yml new file mode 100644 index 000000000..c4e18a0f2 --- /dev/null +++ b/ansible/roles/base/handlers/main.yml @@ -0,0 +1,15 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +- name: Ubuntu - Updating the certificate authority trust. + shell: update-ca-certificates + +- name: RedHat - Updating the certificate authority trust. + shell: update-ca-trust extract + +- name: VMware Photon OS - Updating the certificate authority trust. + shell: rehash_ca_certificates.sh \ No newline at end of file diff --git a/ansible/roles/base/meta/main.yml b/ansible/roles/base/meta/main.yml new file mode 100644 index 000000000..5514b6a40 --- /dev/null +++ b/ansible/roles/base/meta/main.yml @@ -0,0 +1 @@ +dependencies: [] \ No newline at end of file diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml new file mode 100644 index 000000000..2660f4401 --- /dev/null +++ b/ansible/roles/base/tasks/main.yml @@ -0,0 +1,19 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +- name: Prepare {{ ansible_facts['distribution'] }} distribution. + include_tasks: "{{ ansible_facts['distribution'] | lower }}.yml" + when: ansible_facts['distribution'] == 'Ubuntu' + +- name: Prepare {{ ansible_facts['distribution'] }} distribution. + ### Generalized since Rocky Linux and AlmaLinux do not report `os_family` as `RedHat` in some versions of Ansible. + include_tasks: "redhat.yml" + when: ansible_facts['distribution'] in ['RedHat', 'CentOS', 'Rocky', 'AlmaLinux'] + +- name: Prepare {{ ansible_facts['os_family'] }} distribution. + include_tasks: "{{ ansible_facts['lsb']['codename'] | lower }}.yml" + when: ansible_facts['os_family'] == 'VMware Photon OS' \ No newline at end of file diff --git a/ansible/roles/base/tasks/photon.yml b/ansible/roles/base/tasks/photon.yml new file mode 100644 index 000000000..fc19de358 --- /dev/null +++ b/ansible/roles/base/tasks/photon.yml @@ -0,0 +1,44 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." + command: "{{item}}" + with_items: + ### ----------------------------------------------- ### + ### Required due to a bug in VMware Photon OS 4.0. ### + - tdnf -y remove minimal + - rpm -e --noscripts systemd-udev-247.3-1.ph4 + ### ----------------------------------------------- ### + - tdnf clean all + - tdnf makecache + - tdnf -y update + args: + warn: false + +- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." + command: | + tdnf -y install \ + minimal \ + logrotate \ + wget \ + git \ + unzip \ + tar \ + jq \ + parted \ + openssl-c_rehash + args: + warn: false + +- name: "{{ ansible_facts['distribution'] }} - Importing Certificate Authority certificates." + copy: + src: root-ca.crt + dest: /etc/ssl/certs/root-ca.pem + owner: root + group: root + mode: 0644 + notify: "{{ ansible_facts['distribution'] }} - Updating the certificate authority trust." \ No newline at end of file diff --git a/ansible/roles/base/tasks/redhat.yml b/ansible/roles/base/tasks/redhat.yml new file mode 100644 index 000000000..2b37bf45c --- /dev/null +++ b/ansible/roles/base/tasks/redhat.yml @@ -0,0 +1,68 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +### Red Hat Enterprise Linux + +- name: Red Hat Subscription Manager Status + shell: subscription-manager refresh + when: ansible_facts['distribution'] == 'RedHat' + +### Red Hat Enterprise Linux >= 8 and Derivative Distributions + +- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." + dnf: + name: "*" + state: latest + update_cache: yes + when: ansible_facts['distribution_major_version'] >= "8" + +- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." + dnf: + name: + - curl + - wget + - git + - vim + - net-tools + - unzip + - ca-certificates + state: latest + when: ansible_facts['distribution_major_version'] >= "8" + +### Red Hat Enterprise Linux <= 7 and Derivative Distributions + +- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." + yum: + name: "*" + state: latest + update_cache: yes + when: + - ansible_facts['distribution_major_version'] <= "7" + +- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." + yum: + name: + - curl + - wget + - git + - vim + - net-tools + - unzip + - ca-certificates + state: latest + when: ansible_facts['distribution_major_version'] <= "7" + +### Red Hat Enterprise Linux and Derivative Distributions + +- name: "{{ ansible_facts['distribution'] }} - Importing Certificate Authority certificates." + copy: + src: root-ca.crt + dest: /etc/pki/ca-trust/source/anchors/root-ca.crt + owner: root + group: root + mode: 0644 + notify: RedHat - Updating the certificate authority trust. \ No newline at end of file diff --git a/ansible/roles/base/tasks/ubuntu.yml b/ansible/roles/base/tasks/ubuntu.yml new file mode 100644 index 000000000..8a8660b9f --- /dev/null +++ b/ansible/roles/base/tasks/ubuntu.yml @@ -0,0 +1,34 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." + apt: + name: "*" + state: latest + update_cache: yes + force_apt_get: true + +- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." + apt: + name: + - bash-completion + - curl + - wget + - git + - net-tools + - unzip + - ca-certificates + state: latest + +- name: "{{ ansible_facts['distribution'] }} - Importing Certificate Authority certificates." + copy: + src: root-ca.crt + dest: /usr/local/share/ca-certificates/ + owner: root + group: root + mode: 0644 + notify: "{{ ansible_facts['distribution'] }} - Updating the certificate authority trust." \ No newline at end of file diff --git a/ansible/roles/base/vars/main.yml b/ansible/roles/base/vars/main.yml new file mode 100644 index 000000000..66dbcd514 --- /dev/null +++ b/ansible/roles/base/vars/main.yml @@ -0,0 +1,8 @@ +--- + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# vars for base \ No newline at end of file diff --git a/build.sh b/build.sh index ce79feab5..c4fbe1ee5 100755 --- a/build.sh +++ b/build.sh @@ -21,7 +21,7 @@ CONFIG_PATH=$(realpath "${1:-${SCRIPT_PATH}/config}") menu_option_1() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/photon-4/ - echo -e "\nCONFIRM: Build a VMware Photon OS 4 Template for VMware vSphere." + echo -e "\nCONFIRM: Build a VMware Photon OS 4 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -29,15 +29,15 @@ menu_option_1() { exit 1 fi - ### Build a VMware Photon OS 4 Template for VMware vSphere ### - echo "Building a VMware Photon OS 4 Template for VMware vSphere ..." + ### Build a VMware Photon OS 4 Template for VMware vSphere. ### + echo "Building a VMware Photon OS 4 Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Applying the HashiCorp Packer Build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -52,7 +52,7 @@ menu_option_1() { menu_option_2() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu-server-20-04-lts/ - echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS Template for VMware vSphere." + echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -60,15 +60,15 @@ menu_option_2() { exit 1 fi - ### Build a Ubuntu Server 20.04 LTS Template for VMware vSphere ### - echo "Building a Ubuntu Server 20.04 LTS Template for VMware vSphere ..." + ### Build a Ubuntu Server 20.04 LTS Template for VMware vSphere. ### + echo "Building a Ubuntu Server 20.04 LTS Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Applying the HashiCorp Packer Build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -83,7 +83,7 @@ menu_option_2() { menu_option_3() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu-server-18-04-lts/ - echo -e "\nCONFIRM: Build a Ubuntu Server 18.04 LTS Template for VMware vSphere." + echo -e "\nCONFIRM: Build a Ubuntu Server 18.04 LTS Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -91,15 +91,15 @@ menu_option_3() { exit 1 fi - ### Build a Ubuntu Server 20.04 LTS Template for VMware vSphere ### - echo "Building a Ubuntu Server 18.04 LTS Template for VMware vSphere ..." + ### Build a Ubuntu Server 20.04 LTS Template for VMware vSphere. ### + echo "Building a Ubuntu Server 18.04 LTS Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Applying the HashiCorp Packer Build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -114,7 +114,7 @@ menu_option_3() { menu_option_4() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/redhat-linux-8/ - echo -e "\nCONFIRM: Build a Red Hat Enerprise Linux 8 Server Template for VMware vSphere." + echo -e "\nCONFIRM: Build a Red Hat Enerprise Linux 8 Server Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -122,15 +122,15 @@ menu_option_4() { exit 1 fi - ### Build an Red Hat Enerprise Linux 8 Server Template for VMware vSphere ### - echo "Building a Red Hat Enerprise Linux 8 Server Template for VMware vSphere ..." + ### Build an Red Hat Enerprise Linux 8 Server Template for VMware vSphere. ### + echo "Building a Red Hat Enerprise Linux 8 Server Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Applying the HashiCorp Packer Build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -146,7 +146,7 @@ menu_option_4() { menu_option_5() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/redhat-linux-7/ - echo -e "\nCONFIRM: Build a Red Hat Enerprise Linux 7 Server Template for VMware vSphere." + echo -e "\nCONFIRM: Build a Red Hat Enerprise Linux 7 Server Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -154,15 +154,15 @@ menu_option_5() { exit 1 fi - ### Build an Red Hat Enerprise Linux 7 Server Template for VMware vSphere ### - echo "Building a Red Hat Enerprise Linux 7 Server Template for VMware vSphere ..." + ### Build an Red Hat Enerprise Linux 7 Server Template for VMware vSphere. ### + echo "Building a Red Hat Enerprise Linux 7 Server Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Applying the HashiCorp Packer Build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -178,7 +178,7 @@ menu_option_5() { menu_option_6() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux-8/ - echo -e "\nCONFIRM: Build an AlmaLinux 8 Template for VMware vSphere." + echo -e "\nCONFIRM: Build an AlmaLinux 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -186,15 +186,15 @@ menu_option_6() { exit 1 fi - ### Build an AlmaLinux 8 Template for VMware vSphere ### - echo "Building an AlmaLinux 8 Template for VMware vSphere ..." + ### Build an AlmaLinux 8 Template for VMware vSphere. ### + echo "Building an AlmaLinux 8 Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -209,7 +209,7 @@ menu_option_6() { menu_option_7() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky-linux-8/ - echo -e "\nCONFIRM: Build a Rocky Linux 8 Template for VMware vSphere." + echo -e "\nCONFIRM: Build a Rocky Linux 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -217,15 +217,15 @@ menu_option_7() { exit 1 fi - ### Build a Rocky Linux 8 Template for VMware vSphere ### - echo "Building a Rocky Linux 8 Template for VMware vSphere ..." + ### Build a Rocky Linux 8 Template for VMware vSphere. ### + echo "Building a Rocky Linux 8 Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -240,7 +240,7 @@ menu_option_7() { menu_option_8() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos-stream-8/ - echo -e "\nCONFIRM: Build a CentOS Stream 8 Template for VMware vSphere." + echo -e "\nCONFIRM: Build a CentOS Stream 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -248,12 +248,15 @@ menu_option_8() { exit 1 fi - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Build a CentOS Stream 8 Template for VMware vSphere. ### + echo "Building a CentOS Stream 8 Template for VMware vSphere..." + + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -268,7 +271,7 @@ menu_option_8() { menu_option_9() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos-linux-8/ - echo -e "\nCONFIRM: Build a CentOS Linux 8 Template for VMware vSphere." + echo -e "\nCONFIRM: Build a CentOS Linux 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -276,15 +279,15 @@ menu_option_9() { exit 1 fi - ### Build a CentOS Linux 8 Template for VMware vSphere ### - echo "Building a CentOS Linux 8 Template for VMware vSphere ..." + ### Build a CentOS Linux 8 Template for VMware vSphere. ### + echo "Building a CentOS Linux 8 Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -299,7 +302,7 @@ menu_option_9() { menu_option_10() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos-linux-7/ - echo -e "\nCONFIRM: Build a CentOS Linux 7 Template for VMware vSphere." + echo -e "\nCONFIRM: Build a CentOS Linux 7 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -307,15 +310,15 @@ menu_option_10() { exit 1 fi - ### Build a CentOS Linux 7 Template for VMware vSphere ### - echo "Building a CentOS Linux 7 Template for VMware vSphere ..." + ### Build a CentOS Linux 7 Template for VMware vSphere. ### + echo "Building a CentOS Linux 7 Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -330,7 +333,7 @@ menu_option_10() { menu_option_11() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2022/ - echo -e "\nCONFIRM: Build all Microsoft Windows Server 2022 Templates for VMware vSphere." + echo -e "\nCONFIRM: Build all Microsoft Windows Server 2022 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -338,15 +341,15 @@ menu_option_11() { exit 1 fi - ### Build Microsoft Windows Server 2022 Templates for VMware vSphere ### - echo "Building all Microsoft Windows Server 2022 Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2022 Templates for VMware vSphere. ### + echo "Building all Microsoft Windows Server 2022 Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -359,7 +362,7 @@ menu_option_11() { menu_option_12() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2022/ - echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Templates for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -367,15 +370,15 @@ menu_option_12() { exit 1 fi - ### Build Microsoft Windows Server 2022 Standard Templates for VMware vSphere ### - echo "Building Microsoft Windows Server 2022 Standard Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2022 Standard Templates for VMware vSphere. ### + echo "Building Microsoft Windows Server 2022 Standard Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ --only vsphere-iso.windows-server-standard-dexp,vsphere-iso.windows-server-standard-core \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ @@ -389,7 +392,7 @@ menu_option_12() { menu_option_13() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2022/ - echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -397,15 +400,15 @@ menu_option_13() { exit 1 fi - ### Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere ### - echo "Building Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere. ### + echo "Building Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ --only vsphere-iso.windows-server-datacenter-dexp,vsphere-iso.windows-server-datacenter-core \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ @@ -419,7 +422,7 @@ menu_option_13() { menu_option_14() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2019/ - echo -e "\nCONFIRM: Build all Microsoft Windows Server 2019 Templates for VMware vSphere." + echo -e "\nCONFIRM: Build all Microsoft Windows Server 2019 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -427,15 +430,15 @@ menu_option_14() { exit 1 fi - ### Build Microsoft Windows Server 2019 Templates for VMware vSphere ### - echo "Building all Microsoft Windows Server 2019 Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2019 Templates for VMware vSphere. ### + echo "Building all Microsoft Windows Server 2019 Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -448,7 +451,7 @@ menu_option_14() { menu_option_15() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2019/ - echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Templates for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -456,15 +459,15 @@ menu_option_15() { exit 1 fi - ### Build Microsoft Windows Server 2019 Standard Templates for VMware vSphere ### - echo "Building Microsoft Windows Server 2019 Standard Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2019 Standard Templates for VMware vSphere. ### + echo "Building Microsoft Windows Server 2019 Standard Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ --only vsphere-iso.windows-server-standard-dexp,vsphere-iso.windows-server-standard-core \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ @@ -478,7 +481,7 @@ menu_option_15() { menu_option_16() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2019/ - echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -486,15 +489,15 @@ menu_option_16() { exit 1 fi - ### Build Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere ### - echo "Building Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere. ### + echo "Building Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ --only vsphere-iso.windows-server-datacenter-dexp,vsphere-iso.windows-server-datacenter-core \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ @@ -508,7 +511,7 @@ menu_option_16() { menu_option_17() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2016/ - echo -e "\nCONFIRM: Build all Microsoft Windows Server 2016 Templates for VMware vSphere." + echo -e "\nCONFIRM: Build all Microsoft Windows Server 2016 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -516,15 +519,15 @@ menu_option_17() { exit 1 fi - ### Build Microsoft Windows Server 2016 Templates for VMware vSphere ### - echo "Building all Microsoft Windows Server 2016 Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2016 Templates for VMware vSphere. ### + echo "Building all Microsoft Windows Server 2016 Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ @@ -537,7 +540,7 @@ menu_option_17() { menu_option_18() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2016/ - echo -e "\nCONFIRM: Build Microsoft Windows Server 2016 Templates for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows Server 2016 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -545,15 +548,15 @@ menu_option_18() { exit 1 fi - ### Build Microsoft Windows Server 2016 Standard Templates for VMware vSphere ### - echo "Building Microsoft Windows Server 2016 Standard Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2016 Standard Templates for VMware vSphere. ### + echo "Building Microsoft Windows Server 2016 Standard Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ --only vsphere-iso.windows-server-standard-dexp,vsphere-iso.windows-server-standard-core \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ @@ -567,7 +570,7 @@ menu_option_18() { menu_option_19() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-server-2016/ - echo -e "\nCONFIRM: Build Microsoft Windows Server 2016 Datacenter Templates for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows Server 2016 Datacenter Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -575,15 +578,15 @@ menu_option_19() { exit 1 fi - ### Build Microsoft Windows Server 2016 Datacenter Templates for VMware vSphere ### - echo "Building a Microsoft Windows Server 2016 Datacenter Templates for VMware vSphere ..." + ### Build Microsoft Windows Server 2016 Datacenter Templates for VMware vSphere. ### + echo "Building a Microsoft Windows Server 2016 Datacenter Templates for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ --only vsphere-iso.windows-server-datacenter-dexp,vsphere-iso.windows-server-datacenter-core \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ @@ -597,7 +600,7 @@ menu_option_19() { menu_option_20() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/windows-10/ - echo -e "\nCONFIRM: Build Microsoft Windows 10 Professional Template for VMware vSphere." + echo -e "\nCONFIRM: Build Microsoft Windows 10 Professional Template for VMware vSphere?" echo -e "\nContinue? (y/n)" read -r REPLY if [[ ! $REPLY =~ ^[Yy]$ ]] @@ -605,15 +608,15 @@ menu_option_20() { exit 1 fi - ### Build Microsoft Windows 10 Professional for VMware vSphere ### - echo "Building a Microsoft Microsoft Windows 10 Professional Template for VMware vSphere ..." + ### Build Microsoft Windows 10 Professional for VMware vSphere. ### + echo "Building a Microsoft Microsoft Windows 10 Professional Template for VMware vSphere..." - ### Initialize Hashicorp Packer and required plugins ### - echo "Initializing Hashicorp Packer and required plugins ..." + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." packer init "$INPUT_PATH" - ### Apply the HashiCorp Packer Build ### - echo "Starting the HashiCorp Packer build ..." + ### Start the HashiCorp Packer Build ### + echo "Starting the HashiCorp Packer build..." packer build -force \ -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ diff --git a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl index 564587e1b..90646d6a1 100644 --- a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl @@ -128,9 +128,16 @@ source "vsphere-iso" "linux-almalinux" { build { sources = ["source.vsphere-iso.linux-almalinux"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg", + "ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/centos-linux-7/linux-centos-linux.pkr.hcl b/builds/linux/centos-linux-7/linux-centos-linux.pkr.hcl index 3f2fe47f3..1fbed67c3 100644 --- a/builds/linux/centos-linux-7/linux-centos-linux.pkr.hcl +++ b/builds/linux/centos-linux-7/linux-centos-linux.pkr.hcl @@ -128,9 +128,15 @@ source "vsphere-iso" "linux-centos-linux" { build { sources = ["source.vsphere-iso.linux-centos-linux"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl index 50f29d8c0..3d1bce7e3 100644 --- a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl +++ b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl @@ -128,9 +128,15 @@ source "vsphere-iso" "linux-centos-linux" { build { sources = ["source.vsphere-iso.linux-centos-linux"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl index bb7a835ad..bdd2f0547 100644 --- a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl @@ -128,9 +128,15 @@ source "vsphere-iso" "linux-centos-stream" { build { sources = ["source.vsphere-iso.linux-centos-stream"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/photon-4/linux-photon.pkr.hcl b/builds/linux/photon-4/linux-photon.pkr.hcl index 10833b23f..ab4353298 100644 --- a/builds/linux/photon-4/linux-photon.pkr.hcl +++ b/builds/linux/photon-4/linux-photon.pkr.hcl @@ -124,9 +124,16 @@ source "vsphere-iso" "linux-photon" { build { sources = ["source.vsphere-iso.linux-photon"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg", + "ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/redhat-linux-7/linux-redhat-linux.pkr.hcl b/builds/linux/redhat-linux-7/linux-redhat-linux.pkr.hcl index d1ad08f36..aa087d359 100644 --- a/builds/linux/redhat-linux-7/linux-redhat-linux.pkr.hcl +++ b/builds/linux/redhat-linux-7/linux-redhat-linux.pkr.hcl @@ -130,9 +130,15 @@ source "vsphere-iso" "linux-redhat-linux" { build { sources = ["source.vsphere-iso.linux-redhat-linux"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl index df84f28bf..1d77284c8 100644 --- a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl +++ b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl @@ -130,9 +130,15 @@ source "vsphere-iso" "linux-redhat-linux" { build { sources = ["source.vsphere-iso.linux-redhat-linux"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl index e21f4c356..4b7e56a2b 100644 --- a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl +++ b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl @@ -128,9 +128,15 @@ source "vsphere-iso" "linux-rocky-linux" { build { sources = ["source.vsphere-iso.linux-rocky-linux"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl index 38742495d..30c4808e4 100644 --- a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl @@ -134,13 +134,16 @@ source "vsphere-iso" "linux-ubuntu-server" { build { sources = ["source.vsphere-iso.linux-ubuntu-server"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" - } - - provisioner "ansible-local" { - playbook_file = "${path.cwd}/scripts/ansible/playbook.yml" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg", + "ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl index 2a4002ded..a7dde16c0 100644 --- a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl @@ -132,13 +132,15 @@ source "vsphere-iso" "linux-ubuntu-server" { build { sources = ["source.vsphere-iso.linux-ubuntu-server"] - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "${path.cwd}/certificates/root-ca.crt" - } - - provisioner "ansible-local" { - playbook_file = "${path.cwd}/scripts/ansible/playbook.yml" + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "-e", "display_skipped_hosts = false" + ] } provisioner "shell" { diff --git a/scripts/ansible/playbook.yml b/scripts/ansible/playbook.yml deleted file mode 100644 index e90f6c89f..000000000 --- a/scripts/ansible/playbook.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -- hosts: localhost - gather_facts: yes - become: true - tasks: - - name: System Details - debug: msg="{{ item }}" - with_items: - - "{{ ansible_distribution }}" - - - block: # Ubuntu Distributions - - name: Update Cache and Upgrade Packages - apt: - name: "*" - state: latest - update_cache: yes - force_apt_get: true - - - name: Install Additional Packages - apt: - name: - - bash-completion - - curl - - wget - - git - - net-tools - - unzip - - ca-certificates - state: latest - - - name: Install CA Certificate - copy: - src: /tmp/root-ca.crt - dest: /usr/local/share/ca-certificates/ - owner: root - group: root - mode: 0644 - notify: - - Ubuntu - Update Trusted CA - when: - - ansible_distribution == "Ubuntu" - - handlers: - - name: Ubuntu - Update Trusted CA - shell: /usr/sbin/update-ca-certificates diff --git a/scripts/linux/photon.sh b/scripts/linux/photon.sh index 8e65c0528..f622a4540 100644 --- a/scripts/linux/photon.sh +++ b/scripts/linux/photon.sh @@ -17,42 +17,6 @@ export ANSIBLE_KEY echo '> Disabling IPv6' echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf -#### Update the guest operating system. ### -echo '> Updating the guest operating system ...' -cd /etc/yum.repos.d/ -sed -i 's/dl.bintray.com\/vmware/packages.vmware.com\/photon\/$releasever/g' photon.repo photon-updates.repo photon-extras.repo photon-debuginfo.repo -sudo tdnf -y update photon-repos -sudo tdnf -y remove minimal # Required due to a bug in VMware Photon OS 4.0. -sudo rpm -e --noscripts systemd-udev-247.3-1.ph4 # Required due to a bug in VMware Photon OS 4.0. -sudo tdnf clean all -sudo tdnf makecache -sudo tdnf -y update - -### Install additional packages. ### -echo '> Installing additional packages ...' -sudo tdnf install -y \ - minimal \ - logrotate \ - wget \ - git \ - unzip \ - tar \ - jq \ - parted \ - openssl-c_rehash - -### Clearing tdnf cache. ### -echo '> Clearing tdnf cache ...' -sudo tdnf clean all - -### Copy the Certificate Authority certificates and add to the certificate authority trust. ### -echo '> Copying the Certificate Authority certificates and adding to the certificate authority trust ...' -sudo chown -R root:root /tmp/root-ca.crt -sudo cat /tmp/root-ca.crt > /etc/ssl/certs/root-ca.pem -sudo chmod 644 /etc/ssl/certs/root-ca.pem -sudo rehash_ca_certificates.sh -sudo rm -rf /tmp/root-ca.crt - ### Update the default local user. ### echo '> Updating the default local user ...' echo '> Adding authorized_keys for the default local user ...' @@ -98,7 +62,7 @@ sudo sed -i '/^After=vgauthd.service/a\After=dbus.service' /usr/lib/systemd/syst ### Create a cleanup script. ### echo '> Creating cleanup script ...' -sudo cat < /tmp/clean.sh +sudo cat < /home/$BUILD_USERNAME/clean.sh #!/bin/bash # Cleans all audit logs. @@ -153,11 +117,11 @@ EOF ### Change script permissions for execution. ### echo '> Changeing script permissions for execution ...' -sudo chmod +x /tmp/clean.sh +sudo chmod +x /home/$BUILD_USERNAME/clean.sh ### Runs the cleauup script. ### echo '> Running the cleanup script ...' -sudo /tmp/clean.sh +sudo /home/$BUILD_USERNAME/clean.sh ### Generate host keys using ssh-keygen ### echo '> Generating host keys ...' diff --git a/scripts/linux/rhel7-derivative.sh b/scripts/linux/rhel7-derivative.sh index 6b5e7390e..309f04621 100644 --- a/scripts/linux/rhel7-derivative.sh +++ b/scripts/linux/rhel7-derivative.sh @@ -12,30 +12,6 @@ export BUILD_KEY export ANSIBLE_USERNAME export ANSIBLE_KEY -#### Update the guest operating system. ### -echo '> Updating the guest operating system ...' -sudo yum update -y - -### Install additional packages. ### -echo '> Installing additional packages ...' -sudo yum install -y \ - epel-release \ - curl \ - wget \ - git \ - vim \ - net-tools \ - unzip \ - ca-certificates - -### Install the Certificate Authority certificates and add to the certificate authority trust. ### -echo '> Installing the Certificate Authority certificates and adding to the certificate authority trust ...' -sudo chown -R root:root /tmp/root-ca.crt -sudo cat /tmp/root-ca.crt > /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo chmod 644 /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo update-ca-trust extract -sudo rm -rf /tmp/root-ca.crt - ### Update the default local user. ### echo '> Updating the default local user ...' echo '> Adding authorized_keys for the default local user ...' diff --git a/scripts/linux/rhel7.sh b/scripts/linux/rhel7.sh index cc6ec9d9d..f6fc308a7 100644 --- a/scripts/linux/rhel7.sh +++ b/scripts/linux/rhel7.sh @@ -12,33 +12,6 @@ export BUILD_KEY export ANSIBLE_USERNAME export ANSIBLE_KEY -#### Checking Red Hat Subscription Manager status. ### -echo '> Checking the Red Hat Subscription Manager status ...' -subscription-manager refresh - -#### Update the guest operating system. ### -echo '> Updating the guest operating system ...' -sudo yum update -y - -### Install additional packages. ### -echo '> Installing additional packages ...' -sudo yum install -y \ - curl \ - wget \ - git \ - vim \ - net-tools \ - unzip \ - ca-certificates - -### Install the Certificate Authority certificates and add to the certificate authority trust. ### -echo '> Installing the Certificate Authority certificates and adding to the certificate authority trust ...' -sudo chown -R root:root /tmp/root-ca.crt -sudo cat /tmp/root-ca.crt > /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo chmod 644 /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo update-ca-trust extract -sudo rm -rf /tmp/root-ca.crt - ### Update the default local user. ### echo '> Updating the default local user ...' sudo mkdir -p /home/$BUILD_USERNAME/.ssh diff --git a/scripts/linux/rhel8-derivative.sh b/scripts/linux/rhel8-derivative.sh index fd2f57e8c..764b1bb94 100644 --- a/scripts/linux/rhel8-derivative.sh +++ b/scripts/linux/rhel8-derivative.sh @@ -12,30 +12,6 @@ export BUILD_KEY export ANSIBLE_USERNAME export ANSIBLE_KEY -#### Update the guest operating system. ### -echo '> Updating the guest operating system ...' -sudo dnf update -y - -### Install additional packages. ### -echo '> Installing additional packages ...' -sudo dnf install -y \ - epel-release \ - curl \ - wget \ - git \ - vim \ - net-tools \ - unzip \ - ca-certificates - -### Install the Certificate Authority certificates and add to the certificate authority trust. ### -echo '> Installing the Certificate Authority certificates and adding to the certificate authority trust ...' -sudo chown -R root:root /tmp/root-ca.crt -sudo cat /tmp/root-ca.crt > /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo chmod 644 /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo update-ca-trust extract -sudo rm -rf /tmp/root-ca.crt - ### Update the default local user. ### echo '> Updating the default local user ...' echo '> Adding authorized_keys for the default local user ...' diff --git a/scripts/linux/rhel8.sh b/scripts/linux/rhel8.sh index 52aed00e2..66a5f16eb 100644 --- a/scripts/linux/rhel8.sh +++ b/scripts/linux/rhel8.sh @@ -12,33 +12,6 @@ export BUILD_KEY export ANSIBLE_USERNAME export ANSIBLE_KEY -#### Checking Red Hat Subscription Manager status. ### -echo '> Checking the Red Hat Subscription Manager status ...' -subscription-manager refresh - -#### Update the guest operating system. ### -echo '> Updating the guest operating system ...' -sudo dnf update -y - -### Install additional packages. ### -echo '> Installing additional packages ...' -sudo dnf install -y \ - curl \ - wget \ - git \ - vim \ - net-tools \ - unzip \ - ca-certificates - -### Install the Certificate Authority certificates and add to the certificate authority trust. ### -echo '> Installing the Certificate Authority certificates and adding to the certificate authority trust ...' -sudo chown -R root:root /tmp/root-ca.crt -sudo cat /tmp/root-ca.crt > /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo chmod 644 /etc/pki/ca-trust/source/anchors/root-ca.crt -sudo update-ca-trust extract -sudo rm -rf /tmp/root-ca.crt - ### Update the default local user. ### echo '> Updating the default local user ...' sudo mkdir -p /home/$BUILD_USERNAME/.ssh