From 284f070fd68209ce7d02cb3e2806eeaf946a1a67 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Tue, 23 Jun 2020 21:26:24 +0200 Subject: [PATCH 01/10] Add Travis CI script --- .travis.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..6aabf827a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,46 @@ +sudo: true +language: bash +dist: bionic + +jobs: + include: + - env: PROVIDER=qemu TEMPLATE=windows_7 VIRT_GROUP=kvm + +install: +# Install Packer. Travis ships with Packer 1.3, which is fairly old +- wget -nv -nc -O packer_1.6.0_linux_amd64.zip https://releases.hashicorp.com/packer/1.6.0/packer_1.6.0_linux_amd64.zip +- sudo unzip -o packer_1.6.0_linux_amd64.zip -d /usr/local/bin + +# Install ansible +- sudo add-apt-repository -y ppa:ansible/ansible +- sudo apt-get update +- sudo apt-get install -yq --no-install-suggests --no-install-recommends ansible +- pip install pywinrm + +# Install qemu-kvm +- if [ $PROVIDER == "qemu" ]; then sudo apt-get install -yq --no-install-suggests --no-install-recommends qemu-kvm qemu-utils; fi + +# Set up group membership +- sudo adduser $USER $VIRT_GROUP + +# Dump versions of available software +- lsb_release -a +- uname -r +- if [ $PROVIDER == "qemu" ]; then qemu-system-x86_64 --version; fi +- packer --version +- ansible --version + +# Dump group membership +- groups +- sudo sudo -u $USER -g $VIRT_GROUP groups +- sudo -E su $USER -c 'groups' + +# Dump CPU information +- cat /proc/cpuinfo + +script: +# Download the virtio-win iso +- wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O ~/virtio-win.iso +- export PACKER_LOG=1 +# See here https://github.com/travis-ci/travis-ci/issues/1839 for background on the sudo sudo command +- sudo -E su $USER -c 'packer build --only=${PROVIDER} --var virtio_win_iso=~/virtio-win.iso ${TEMPLATE}.json' \ No newline at end of file From bb0b039a5bfd828ee90befa1b5bf526bccea06b5 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Fri, 26 Jun 2020 17:11:55 +0200 Subject: [PATCH 02/10] Build VirtualBox image in Azure --- .azure-pipelines.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .azure-pipelines.yml diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml new file mode 100644 index 000000000..4d6dc61e7 --- /dev/null +++ b/.azure-pipelines.yml @@ -0,0 +1,39 @@ +jobs: +- job: build + pool: + vmImage: 'macOS-10.15' + timeoutInMinutes: 300 + strategy: + maxParallel: 4 + matrix: + windows_7: + template: windows_7 + steps: + - bash: | + wget -nv -nc -O packer_1.6.0_darwin_amd64.zip https://releases.hashicorp.com/packer/1.6.0/packer_1.6.0_darwin_amd64.zip + sudo unzip -o packer_1.6.0_darwin_amd64.zip -d /usr/local/bin + displayName: Install Packer + - bash: | + pip install --user ansible + pip install pywinrm + ln -s /Users/runner/Library/Python/2.7/bin/ansible /usr/local/bin/ansible + ln -s /Users/runner/Library/Python/2.7/bin/ansible-playbook /usr/local/bin/ansible-playbook + displayName: Install Ansible + - bash: | + packer --version + ansible --version + ansible-playbook --version + vboxmanage --version + sysctl -a | grep machdep.cpu + sysctl -a | grep mem + df -h . + displayName: Dump software version + - bash: | + wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O $(Agent.BuildDirectory)/virtio-win.iso + displayName: Download virtio-win iso + - bash: | + # Set PACKER_LOG to 1 to troubleshoot infrastructure issues + # export PACKER_LOG=1 + export PACKER_CACHE_DIR=$(Agent.BuildDirectory)/packer_cache/ + packer build --only=virtualbox-iso --var virtio_win_iso=$(Agent.BuildDirectory)/virtio-win.iso $(template).json + displayName: Build box \ No newline at end of file From e20656817059deab98d33723ecf7a092601fa33b Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Fri, 26 Jun 2020 19:35:40 +0200 Subject: [PATCH 03/10] Work around a possible Ansible bug --- .azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 4d6dc61e7..59bf38f0c 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -35,5 +35,8 @@ jobs: # Set PACKER_LOG to 1 to troubleshoot infrastructure issues # export PACKER_LOG=1 export PACKER_CACHE_DIR=$(Agent.BuildDirectory)/packer_cache/ + # See https://github.com/ansible/ansible/issues/49207 + # See https://github.com/ansible/ansible/issues/32499 + export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES packer build --only=virtualbox-iso --var virtio_win_iso=$(Agent.BuildDirectory)/virtio-win.iso $(template).json displayName: Build box \ No newline at end of file From f7a99476b5fa2fe0c35e7a9f2405e10244287022 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Fri, 26 Jun 2020 22:10:24 +0200 Subject: [PATCH 04/10] Build Windows 10, 6 GB memory and 30 GB disk space --- .azure-pipelines.yml | 9 +++------ .travis.yml | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 59bf38f0c..9f7a37337 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -6,8 +6,8 @@ jobs: strategy: maxParallel: 4 matrix: - windows_7: - template: windows_7 + windows_10: + template: windows_10 steps: - bash: | wget -nv -nc -O packer_1.6.0_darwin_amd64.zip https://releases.hashicorp.com/packer/1.6.0/packer_1.6.0_darwin_amd64.zip @@ -28,9 +28,6 @@ jobs: sysctl -a | grep mem df -h . displayName: Dump software version - - bash: | - wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O $(Agent.BuildDirectory)/virtio-win.iso - displayName: Download virtio-win iso - bash: | # Set PACKER_LOG to 1 to troubleshoot infrastructure issues # export PACKER_LOG=1 @@ -38,5 +35,5 @@ jobs: # See https://github.com/ansible/ansible/issues/49207 # See https://github.com/ansible/ansible/issues/32499 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - packer build --only=virtualbox-iso --var virtio_win_iso=$(Agent.BuildDirectory)/virtio-win.iso $(template).json + packer build --only=virtualbox-iso --var memory_size=6144 --var disk_size=30720 $(template).json displayName: Build box \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 6aabf827a..ad88015f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ dist: bionic jobs: include: - - env: PROVIDER=qemu TEMPLATE=windows_7 VIRT_GROUP=kvm + - env: PROVIDER=qemu TEMPLATE=windows_10 VIRT_GROUP=kvm install: # Install Packer. Travis ships with Packer 1.3, which is fairly old @@ -43,4 +43,4 @@ script: - wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O ~/virtio-win.iso - export PACKER_LOG=1 # See here https://github.com/travis-ci/travis-ci/issues/1839 for background on the sudo sudo command -- sudo -E su $USER -c 'packer build --only=${PROVIDER} --var virtio_win_iso=~/virtio-win.iso ${TEMPLATE}.json' \ No newline at end of file +- sudo -E su $USER -c 'packer build --only=${PROVIDER} --var virtio_win_iso=~/virtio-win.iso --var memory_size=6144 --var disk_size=30720 ${TEMPLATE}.json' \ No newline at end of file From 813ec6eb44c49c259d2980018cc14067bc821a04 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Thu, 25 Jun 2020 14:31:39 +0200 Subject: [PATCH 05/10] Keep stdout busy --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad88015f2..fd8b75d96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,8 +39,12 @@ install: - cat /proc/cpuinfo script: +# Ping stdout every 9 minutes to prevent Travis from terminating the buidl. +- | + while sleep 9m; do + echo "====[ This job has been running for $SECONDS ]====" + done & # Download the virtio-win iso - wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O ~/virtio-win.iso -- export PACKER_LOG=1 # See here https://github.com/travis-ci/travis-ci/issues/1839 for background on the sudo sudo command - sudo -E su $USER -c 'packer build --only=${PROVIDER} --var virtio_win_iso=~/virtio-win.iso --var memory_size=6144 --var disk_size=30720 ${TEMPLATE}.json' \ No newline at end of file From 500afc7f970eefcc9fabb355a6b99509a74046bb Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Tue, 19 Oct 2021 11:04:10 +0200 Subject: [PATCH 06/10] Bump packer verion Set PACKET_LOG to 1 --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd8b75d96..80b2fec7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,15 @@ sudo: true language: bash -dist: bionic +dist: focal jobs: include: - - env: PROVIDER=qemu TEMPLATE=windows_10 VIRT_GROUP=kvm + - env: PROVIDER=qemu TEMPLATE=windows_10 VIRT_GROUP=kvm PACKER_VERSION=1.7.6 PACKER_LOG=1 install: -# Install Packer. Travis ships with Packer 1.3, which is fairly old -- wget -nv -nc -O packer_1.6.0_linux_amd64.zip https://releases.hashicorp.com/packer/1.6.0/packer_1.6.0_linux_amd64.zip -- sudo unzip -o packer_1.6.0_linux_amd64.zip -d /usr/local/bin +# Install Packer. +- wget -nv -nc -O packer_${PACKER_VERSION}_linux_amd64.zip https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip +- sudo unzip -o packer_${PACKER_VERSION}_linux_amd64.zip -d /usr/local/bin # Install ansible - sudo add-apt-repository -y ppa:ansible/ansible From 604ae5bf914ff77d97ae142d4b373d0b46093dea Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Tue, 19 Oct 2021 11:33:16 +0200 Subject: [PATCH 07/10] Revert "Update windows_10.json" This reverts commit c94dccd06b77a152a160d1effecc3b16c5d5e499. --- windows_10.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/windows_10.json b/windows_10.json index 247975939..8a877056e 100644 --- a/windows_10.json +++ b/windows_10.json @@ -18,8 +18,7 @@ "./scripts/win-updates.ps1" ], "headless": true, - "iso_checksum": "{{user `iso_checksum`}}", - "iso_url": "{{user `iso_url`}}", + "iso_checksum": "{{user `iso_checksum`}}" "memory": "{{user `memory`}}", "output_directory": "windows_10-qemu", "qemuargs": [ From cf3141b2b89b47462dd041c419b63617cceb125b Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Tue, 19 Oct 2021 11:33:26 +0200 Subject: [PATCH 08/10] Revert "Update windows_10.json" This reverts commit 7cb37889c834b04c2bd8d4f1dd2b843f14c9ec1d. --- windows_10.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/windows_10.json b/windows_10.json index 8a877056e..aaf403f0c 100644 --- a/windows_10.json +++ b/windows_10.json @@ -18,7 +18,8 @@ "./scripts/win-updates.ps1" ], "headless": true, - "iso_checksum": "{{user `iso_checksum`}}" + "iso_checksum": "{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", "memory": "{{user `memory`}}", "output_directory": "windows_10-qemu", "qemuargs": [ @@ -26,10 +27,6 @@ "-drive", "file=windows_10-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1" ], - [ - "-drive", - "file={{ user `iso_url` }},media=cdrom,index=2" - ], [ "-drive", "file={{ user `virtio_win_iso` }},media=cdrom,index=3" From 6a3aed3172142be43cce52616016239528d590fe Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Tue, 19 Oct 2021 21:58:02 +0200 Subject: [PATCH 09/10] Use Packer 1.6.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 80b2fec7f..c0c6921ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ dist: focal jobs: include: - - env: PROVIDER=qemu TEMPLATE=windows_10 VIRT_GROUP=kvm PACKER_VERSION=1.7.6 PACKER_LOG=1 + - env: PROVIDER=qemu TEMPLATE=windows_10 VIRT_GROUP=kvm PACKER_VERSION=1.6.0 PACKER_LOG=1 install: # Install Packer. From f2e0498cf80e99ca97d7cff8d642e745b1753a12 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Tue, 19 Oct 2021 23:30:10 +0200 Subject: [PATCH 10/10] Upload box to Azure storage --- .travis.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c0c6921ff..d7b024e4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,4 +47,13 @@ script: # Download the virtio-win iso - wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O ~/virtio-win.iso # See here https://github.com/travis-ci/travis-ci/issues/1839 for background on the sudo sudo command -- sudo -E su $USER -c 'packer build --only=${PROVIDER} --var virtio_win_iso=~/virtio-win.iso --var memory_size=6144 --var disk_size=30720 ${TEMPLATE}.json' \ No newline at end of file +- sudo -E su $USER -c 'packer build --only=${PROVIDER} --var virtio_win_iso=~/virtio-win.iso --var memory_size=6144 --var disk_size=30720 ${TEMPLATE}.json' + +after_success: +# Upload the resulting box to Azure Storage +- | + sha256sum ${TEMPLATE}_libvirt.box + az storage blob upload --auth-mode=key --account-name=${AZURE_STORAGE_ACCOUNT} --account-key=${AZURE_STORAGE_KEY} --container-name boxes --file ${TEMPLATE}_libvirt.box --name ${TRAVIS_JOB_ID}/${TEMPLATE}_libvirt.box + echo "The box has been uploaded to Azure Storage:" + echo "URL: https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/boxes/${TRAVIS_JOB_ID}/${TEMPLATE}_virtualbox.box" + echo "SHA256: `shasum -a 256 ${TEMPLATE}_virtualbox.box`"