From 061ca8217a151bea5676fd239691fb1b37fa7dbf Mon Sep 17 00:00:00 2001 From: Corey Hemminger Date: Thu, 11 Apr 2024 17:34:21 -0500 Subject: [PATCH] switch to ubuntu-latest runners (#1561) - Add back iso check, packer lint, and amazonlinux builds to build pipeline - Fix amazonlinux 2 build script - Added amazonlinux 2023 build scripts - Migrate Virtualbox and Qemu builds to github hosted runners from self-hosted runners - Added test-kitchen and kitchen-vagrant dependencies to gemspec - Added arg for bento test command to specify a specific build to test - this passes the arg to the kitchen test command - Fix vagrant post-processor to specify custom vagrant file for freebsd builds - Remove gui true from windows custom vagrant file - Fix test to skip removing linux-firmware on oraclelinux - Renamed oracle boxes to oraclelinux for consistency and remove edge cases in code - Removed unused -c flag for specifying a specific config file for bento build - Added --on-error flag to bento build command to pass to packer command - Added cpu architecture support to bento build command, so it'll only test builds that work with the current cpu architecture - Remove additional Ubuntu user-date last-command that may be locking macaddress - Add to test to move failed test boxes to builds/failed_testing directory - Changed ssh_timeout to 15m --- .github/workflows/ci-build.yml | 16 +++- .github/workflows/pkr-bld-amazonlinux-x64.yml | 64 ++++++++------- .github/workflows/pkr-bld-hyperv-x64.yml | 20 ++--- .github/workflows/pkr-bld-parallels-arm64.yml | 35 ++++----- .github/workflows/pkr-bld-parallels-x64.yml | 35 ++++----- .github/workflows/pkr-bld-qemu-arm64.yml | 60 +++++++------- .github/workflows/pkr-bld-qemu-x64.yml | 78 ++++++++++++------- .../workflows/pkr-bld-virtualbox-arm64.yml | 68 ++++++++-------- .github/workflows/pkr-bld-virtualbox-x64.yml | 74 ++++++++++-------- .github/workflows/pkr-bld-vmware-arm64.yml | 35 ++++----- .github/workflows/pkr-bld-vmware-x64.yml | 35 ++++----- .gitignore | 1 + CHANGELOG.md | 27 ++++++- amazonlinux-2-x86_64-virtualbox-build.sh | 19 +++-- amazonlinux-2023-aarch64-virtualbox-build.sh | 19 +++-- amazonlinux-2023-x86_64-virtualbox-build.sh | 19 +++-- bento.gemspec | 2 + builds.yml | 8 +- builds/failed_testing/.gitkeep | 0 builds/iso/.gitkeep | 0 lib/bento/cli.rb | 16 ++-- lib/bento/common.rb | 36 ++------- lib/bento/providermetadata.rb | 2 +- lib/bento/runner.rb | 12 +-- lib/bento/test.rb | 36 +++++++-- lib/bento/version.rb | 2 +- .../amazonlinux-2-x86_64.pkrvars.hcl | 10 +-- .../opensuse-leap-15-aarch64.pkrvars.hcl | 2 +- .../opensuse-leap-15-x86_64.pkrvars.hcl | 2 +- .../oraclelinux-7-aarch64.pkrvars.hcl} | 2 +- .../oraclelinux-7-x86_64.pkrvars.hcl} | 2 +- .../oraclelinux-8-aarch64.pkrvars.hcl} | 2 +- .../oraclelinux-8-x86_64.pkrvars.hcl} | 2 +- .../oraclelinux-9-aarch64.pkrvars.hcl} | 2 +- .../oraclelinux-9-x86_64.pkrvars.hcl} | 2 +- os_pkrvars/sles/sles-15-x86_64.pkrvars.hcl | 2 +- packer_templates/http/ubuntu/user-data | 2 +- packer_templates/pkr-builder.pkr.hcl | 10 ++- packer_templates/pkr-variables.pkr.hcl | 2 +- packer_templates/scripts/rhel/cleanup_yum.sh | 5 +- packer_templates/vagrantfile-windows.template | 1 - 41 files changed, 419 insertions(+), 348 deletions(-) create mode 100644 builds/failed_testing/.gitkeep create mode 100644 builds/iso/.gitkeep rename os_pkrvars/{oracle/oracle-7-aarch64.pkrvars.hcl => oraclelinux/oraclelinux-7-aarch64.pkrvars.hcl} (93%) rename os_pkrvars/{oracle/oracle-7-x86_64.pkrvars.hcl => oraclelinux/oraclelinux-7-x86_64.pkrvars.hcl} (92%) rename os_pkrvars/{oracle/oracle-8-aarch64.pkrvars.hcl => oraclelinux/oraclelinux-8-aarch64.pkrvars.hcl} (93%) rename os_pkrvars/{oracle/oracle-8-x86_64.pkrvars.hcl => oraclelinux/oraclelinux-8-x86_64.pkrvars.hcl} (92%) rename os_pkrvars/{oracle/oracle-9-aarch64.pkrvars.hcl => oraclelinux/oraclelinux-9-aarch64.pkrvars.hcl} (93%) rename os_pkrvars/{oracle/oracle-9-x86_64.pkrvars.hcl => oraclelinux/oraclelinux-9-x86_64.pkrvars.hcl} (92%) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 6864185e1..59932627c 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -28,9 +28,18 @@ jobs: powershell-lint: uses: chef/github-workflows/.github/workflows/powershell-lint.yml@main -# pkr-bld-amazonlinux-x64: -# uses: ./.github/workflows/pkr-bld-amazonlinux-x64.yml -# secrets: inherit + packer-iso-check: + uses: chef/github-workflows/.github/workflows/packer-iso-url-checker.yml@main + with: + EXCLUDE_REGEX: 'amazonlinux-2.*|rhel.*|sles.*|solaris.*|windows-11-aarch64.*' + + packer-lint: + uses: chef/github-workflows/.github/workflows/packer-lint.yml@main + secrets: inherit + + pkr-bld-amazonlinux-x64: + uses: ./.github/workflows/pkr-bld-amazonlinux-x64.yml + secrets: inherit pkr-bld-hyperv-x64: uses: ./.github/workflows/pkr-bld-hyperv-x64.yml @@ -77,6 +86,7 @@ jobs: - xml-lint - powershell-lint - shellcheck-lint + - packer-lint runs-on: Ubuntu-latest steps: - name: Decide whether the needed jobs succeeded or failed diff --git a/.github/workflows/pkr-bld-amazonlinux-x64.yml b/.github/workflows/pkr-bld-amazonlinux-x64.yml index 033202112..e12c54d14 100644 --- a/.github/workflows/pkr-bld-amazonlinux-x64.yml +++ b/.github/workflows/pkr-bld-amazonlinux-x64.yml @@ -4,51 +4,61 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: x86_64: - runs-on: [self-hosted, X64, virtualbox] + runs-on: ubuntu-latest strategy: fail-fast: false matrix: os: - amazonlinux-2 + - amazonlinux-2023 steps: + - name: Install Vagrant and VirtualBox + run: | + wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg + wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/oracle-virtualbox-2016.gpg + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + echo "deb [signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list + sudo apt-get update + sudo apt-get install -y software-properties-common vagrant virtualbox-7.0 qemu-utils genisoimage + VBoxManage --version + vagrant --version + - name: Install Chef + uses: actionshub/chef-install@3.0.0 + - name: Setup Packer + uses: hashicorp/setup-packer@main + with: + version: latest - name: Checkout uses: actions/checkout@main -# - name: Setup Packer -# uses: hashicorp/setup-packer@main -# with: -# version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates + - name: Install Bento + run: | + eval "$(chef shell-init bash)" + gem build bento.gemspec + gem install bento-*.gem - name: Bento build run: | + rm -rf builds + sudo mkdir -p /mnt/builds/iso + sudo chmod -R 777 /mnt/builds + sudo ln -s /mnt/builds ./ eval "$(chef shell-init bash)" - ./AMZ_build_virtualbox-ovf.sh - bento build --metadata_only os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" + ./${{ matrix.os }}-x86_64-virtualbox-build.sh ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test - - name: Remove VM in case of canceled job - if: cancelled() - run: | - echo Powering off and deleting any existing VMs named AmazonLinuxBento - VBoxManage controlvm AmazonLinuxBento poweroff --type headless 2> /dev/null - sleep 1 - VBoxManage unregistervm AmazonLinuxBento --delete 2> /dev/null - sleep 2 + cat builds/${{ matrix.os }}*-x86_64._metadata.json - name: Upload build artifact uses: actions/upload-artifact@main with: name: "${{ matrix.os }}-virtualbox-x86_64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.github/workflows/pkr-bld-hyperv-x64.yml b/.github/workflows/pkr-bld-hyperv-x64.yml index fae3953c8..833ce338c 100644 --- a/.github/workflows/pkr-bld-hyperv-x64.yml +++ b/.github/workflows/pkr-bld-hyperv-x64.yml @@ -4,6 +4,7 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: x86_64: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,20 +38,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') # - name: Setup Packer # uses: hashicorp/setup-packer@main # with: # version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: packer fmt -check -recursive . - - name: Packer Validate - run: packer validate -var-file="os_pkrvars/$("${{ matrix.os }}".Split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates - - name: Packer build + - name: Bento build run: packer build -timestamp-ui -only="${{ matrix.provider }}.vm" -var-file="os_pkrvars/$("${{ matrix.os }}".Split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates - name: Remove VM in case of canceled job if: cancelled() @@ -66,4 +58,6 @@ jobs: name: "${{ matrix.os }}-hyperv-x86_64" path: | builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression diff --git a/.github/workflows/pkr-bld-parallels-arm64.yml b/.github/workflows/pkr-bld-parallels-arm64.yml index 08ec7d8ab..626841710 100644 --- a/.github/workflows/pkr-bld-parallels-arm64.yml +++ b/.github/workflows/pkr-bld-parallels-arm64.yml @@ -4,6 +4,7 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: aarch64: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,30 +38,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') # - name: Setup Packer # if: steps.verify-changed-files.outputs.files_changed == 'true' # uses: hashicorp/setup-packer@main # with: # version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates + - name: Bento build run: | eval "$(chef shell-init bash)" bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test + ls -alh builds/ + cat builds/${{ matrix.os }}*-aarch64._metadata.json - name: Remove VM in case of canceled job if: cancelled() run: | @@ -75,6 +63,11 @@ jobs: with: name: "${{ matrix.os }}-parallels-aarch64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.github/workflows/pkr-bld-parallels-x64.yml b/.github/workflows/pkr-bld-parallels-x64.yml index 1b9d1d3e2..aa1a55797 100644 --- a/.github/workflows/pkr-bld-parallels-x64.yml +++ b/.github/workflows/pkr-bld-parallels-x64.yml @@ -4,6 +4,7 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: x86_64: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,29 +38,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') # - name: Setup Packer # uses: hashicorp/setup-packer@main # with: # version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates + - name: Bento build run: | eval "$(chef shell-init bash)" bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test + ls -alh builds/ + cat builds/${{ matrix.os }}*-x86_64._metadata.json - name: Remove VM in case of canceled job if: cancelled() run: | @@ -74,6 +62,11 @@ jobs: with: name: "${{ matrix.os }}-parallels-x86_64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.github/workflows/pkr-bld-qemu-arm64.yml b/.github/workflows/pkr-bld-qemu-arm64.yml index 69e50b286..e32c89878 100644 --- a/.github/workflows/pkr-bld-qemu-arm64.yml +++ b/.github/workflows/pkr-bld-qemu-arm64.yml @@ -4,10 +4,11 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: aarch64: - runs-on: [self-hosted, ARM64, qemu] + runs-on: macos-14 strategy: fail-fast: false matrix: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,35 +38,40 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') -# - name: Setup Packer -# if: steps.verify-changed-files.outputs.files_changed == 'true' -# uses: hashicorp/setup-packer@main -# with: -# version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var "qemu_accelerator=hvf" -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates + - name: Install Vagrant QEMU + run: | + brew install qemu libvirt + brew tap hashicorp/tap + brew install --cask hashicorp/tap/hashicorp-vagrant + brew services start libvirt + vagrant plugin install vagrant-libvirt vagrant-qemu + - name: Install Chef + uses: actionshub/chef-install@3.0.0 + - name: Setup Packer + uses: hashicorp/setup-packer@main + with: + version: latest + - name: Install Bento + run: | + eval "$(chef shell-init bash)" + gem build bento.gemspec + gem install bento-*.gem + - name: Bento build run: | eval "$(chef shell-init bash)" bento build -o ${{ matrix.provider }}.vm --vars "qemu_accelerator=hvf" os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test + ls -alh builds/ + cat builds/${{ matrix.os }}*-aarch64._metadata.json - name: Upload build artifact uses: actions/upload-artifact@v3 with: name: "${{ matrix.os }}-qemu-aarch64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test libvirt diff --git a/.github/workflows/pkr-bld-qemu-x64.yml b/.github/workflows/pkr-bld-qemu-x64.yml index b5fbc75bd..86e2dc5a3 100644 --- a/.github/workflows/pkr-bld-qemu-x64.yml +++ b/.github/workflows/pkr-bld-qemu-x64.yml @@ -4,10 +4,11 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: x86_64: - runs-on: [self-hosted, X64, qemu] + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,36 +38,55 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') - - name: Download virtio-win.iso - run: curl https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.229-1/virtio-win.iso -o packer_templates/win_answer_files/virtio-win.iso -# - name: Setup Packer -# uses: hashicorp/setup-packer@main -# with: -# version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var "qemu_accelerator=hvf" -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates + - name: Install Vagrant and kvm + run: | + wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + sudo apt-get update + sudo apt-get install -y software-properties-common vagrant qemu-kvm libvirt-daemon-system virtinst libvirt-clients bridge-utils qemu-utils libvirt-dev + vagrant plugin install vagrant-libvirt vagrant-qemu + vagrant --version + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + sudo usermod -aG kvm $USER + sudo usermod -aG libvirt $USER + sudo chmod o+rw /var/run/libvirt/libvirt-sock + sudo systemctl start libvirtd + sudo systemctl status libvirtd + - name: Install Chef + uses: actionshub/chef-install@3.0.0 + - name: Setup Packer + uses: hashicorp/setup-packer@main + with: + version: latest + - name: Install Bento run: | eval "$(chef shell-init bash)" - bento build -o ${{ matrix.provider }}.vm --vars "qemu_accelerator=hvf" os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test + gem build bento.gemspec + gem install bento-*.gem + - name: Bento build + run: | + rm -rf builds + sudo mkdir -p /mnt/builds/iso + sudo chmod -R 777 /mnt/builds + sudo ln -s /mnt/builds ./ + eval "$(chef shell-init bash)" + bento build -o ${{ matrix.provider }}.vm --vars "qemu_accelerator=kvm" os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" + ls -alh builds/ + cat builds/${{ matrix.os }}*-x86_64._metadata.json - name: Upload build artifact uses: actions/upload-artifact@main with: name: "${{ matrix.os }}-qemu-x86_64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test libvirt diff --git a/.github/workflows/pkr-bld-virtualbox-arm64.yml b/.github/workflows/pkr-bld-virtualbox-arm64.yml index 5a5057700..f97be204e 100644 --- a/.github/workflows/pkr-bld-virtualbox-arm64.yml +++ b/.github/workflows/pkr-bld-virtualbox-arm64.yml @@ -4,10 +4,11 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: aarch64: - runs-on: [self-hosted, ARM64, virtualbox] + runs-on: macos-14 strategy: fail-fast: false matrix: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,43 +38,40 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') -# - name: Setup Packer -# if: steps.verify-changed-files.outputs.files_changed == 'true' -# uses: hashicorp/setup-packer@main -# with: -# version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates + - name: Install Vagrant Virtualbox + run: | + brew tap hashicorp/tap + brew install --cask hashicorp/tap/hashicorp-vagrant + wget -q https://www.virtualbox.org/download/testcase/VirtualBox-7.0.15_BETA4-162549-macOSArm64.dmg + hdiutil attach VirtualBox-7.0.15_BETA4-162549-macOSArm64.dmg + sudo installer -pkg /Volumes/VirtualBox/VirtualBox.pkg -target / + - name: Install Chef + uses: actionshub/chef-install@3.0.0 + - name: Setup Packer + uses: hashicorp/setup-packer@main + with: + version: latest + - name: Install Bento run: | eval "$(chef shell-init bash)" - bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test - - name: Remove VM in case of canceled job - if: cancelled() + gem build bento.gemspec + gem install bento-*.gem + - name: Bento build run: | - echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-aarch64 - VBoxManage controlvm ${{ matrix.os }}*-aarch64 poweroff --type headless 2> /dev/null - sleep 1 - VBoxManage unregistervm ${{ matrix.os }}*-aarch64 --delete 2> /dev/null - sleep 2 + eval "$(chef shell-init bash)" + bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" + ls -alh builds/ + cat builds/${{ matrix.os }}*-aarch64._metadata.json - name: Upload build artifact uses: actions/upload-artifact@main with: name: "${{ matrix.os }}-virtualbox-aarch64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.github/workflows/pkr-bld-virtualbox-x64.yml b/.github/workflows/pkr-bld-virtualbox-x64.yml index e3d29389e..7638f9875 100644 --- a/.github/workflows/pkr-bld-virtualbox-x64.yml +++ b/.github/workflows/pkr-bld-virtualbox-x64.yml @@ -4,10 +4,11 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: x86_64: - runs-on: [self-hosted, X64, virtualbox] + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,42 +38,47 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') -# - name: Setup Packer -# uses: hashicorp/setup-packer@main -# with: -# version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates + - name: Install Vagrant and VirtualBox + run: | + wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg + wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/oracle-virtualbox-2016.gpg + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + echo "deb [signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list + sudo apt-get update + sudo apt-get install -y software-properties-common vagrant virtualbox-7.0 + VBoxManage --version + vagrant --version + - name: Install Chef + uses: actionshub/chef-install@3.0.0 + - name: Setup Packer + uses: hashicorp/setup-packer@main + with: + version: latest + - name: Install Bento run: | eval "$(chef shell-init bash)" - bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test - - name: Remove VM in case of canceled job - if: cancelled() + gem build bento.gemspec + gem install bento-*.gem + - name: Bento build run: | - echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-amd64 - VBoxManage controlvm ${{ matrix.os }}*-amd64 poweroff --type headless 2> /dev/null - sleep 1 - VBoxManage unregistervm ${{ matrix.os }}*-amd64 --delete 2> /dev/null - sleep 2 + rm -rf builds + sudo mkdir -p /mnt/builds/iso + sudo chmod -R 777 /mnt/builds + sudo ln -s /mnt/builds ./ + eval "$(chef shell-init bash)" + bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" + ls -alh builds/ + cat builds/${{ matrix.os }}*-x86_64._metadata.json - name: Upload build artifact uses: actions/upload-artifact@main with: name: "${{ matrix.os }}-virtualbox-x86_64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.github/workflows/pkr-bld-vmware-arm64.yml b/.github/workflows/pkr-bld-vmware-arm64.yml index dcfd9e484..ecb3a0c5b 100644 --- a/.github/workflows/pkr-bld-vmware-arm64.yml +++ b/.github/workflows/pkr-bld-vmware-arm64.yml @@ -4,6 +4,7 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: aarch64: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,30 +38,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') # - name: Setup Packer # if: steps.verify-changed-files.outputs.files_changed == 'true' # uses: hashicorp/setup-packer@main # with: # version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" packer_templates + - name: Bento build run: | eval "$(chef shell-init bash)" bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test + ls -alh builds/ + cat builds/${{ matrix.os }}*-aarch64._metadata.json - name: Remove VM in case of canceled job if: cancelled() run: | @@ -74,6 +62,11 @@ jobs: with: name: "${{ matrix.os }}-vmware-aarch64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.github/workflows/pkr-bld-vmware-x64.yml b/.github/workflows/pkr-bld-vmware-x64.yml index 0e8b489d4..8e1bcaa57 100644 --- a/.github/workflows/pkr-bld-vmware-x64.yml +++ b/.github/workflows/pkr-bld-vmware-x64.yml @@ -4,6 +4,7 @@ on: env: PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PACKER_LOG: "1" jobs: x86_64: @@ -24,9 +25,9 @@ jobs: - freebsd-13 - freebsd-14 - opensuse-leap-15 - - oracle-7 - - oracle-8 - - oracle-9 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-20.04 @@ -37,29 +38,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@main - - name: iso-availability - shell: pwsh - run: Invoke-RestMethod -Method Head -Verbose -Uri $(Get-Content os_pkrvars/$('${{ matrix.os }}'.split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl | ConvertFrom-StringData).iso_url.Trim('"') # - name: Setup Packer # uses: hashicorp/setup-packer@main # with: # version: latest - - name: Packer Init - run: packer init -upgrade packer_templates - - name: Packer FMT - run: if packer fmt -check -recursive .; then exit 0; else echo "Some packer files need to be formatted, run 'packer fmt -recursive .' to fix"; exit 1; fi - - name: Packer Validate - run: packer validate -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates - - name: Packer build -# run: packer build -timestamp-ui -only=${{ matrix.provider }}.vm -var-file=os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates + - name: Bento build run: | eval "$(chef shell-init bash)" bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl" - ls -alh builds -# - name: Bento Test -# run: | -# eval "$(chef shell-init bash)" -# bento test + ls -alh builds/ + cat builds/${{ matrix.os }}*-x86_64._metadata.json - name: Remove VM in case of canceled job if: cancelled() run: | @@ -73,6 +61,11 @@ jobs: with: name: "${{ matrix.os }}-vmware-x86_64" path: | - builds - !builds/uploaded/* + builds/*.box + builds/*.json retention-days: 10 + compression-level: 0 # no compression + - name: Bento Test + run: | + eval "$(chef shell-init bash)" + bento test diff --git a/.gitignore b/.gitignore index 14efcc395..b85965350 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ **/builds/ *.iso *.box +*.ova *.ovf *.vmdk *.vdi diff --git a/CHANGELOG.md b/CHANGELOG.md index 13dcfefa0..04b123644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ Markdown table generated at |:----------------:|:---:|:-------------------:|:--------------------:|:---:|:---:|:--------------------:|:---:|:-----------------:|:-----------------:| | almalinux-8 | | x | | x | | x | | x | | | almalinux-9 | | x | x | | | x | | x | x | -| amazonlinux-2 | | na | na | | | | na | | na | -| amazonlinux-2023 | na | na | na | na | na | na | na | na | na | +| amazonlinux-2 | | | | | | x | | | | +| amazonlinux-2023 | | | | | | x | | | | | centos-7 | | x | | x | | x | | x | | | centos-stream-8 | | x | | x | | x | | x | | | centos-stream-9 | | | x | | | | | | | @@ -36,7 +36,7 @@ Markdown table generated at | ubuntu-22.04 | | x | | x | | x | | x | | | ubuntu-23.10 | | x | x | | | x | | x | x | | windows-10 | | x | na | | na | x | na | | na | -| windows-11 | | x | na | | na | x | na | | na | +| windows-11 | | x | x | | na | x | na | | | | windows-2016 | | x | na | | na | x | na | | na | | windows-2019 | | x | na | | na | x | na | | na | | windows-2022 | | x | na | | na | x | na | | na | @@ -53,7 +53,26 @@ Markdown table generated at - Create CD pipeline to upload vagrant boxes after PR is merged - Create CD pipeline to build and upload new versions of vagrant boxes once every 3 months with the latest patches -## [unreleased] (2024-03-20) +## [unreleased] (2024-04-11) + +## [v4.1.0] (2024-04-11) + +- Add back iso check, packer lint, and amazonlinux builds to build pipeline +- Fix amazonlinux 2 build script +- Added amazonlinux 2023 build scripts +- Migrate Virtualbox and Qemu builds to github hosted runners from self-hosted runners +- Added test-kitchen and kitchen-vagrant dependencies to gemspec +- Added arg for bento test command to specify a specific build to test - this passes the arg to the kitchen test command +- Fix vagrant post-processor to specify custom vagrant file for freebsd builds +- Remove gui true from windows custom vagrant file +- Fix test to skip removing linux-firmware on oraclelinux +- Renamed oracle boxes to oraclelinux for consistency and remove edge cases in code +- Removed unused -c flag for specifying a specific config file for bento build +- Added --on-error flag to bento build command to pass to packer command +- Added cpu architecture support to bento build command, so it'll only test builds that work with the current cpu architecture +- Remove additional Ubuntu user-date last-command that may be locking macaddress +- Add to test to move failed test boxes to builds/failed_testing directory +- Changed ssh_timeout to 15m ## [v4.0.2] (2024-03-20) diff --git a/amazonlinux-2-x86_64-virtualbox-build.sh b/amazonlinux-2-x86_64-virtualbox-build.sh index 8902e9dae..9bddec904 100755 --- a/amazonlinux-2-x86_64-virtualbox-build.sh +++ b/amazonlinux-2-x86_64-virtualbox-build.sh @@ -24,7 +24,16 @@ echo "Cleaning up old files" rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk echo "Creating ISO" -hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso +if [ -x "$(command -v genisoimage)" ]; then + genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$AMZDIR"/../amz_seed_iso/user-data "$AMZDIR"/../amz_seed_iso/meta-data +elif [ -x "$(command -v hdiutil)" ]; then + hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso +elif [ -x "$(command -v mkisofs)" ]; then + mkfsiso9660 -o "$AMZDIR"/seed.iso "$AMZDIR"/../amz_seed_iso +else + echo "No tool found to create the seed.iso" + exit 1 +fi VM="AmazonLinuxBento" echo Powering off and deleting any existing VMs named $VM @@ -36,8 +45,8 @@ echo "Creating the VM" # from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html VBoxManage createvm --name $VM --ostype "RedHat_64" --register VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon2_x86_64.vdi -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium "$AMZDIR"/seed.iso +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --type hdd --medium "$AMZDIR"/amazon2_x86_64.vdi +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --type dvddrive --medium "$AMZDIR"/seed.iso VBoxManage modifyvm $VM --memory 2048 VBoxManage modifyvm $VM --cpus 2 VBoxManage modifyvm $VM --audio-driver none @@ -48,7 +57,7 @@ echo Sleeping for 120 seconds to let the system boot and cloud-init to run VBoxManage startvm $VM --type headless sleep 120 VBoxManage controlvm $VM poweroff --type headless -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium none +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --type dvddrive --medium none sleep 5 echo Exporting the VM to an OVF file @@ -59,7 +68,7 @@ echo Deleting the VM vboxmanage unregistervm $VM --delete echo starting packer build of amazonlinux -if packer build -timestamp-ui -var "vbox_source_path=$AMZDIR/amazon2_x86_64.ovf" -var "vbox_checksum=null" -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then +if bento build --vars vbox_source_path="$AMZDIR"/amazon2_x86_64.ovf,vbox_checksum=null "$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl; then echo "Cleaning up files" rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso else diff --git a/amazonlinux-2023-aarch64-virtualbox-build.sh b/amazonlinux-2023-aarch64-virtualbox-build.sh index 5d0ec7ae8..2bee4bf56 100755 --- a/amazonlinux-2023-aarch64-virtualbox-build.sh +++ b/amazonlinux-2023-aarch64-virtualbox-build.sh @@ -26,7 +26,16 @@ if [ ! -f "$AMZDIR"/amazon2023_arm64.vdi ]; then fi echo "Creating ISO" -hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso +if [ -x "$(command -v genisoimage)" ]; then + genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$AMZDIR"/../amz_seed_iso/user-data "$AMZDIR"/../amz_seed_iso/meta-data +elif [ -x "$(command -v hdiutil)" ]; then + hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso +elif [ -x "$(command -v mkisofs)" ]; then + mkfsiso9660 -o "$AMZDIR"/seed.iso "$AMZDIR"/../amz_seed_iso +else + echo "No tool found to create the seed.iso" + exit 1 +fi VM="AmazonLinuxBento" echo Powering off and deleting any existing VMs named $VM @@ -38,8 +47,8 @@ echo "Creating the VM" # from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html VBoxManage createvm --name $VM --ostype "Fedora_64" --register VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon2023_arm64.vdi -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium "$AMZDIR"/seed.iso +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --type hdd --medium "$AMZDIR"/amazon2023_arm64.vdi +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --type dvddrive --medium "$AMZDIR"/seed.iso VBoxManage modifyvm $VM --chipset ich9 VBoxManage modifyvm $VM --firmware efi VBoxManage modifyvm $VM --memory 2048 @@ -56,7 +65,7 @@ echo "Sleeping for 120 seconds to let the system boot and cloud-init to run" VBoxManage startvm $VM --type headless sleep 120 VBoxManage controlvm $VM poweroff --type headless -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium none +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --type dvddrive --medium none sleep 5 echo "Exporting the VM to an OVF file" @@ -67,7 +76,7 @@ echo "Deleting the VM" vboxmanage unregistervm $VM --delete echo "starting packer build of amazonlinux" -if packer build -timestamp-ui -var "vbox_source_path=$AMZDIR/amazon2023_arm64.ovf" -var "vbox_checksum=null" -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-aarch64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then +if bento build --vars vbox_source_path="$AMZDIR"/amazon2023_arm64.ovf,vbox_checksum=null "$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-aarch64.pkrvars.hcl; then echo "Cleaning up files" rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso "$AMZDIR"/*.vdi "$AMZDIR"/*.qcow2 else diff --git a/amazonlinux-2023-x86_64-virtualbox-build.sh b/amazonlinux-2023-x86_64-virtualbox-build.sh index f58fb84b6..0591f6a86 100755 --- a/amazonlinux-2023-x86_64-virtualbox-build.sh +++ b/amazonlinux-2023-x86_64-virtualbox-build.sh @@ -26,7 +26,16 @@ if [ ! -f "$AMZDIR"/amazon2023_x86_64.vdi ]; then fi echo "Creating ISO" -hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso +if [ -x "$(command -v genisoimage)" ]; then + genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$AMZDIR"/../amz_seed_iso/user-data "$AMZDIR"/../amz_seed_iso/meta-data +elif [ -x "$(command -v hdiutil)" ]; then + hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso +elif [ -x "$(command -v mkisofs)" ]; then + mkfsiso9660 -o "$AMZDIR"/seed.iso "$AMZDIR"/../amz_seed_iso +else + echo "No tool found to create the seed.iso" + exit 1 +fi VM="AmazonLinuxBento" echo Powering off and deleting any existing VMs named $VM @@ -38,8 +47,8 @@ echo "Creating the VM" # from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html VBoxManage createvm --name $VM --ostype "Fedora_64" --register VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon2023_x86_64.vdi -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium "$AMZDIR"/seed.iso +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --type hdd --medium "$AMZDIR"/amazon2023_x86_64.vdi +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --type dvddrive --medium "$AMZDIR"/seed.iso VBoxManage modifyvm $VM --memory 2048 VBoxManage modifyvm $VM --cpus 2 VBoxManage modifyvm $VM --nat-localhostreachable1 on @@ -54,7 +63,7 @@ echo "Sleeping for 120 seconds to let the system boot and cloud-init to run" VBoxManage startvm $VM --type headless sleep 120 VBoxManage controlvm $VM poweroff --type headless -VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium none +VBoxManage storageattach $VM --storagectl "SATA Controller" --port 1 --type dvddrive --medium none sleep 5 echo "Exporting the VM to an OVF file" @@ -65,7 +74,7 @@ echo "Deleting the VM" vboxmanage unregistervm $VM --delete echo "starting packer build of amazonlinux" -if packer build -timestamp-ui -var "vbox_source_path=$AMZDIR/amazon2023_x86_64.ovf" -var "vbox_checksum=null" -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-x86_64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then +if bento build --vars vbox_source_path="$AMZDIR"/amazon2023_x86_64.ovf,vbox_checksum=null "$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-x86_64.pkrvars.hcl; then echo "Cleaning up files" rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso "$AMZDIR"/*.vdi "$AMZDIR"/*.qcow2 else diff --git a/bento.gemspec b/bento.gemspec index 690638410..51343bad0 100644 --- a/bento.gemspec +++ b/bento.gemspec @@ -14,6 +14,8 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.6' s.add_dependency 'mixlib-shellout', '>= 2.3.2' + s.add_dependency 'test-kitchen' + s.add_dependency 'kitchen-vagrant' s.bindir = 'bin' s.executables = %w(bento) diff --git a/builds.yml b/builds.yml index 6a3567516..873b50a90 100644 --- a/builds.yml +++ b/builds.yml @@ -10,8 +10,6 @@ public: - 'amazonlinux-2023' - 'almalinux-8' - 'almalinux-9' - - 'amazon-2' - - 'amazon-2023' - 'centos-7' - 'centos-stream-8' - 'centos-stream-9' @@ -22,9 +20,9 @@ public: - 'freebsd-13' - 'freebsd-14' - 'opensuse-leap-15' - - 'oracle-7' - - 'oracle-8' - - 'oracle-9' + - 'oraclelinux-7' + - 'oraclelinux-8' + - 'oraclelinux-9' - 'rockylinux-8' - 'rockylinux-9' - 'ubuntu-20.04' diff --git a/builds/failed_testing/.gitkeep b/builds/failed_testing/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/builds/iso/.gitkeep b/builds/iso/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/bento/cli.rb b/lib/bento/cli.rb index 0727465e4..e68ab53c8 100644 --- a/lib/bento/cli.rb +++ b/lib/bento/cli.rb @@ -49,6 +49,10 @@ def self.parse(args) end } + test_argv_proc = proc { |opts| + opts.regx = ARGV[0] + } + md_json_argv_proc = proc { |opts| opts.md_json = ARGV[0] } @@ -81,6 +85,10 @@ def self.parse(args) options.metadata_only = opt end + opts.on('--on-error', '[cleanup|abort|ask|run-cleanup-provisioner] If the build fails do: clean up (default), abort, ask, or run-cleanup-provisioner.') do |opt| + options.on_error = opt + end + opts.on('--vars VARS', 'Comma seperated list of variable names equal values (ex: boot_wait="2s",ssh_timeout="5s")') do |opt| options.vars = opt end @@ -89,10 +97,6 @@ def self.parse(args) options.var_files = opt end - opts.on('-c BUILD_YML', '--config BUILD_YML', 'Use a configuration file') do |opt| - options.config = opt - end - opts.on('-d', '--[no-]debug', 'Run packer with debug output') do |opt| options.debug = opt end @@ -165,7 +169,7 @@ def self.parse(args) options.provisioner = opt end end, - argv: proc {}, + argv: test_argv_proc, }, upload: { class: UploadRunner, @@ -206,7 +210,7 @@ def initialize(opts) end def start - templates.each { |template| puts template } + puts templates.join("\n") end end diff --git a/lib/bento/common.rb b/lib/bento/common.rb index 24aa0b81f..8b3b9a63d 100644 --- a/lib/bento/common.rb +++ b/lib/bento/common.rb @@ -75,40 +75,20 @@ def box_metadata(metadata_file) metadata end - def metadata_files - @metadata_files ||= Dir.glob('builds/*.json') + def metadata_files(arch_support = false) + arch = if RbConfig::CONFIG['host_cpu'] == 'arm64' + 'aarch64' + else + RbConfig::CONFIG['host_cpu'] + end + glob = "builds/*#{"-#{arch}" if arch_support}._metadata.json" + @metadata_files ||= Dir.glob(glob) end def builds_yml YAML.load(File.read('builds.yml')) end - def build_list - arm64 = [] - x86_64 = [] - builds_yml['public'].each do |platform, versions| - versions.each do |version, archs| - archs.each do |arch| - folder = case platform - when 'opensuse-leap' - 'opensuse' - when 'oracle' - 'oraclelinux' - else - platform - end - case arch - when 'aarch64' - arm64 << "#{folder}/#{platform}-#{version}-#{arch}" - else - x86_64 << "#{folder}/#{platform}-#{version}-#{arch}" - end - end - end - end - x86_64 + arm64 - end - def private_box?(boxname) proprietary_os_list = %w(macos windows sles solaris rhel) proprietary_os_list.any? { |p| boxname.include?(p) } diff --git a/lib/bento/providermetadata.rb b/lib/bento/providermetadata.rb index 051b41a9d..7850e4c49 100644 --- a/lib/bento/providermetadata.rb +++ b/lib/bento/providermetadata.rb @@ -93,7 +93,7 @@ def ver_vbox end def ver_libvirt - cmd = Mixlib::ShellOut.new('/usr/local/opt/libvirt/sbin/libvirtd -V') + cmd = Mixlib::ShellOut.new('libvirtd -V') cmd.run_command cmd.stdout.split(' ').last end diff --git a/lib/bento/runner.rb b/lib/bento/runner.rb index b59554dcc..7c41b5804 100644 --- a/lib/bento/runner.rb +++ b/lib/bento/runner.rb @@ -8,7 +8,7 @@ class BuildRunner include Common include PackerExec - attr_reader :template_files, :config, :dry_run, :debug, :only, :except, :mirror, :headed, :single, :errors, + attr_reader :template_files, :dry_run, :debug, :only, :except, :mirror, :headed, :single, :errors, :on_error, :override_version, :build_timestamp, :cpus, :mem, :metadata_only, :vars, :var_files, :pkr_cmd def initialize(opts) @@ -17,6 +17,7 @@ def initialize(opts) @dry_run = opts.dry_run @metadata_only = opts.metadata_only @debug = opts.debug + @on_error = opts.on_error ||= nil @only = opts.only ||= nil @except = opts.except @mirror = opts.mirror @@ -33,7 +34,7 @@ def initialize(opts) end def start - templates = config ? build_list : template_files + templates = template_files banner('Starting build for templates:') banner('Installing packer plugins') unless dry_run || metadata_only shellout("packer init -upgrade #{File.dirname(templates.first)}/../../packer_templates") unless dry_run || metadata_only @@ -43,7 +44,7 @@ def start end banner("Build finished in #{duration(time.real)}.") unless errors.empty? - raise("Failed Builds:\n #{errors.join("\n")}\n exited #{$CHILD_STATUS}") + raise("Failed Builds:\n#{errors.join("\n")}\nexited #{$CHILD_STATUS}") end end @@ -95,6 +96,7 @@ def packer_build_cmd(template, _var_file) cmd.insert(4, '-var headless=false') if headed cmd.insert(2, '-parallel=false') if single cmd.insert(2, '-debug') if debug + cmd.insert(2, "-on-error=#{on_error}") if on_error cmd.insert(0, 'echo') if dry_run || metadata_only cmd end @@ -106,8 +108,8 @@ def write_final_metadata(template, buildtime) md[:providers] = ProviderMetadata.new(path, md[:template]).read md[:providers].each do |p| p[:build_time] = buildtime - p[:build_cpus] = cpus unless cpus.nil? - p[:build_mem] = mem unless mem.nil? + p[:build_cpus] = cpus if cpus + p[:build_mem] = mem if mem end if dry_run diff --git a/lib/bento/test.rb b/lib/bento/test.rb index 21c2b684d..0d733aa15 100644 --- a/lib/bento/test.rb +++ b/lib/bento/test.rb @@ -5,19 +5,22 @@ class TestRunner include Common - attr_reader :shared_folder, :boxname, :provider, :box_url, :no_shared, :provisioner, :errors + attr_reader :shared_folder, :boxname, :provider, :box_url, :no_shared, :provisioner, :errors, :regx def initialize(opts) @debug = opts.debug @no_shared = opts.no_shared @provisioner = opts.provisioner.nil? ? 'shell' : opts.provisioner @errors = [] + @regx = opts.regx || nil end def start banner('Starting testing...') + md_files = metadata_files(true) + puts md_files.join("\n") time = Benchmark.measure do - metadata_files.each do |metadata_file| + md_files.each do |metadata_file| destroy_all_bento test_box(metadata_file) destroy_all_bento @@ -25,7 +28,7 @@ def start end banner("Testing finished in #{duration(time.real)}.") unless errors.empty? - raise("Failed Tests:\n #{errors.join("\n")}\n exited #{$CHILD_STATUS}") + raise("Failed Tests:\n#{errors.join("\n")}\nexited #{$CHILD_STATUS}") end end @@ -55,7 +58,7 @@ def test_box(md_json) when 'aarch64', 'arm64' 'arm64' else - raise "Unknown arch #{md_data.inspect}" + raise "Unknown arch #{md['arch'].inspect}" end @boxname = md['name'] @providers = md['providers'] @@ -71,14 +74,33 @@ def test_box(md_json) Dir.chdir(temp_dir) banner("Test kitchen file located in #{temp_dir}") - @providers.each do |k, _v| - test = Mixlib::ShellOut.new("kitchen test #{@boxname}-#{@arch}-#{k.tr('_', '-')}", timeout: 900, live_stream: STDOUT) + if regx + test = Mixlib::ShellOut.new("kitchen test #{regx.tr('.', '').tr('_', '-')}", timeout: 900, live_stream: STDOUT) test.run_command if test.error? - test.stderr + puts test.stderr + errors << "#{regex}" + end + else + @providers.each do |k, v| + banner("Testing #{@boxname.tr('.', '')}-#{@arch}-#{k.tr('_', '-')}") + test = Mixlib::ShellOut.new("kitchen test #{@boxname.tr('.', '')}-#{@arch}-#{k.tr('_', '-')}", timeout: 900, live_stream: STDOUT) + test.run_command + next unless test.error? + puts test.stderr errors << "#{@boxname}-#{@arch}-#{k}" + FileUtils.cp(File.join(bento_dir, md_json), File.join(bento_dir, 'builds', 'failed_testing', File.basename(md_json))) unless File.exist?(File.join(bento_dir, 'builds', 'failed_testing', File.basename(md_json))) + FileUtils.mv(File.join(bento_dir, 'builds', v['file']), File.join(bento_dir, 'builds', 'failed_testing', v['file'])) + @providers.delete(k) + if @providers.empty? + File.delete(File.join(bento_dir, md_json)) if File.exist?(File.join(bento_dir, md_json)) + else + File.binwrite(File.join(bento_dir, md_json), JSON.pretty_generate(md)) + end end end + destroy = Mixlib::ShellOut.new('kitchen destroy', timeout: 900, live_stream: STDOUT) + destroy.run_command Dir.chdir(bento_dir) FileUtils.rm_rf(temp_dir) end diff --git a/lib/bento/version.rb b/lib/bento/version.rb index 9cba61623..4cb808c14 100644 --- a/lib/bento/version.rb +++ b/lib/bento/version.rb @@ -1,3 +1,3 @@ module Bento - VERSION = '4.0.2'.freeze + VERSION = '4.1.0'.freeze end diff --git a/os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl b/os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl index 08baf9a58..812d44045 100644 --- a/os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl +++ b/os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ -os_name = "amazonlinux" -os_version = "2" -os_arch = "x86_64" -vbox_source_path = "https://cdn.amazonlinux.com/os-images/latest/virtualbox/amzn2-virtualbox-2.0.20240306.2-x86_64.xfs.gpt.vdi" -vbox_checksum = "file:https://cdn.amazonlinux.com/os-images/latest/virtualbox/SHA256SUMS" +os_name = "amazonlinux" +os_version = "2" +os_arch = "x86_64" +vbox_source_path = "https://cdn.amazonlinux.com/os-images/latest/virtualbox/amzn2-virtualbox-2.0.20240306.2-x86_64.xfs.gpt.vdi" +vbox_checksum = "file:https://cdn.amazonlinux.com/os-images/latest/virtualbox/SHA256SUMS" parallels_guest_os_type = "centos" vbox_guest_os_type = "RedHat_64" vmware_guest_os_type = "rhel9-64" diff --git a/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl b/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl index 29b434d07..754aaebab 100644 --- a/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl +++ b/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "opensuse" +os_name = "opensuse-leap" os_version = "15.5" os_arch = "aarch64" iso_url = "http://provo-mirror.opensuse.org/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-aarch64-Media.iso" diff --git a/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl b/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl index 487b637bf..33202e42f 100644 --- a/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl +++ b/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "opensuse" +os_name = "opensuse-leap" os_version = "15.5" os_arch = "x86_64" iso_url = "http://sfo-korg-mirror.kernel.org/opensuse/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-x86_64-Media.iso" diff --git a/os_pkrvars/oracle/oracle-7-aarch64.pkrvars.hcl b/os_pkrvars/oraclelinux/oraclelinux-7-aarch64.pkrvars.hcl similarity index 93% rename from os_pkrvars/oracle/oracle-7-aarch64.pkrvars.hcl rename to os_pkrvars/oraclelinux/oraclelinux-7-aarch64.pkrvars.hcl index 67873935e..8fbfc33f8 100644 --- a/os_pkrvars/oracle/oracle-7-aarch64.pkrvars.hcl +++ b/os_pkrvars/oraclelinux/oraclelinux-7-aarch64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "oracle" +os_name = "oraclelinux" os_version = "7.9" os_arch = "aarch64" iso_url = "https://yum.oracle.com/ISOS/OracleLinux/OL7/u9/aarch64/OracleLinux-R7-U9-Server-aarch64-dvd.iso" diff --git a/os_pkrvars/oracle/oracle-7-x86_64.pkrvars.hcl b/os_pkrvars/oraclelinux/oraclelinux-7-x86_64.pkrvars.hcl similarity index 92% rename from os_pkrvars/oracle/oracle-7-x86_64.pkrvars.hcl rename to os_pkrvars/oraclelinux/oraclelinux-7-x86_64.pkrvars.hcl index 49a1a6f40..6bd8977ad 100644 --- a/os_pkrvars/oracle/oracle-7-x86_64.pkrvars.hcl +++ b/os_pkrvars/oraclelinux/oraclelinux-7-x86_64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "oracle" +os_name = "oraclelinux" os_version = "7.9" os_arch = "x86_64" iso_url = "http://mirrors.dotsrc.org/oracle-linux/OL7/u9/x86_64/OracleLinux-R7-U9-Server-x86_64-dvd.iso" diff --git a/os_pkrvars/oracle/oracle-8-aarch64.pkrvars.hcl b/os_pkrvars/oraclelinux/oraclelinux-8-aarch64.pkrvars.hcl similarity index 93% rename from os_pkrvars/oracle/oracle-8-aarch64.pkrvars.hcl rename to os_pkrvars/oraclelinux/oraclelinux-8-aarch64.pkrvars.hcl index 8656e267d..c04cf1f0e 100644 --- a/os_pkrvars/oracle/oracle-8-aarch64.pkrvars.hcl +++ b/os_pkrvars/oraclelinux/oraclelinux-8-aarch64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "oracle" +os_name = "oraclelinux" os_version = "8.9" os_arch = "aarch64" iso_url = "https://yum.oracle.com/ISOS/OracleLinux/OL8/u9/aarch64/OracleLinux-R8-U9-aarch64-dvd.iso" diff --git a/os_pkrvars/oracle/oracle-8-x86_64.pkrvars.hcl b/os_pkrvars/oraclelinux/oraclelinux-8-x86_64.pkrvars.hcl similarity index 92% rename from os_pkrvars/oracle/oracle-8-x86_64.pkrvars.hcl rename to os_pkrvars/oraclelinux/oraclelinux-8-x86_64.pkrvars.hcl index af05d8767..499533fd4 100644 --- a/os_pkrvars/oracle/oracle-8-x86_64.pkrvars.hcl +++ b/os_pkrvars/oraclelinux/oraclelinux-8-x86_64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "oracle" +os_name = "oraclelinux" os_version = "8.9" os_arch = "x86_64" iso_url = "https://yum.oracle.com/ISOS/OracleLinux/OL8/u9/x86_64/OracleLinux-R8-U9-x86_64-dvd.iso" diff --git a/os_pkrvars/oracle/oracle-9-aarch64.pkrvars.hcl b/os_pkrvars/oraclelinux/oraclelinux-9-aarch64.pkrvars.hcl similarity index 93% rename from os_pkrvars/oracle/oracle-9-aarch64.pkrvars.hcl rename to os_pkrvars/oraclelinux/oraclelinux-9-aarch64.pkrvars.hcl index 2357d748e..7d64a0a65 100644 --- a/os_pkrvars/oracle/oracle-9-aarch64.pkrvars.hcl +++ b/os_pkrvars/oraclelinux/oraclelinux-9-aarch64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "oracle" +os_name = "oraclelinux" os_version = "9.3" os_arch = "aarch64" iso_url = "https://yum.oracle.com/ISOS/OracleLinux/OL9/u3/aarch64/OracleLinux-R9-U3-aarch64-dvd.iso" diff --git a/os_pkrvars/oracle/oracle-9-x86_64.pkrvars.hcl b/os_pkrvars/oraclelinux/oraclelinux-9-x86_64.pkrvars.hcl similarity index 92% rename from os_pkrvars/oracle/oracle-9-x86_64.pkrvars.hcl rename to os_pkrvars/oraclelinux/oraclelinux-9-x86_64.pkrvars.hcl index b76944965..0aa28f6e1 100644 --- a/os_pkrvars/oracle/oracle-9-x86_64.pkrvars.hcl +++ b/os_pkrvars/oraclelinux/oraclelinux-9-x86_64.pkrvars.hcl @@ -1,4 +1,4 @@ -os_name = "oracle" +os_name = "oraclelinux" os_version = "9.3" os_arch = "x86_64" iso_url = "https://yum.oracle.com/ISOS/OracleLinux/OL9/u3/x86_64/OracleLinux-R9-U3-x86_64-dvd.iso" diff --git a/os_pkrvars/sles/sles-15-x86_64.pkrvars.hcl b/os_pkrvars/sles/sles-15-x86_64.pkrvars.hcl index 4d9b85d40..bf705c990 100644 --- a/os_pkrvars/sles/sles-15-x86_64.pkrvars.hcl +++ b/os_pkrvars/sles/sles-15-x86_64.pkrvars.hcl @@ -2,7 +2,7 @@ os_name = "suse" os_version = "15.5" os_arch = "x86_64" iso_url = "https://updates.suse.com/SUSE/Products/SLE-Product-SLES/15-SP5/x86_64/iso/SLE-15-SP5-Online-x86_64-GM-Media1.iso" -iso_checksum = "" +iso_checksum = "b0920189fd7f2624983a9cf8bc062bbb7a8557658e3feadde77b80e72f66b6ef" parallels_guest_os_type = "suse" vbox_guest_os_type = "SUSE_LE_64" vmware_guest_os_type = "sles15-64" diff --git a/packer_templates/http/ubuntu/user-data b/packer_templates/http/ubuntu/user-data index bd5b64355..d9393c65d 100644 --- a/packer_templates/http/ubuntu/user-data +++ b/packer_templates/http/ubuntu/user-data @@ -13,7 +13,7 @@ autoinstall: install-server: yes allow-pw: yes late-commands: - - sed -i 's/^#*\(send dhcp-client-identifier\).*$/\1 = hardware;/' /target/etc/dhcp/dhclient.conf + # - sed -i 's/^#*\(send dhcp-client-identifier\).*$/\1 = hardware;/' /target/etc/dhcp/dhclient.conf - 'sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml' - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/vagrant # Enable hyper-v daemons only if using hyper-v virtualization diff --git a/packer_templates/pkr-builder.pkr.hcl b/packer_templates/pkr-builder.pkr.hcl index 8111c87e4..66c797904 100644 --- a/packer_templates/pkr-builder.pkr.hcl +++ b/packer_templates/pkr-builder.pkr.hcl @@ -64,7 +64,7 @@ locals { "${path.root}/scripts/freebsd/cleanup_freebsd.sh", "${path.root}/scripts/freebsd/minimize_freebsd.sh" ] : ( - var.os_name == "opensuse" || + var.os_name == "opensuse-leap" || var.os_name == "sles" ? [ "${path.root}/scripts/suse/repositories_suse.sh", "${path.root}/scripts/suse/update_suse.sh", @@ -209,8 +209,10 @@ build { # Convert machines to vagrant boxes post-processor "vagrant" { - compression_level = 9 - output = "${path.root}/../builds/${var.os_name}-${var.os_version}-${var.os_arch}.{{ .Provider }}.box" - vagrantfile_template = var.is_windows ? "${path.root}/vagrantfile-windows.template" : null + compression_level = 9 + output = "${path.root}/../builds/${var.os_name}-${var.os_version}-${var.os_arch}.{{ .Provider }}.box" + vagrantfile_template = var.is_windows ? "${path.root}/vagrantfile-windows.template" : ( + var.os_name == "freebsd" ? "${path.root}/vagrantfile-freebsd.template" : null + ) } } diff --git a/packer_templates/pkr-variables.pkr.hcl b/packer_templates/pkr-variables.pkr.hcl index a09aca878..16ef20dd8 100644 --- a/packer_templates/pkr-variables.pkr.hcl +++ b/packer_templates/pkr-variables.pkr.hcl @@ -359,7 +359,7 @@ variable "ssh_port" { } variable "ssh_timeout" { type = string - default = "30m" + default = "15m" } variable "ssh_username" { type = string diff --git a/packer_templates/scripts/rhel/cleanup_yum.sh b/packer_templates/scripts/rhel/cleanup_yum.sh index abc88a934..22cf50b4d 100644 --- a/packer_templates/scripts/rhel/cleanup_yum.sh +++ b/packer_templates/scripts/rhel/cleanup_yum.sh @@ -19,9 +19,8 @@ package-cleanup --oldkernels --count=1 -y # Avoid ~200 meg firmware package we don't need # this cannot be done in the KS file so we do it here -if test "$(uname -r)" == -- *el7uek*; then - echo "Skipping firmware removal for Oracle Linux" -else +distro="$(rpm -qf --queryformat '%{NAME}' /etc/redhat-release | cut -f 1 -d '-')" +if [ "$distro" != 'oraclelinux' ]; then echo "Removing extra firmware packages" yum -y remove linux-firmware fi diff --git a/packer_templates/vagrantfile-windows.template b/packer_templates/vagrantfile-windows.template index 4a19e63d7..d6838e0e8 100644 --- a/packer_templates/vagrantfile-windows.template +++ b/packer_templates/vagrantfile-windows.template @@ -9,7 +9,6 @@ Vagrant.configure(2) do |config| config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true config.vm.provider "virtualbox" do |vb| - vb.gui = true vb.cpus = 2 vb.memory = 4096 end