Install packer on build agent - issue #280 (#295)

* create packer.sh deployment file

Copy from terraform.sh

* add packer.sh to provisioner

add packer.sh script to provisioner to install packer.

* add packer.sh to provisioner

Add packer.sh script to provisioner to install packer

* remove blank lines

removed blank lines as requested in feedback by alepauly.

* remove additional blank lines

* Add Install-Packer.ps1

This script installs packer on Windows through chocolatey

* Create Validate-Packer.ps1

This script validates the installation of Packer from Install-Packer.ps1 and adds the software details to the markdown files.

* Add Packer install and validate script

Added Packer install script and validate script to provisioners.

* Add Packer install script and validation script

Add Packer install and validation script to provisioners.
This commit is contained in:
Niels
2020-03-04 15:42:36 +01:00
committed by GitHub
parent 0c2643cb8d
commit c6bf6c3b7b
7 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#!/bin/bash
################################################################################
## File: packer.sh
## Desc: Installs packer
################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh
source $HELPER_SCRIPTS/apt.sh
# Install Packer
PACKER_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r .current_version)
curl -LO "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d /usr/local/bin
rm -f "packer_${PACKER_VERSION}_linux_amd64.zip"
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v packer; then
echo "Packer was not installed or found on PATH"
exit 1
fi
# Document what was added to the image
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Packer ($(packer --version))"

View File

@@ -166,6 +166,7 @@
"{{template_dir}}/scripts/installers/sphinx.sh",
"{{template_dir}}/scripts/installers/subversion.sh",
"{{template_dir}}/scripts/installers/terraform.sh",
"{{template_dir}}/scripts/installers/packer.sh",
"{{template_dir}}/scripts/installers/vcpkg.sh",
"{{template_dir}}/scripts/installers/zeit-now.sh",
"{{template_dir}}/scripts/installers/updatepath.sh",

View File

@@ -169,6 +169,7 @@
"{{template_dir}}/scripts/installers/sphinx.sh",
"{{template_dir}}/scripts/installers/subversion.sh",
"{{template_dir}}/scripts/installers/terraform.sh",
"{{template_dir}}/scripts/installers/packer.sh",
"{{template_dir}}/scripts/installers/vcpkg.sh",
"{{template_dir}}/scripts/installers/zeit-now.sh",
"{{template_dir}}/scripts/installers/updatepath.sh",

View File

@@ -282,6 +282,12 @@
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-7zip.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-Packer.ps1"
]
},
{
"type": "file",
@@ -777,6 +783,12 @@
"{{ template_dir }}/scripts/Installers/Validate-7zip.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Packer.ps1"
]
},
{
"type": "powershell",
"scripts":[

View File

@@ -252,6 +252,12 @@
"{{ template_dir }}/scripts/Installers/Install-7zip.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-Packer.ps1"
]
},
{
"type": "file",
"source": "{{template_dir}}/toolcache-2019.json",
@@ -745,6 +751,12 @@
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-7zip.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Packer.ps1"
]
},
{
"type": "powershell",

View File

@@ -0,0 +1,6 @@
################################################################################
## File: Install-Packer.ps1
## Desc: Install Packer
################################################################################
choco install packer -y

View File

@@ -0,0 +1,24 @@
################################################################################
## File: Validate-Packer.ps1
## Desc: Validate Packer
################################################################################
if (Get-Command -Name 'packer')
{
Write-Host "Packer is on path"
}
else
{
Write-Host 'Packer is not on path'
exit 1
}
# Adding description of the software to Markdown
$SoftwareName = "Packer"
$PackerVersion = (packer version).Split("")
$Description = @"
_Version:_ $PackerVersion.Item(1)<br/>
"@
Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description