Skip to content

Commit

Permalink
Merge pull request #84 from ElstonLewis/product_codes
Browse files Browse the repository at this point in the history
Restructured packer product_codes handling
  • Loading branch information
ElstonLewis authored Oct 14, 2024
2 parents c459203 + 9b5abcb commit b8a8f43
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
14 changes: 7 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def volume_size = "0"
def packer_script = "linux.pkr.hcl"
def script_base = ""
def iso_url = ""
def product_codes = "'0001'"
def product_codes = "0001"
switch(OS) {
case "Alma Linux 9":
base_name = "AlmaLinux-9"
Expand Down Expand Up @@ -80,40 +80,40 @@ switch(OS) {
case "Windows Server 2019":
base_name = "WindowsServer-2019"
packer_script = "windows.pkr.hcl"
product_codes = "'0002'"
product_codes = "0002"
break

case "Windows Server 2019 SQL Server Web 2019":
base_name = "WindowsServer-2019-MSSQL-Web2019"
packer_script = "windows-sql.pkr.hcl"
iso_url = "https://oos.eu-west-2.outscale.com/omi/iso/SW_DVD9_SQL_Svr_Web_Ed_2019Dec2019_64Bit_English_MLF_X22-22250.ISO"
product_codes = "'0002','0007'"
product_codes = "0002,0007"
break

case "Windows Server 2019 SQL Standard 2019":
base_name = "WindowsServer-2019-MSSQL-Std2019"
packer_script = "windows-sql.pkr.hcl"
iso_url = "https://oos.eu-west-2.outscale.com/omi/iso/SW_DVD9_NTRL_SQL_Svr_Standard_Edtn_2019Dec2019_64Bit_English_OEM_VL_X22-22109.ISO"
product_codes = "'0002','0008'"
product_codes = "0002,0008"
break

case "Windows Server 2019 SQL Enterprise 2019":
base_name = "WindowsServer-2019-MSSQL-Ent2019"
packer_script = "windows-sql.pkr.hcl"
iso_url = "https://oos.eu-west-2.outscale.com/omi/iso/SW_DVD9_NTRL_SQL_Svr_Ent_Core_2019Dec2019_64Bit_English_OEM_VL_X22-22120.ISO"
product_codes = "'0002','0009'"
product_codes = "0002,0009"
break

case "Windows 10":
base_name = "Windows-10"
packer_script = "windows.pkr.hcl"
product_codes = "'0002'"
product_codes = "0002"
break

case "Windows Server 2022":
base_name = "WindowsServer-2022"
packer_script = "windows.pkr.hcl"
product_codes = "'0002'"
product_codes = "0002"
break
}

Expand Down
14 changes: 7 additions & 7 deletions JenkinsfileMKP
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def volume_size = "0"
def packer_script = "linux.pkr.hcl"
def script_base = ""
def iso_url = ""
def product_codes = "'0001'"
def product_codes = "0001"
switch(OS) {
case "Alma Linux 9":
base_name = "AlmaLinux-9"
Expand Down Expand Up @@ -80,40 +80,40 @@ switch(OS) {
case "Windows Server 2019":
base_name = "WindowsServer-2019"
packer_script = "windows.pkr.hcl"
product_codes = "'0002'"
product_codes = "0002"
break

case "Windows Server 2019 SQL Server Web 2019":
base_name = "WindowsServer-2019-MSSQL-Web2019"
packer_script = "windows-sql.pkr.hcl"
iso_url = "https://oos.eu-west-2.outscale.com/omi/iso/SW_DVD9_SQL_Svr_Web_Ed_2019Dec2019_64Bit_English_MLF_X22-22250.ISO"
product_codes = "'0002'0007'"
product_codes = "0002,0007"
break

case "Windows Server 2019 SQL Standard 2019":
base_name = "WindowsServer-2019-MSSQL-Std2019"
packer_script = "windows-sql.pkr.hcl"
iso_url = "https://oos.eu-west-2.outscale.com/omi/iso/SW_DVD9_NTRL_SQL_Svr_Standard_Edtn_2019Dec2019_64Bit_English_OEM_VL_X22-22109.ISO"
product_codes = "'0002'0008'"
product_codes = "0002,0008"
break

case "Windows Server 2019 SQL Enterprise 2019":
base_name = "WindowsServer-2019-MSSQL-Ent2019"
packer_script = "windows-sql.pkr.hcl"
iso_url = "https://oos.eu-west-2.outscale.com/omi/iso/SW_DVD9_NTRL_SQL_Svr_Ent_Core_2019Dec2019_64Bit_English_OEM_VL_X22-22120.ISO"
product_codes = "'0002','0009'"
product_codes = "0002,0009"
break

case "Windows 10":
base_name = "Windows-10"
packer_script = "windows.pkr.hcl"
product_codes = "'0002'"
product_codes = "0002"
break

case "Windows Server 2022":
base_name = "WindowsServer-2022"
packer_script = "windows.pkr.hcl"
product_codes = "'0002'"
product_codes = "0002"
break
}

Expand Down
5 changes: 2 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fi
# Clean up old packer plugins before installing required
#/bin/packer plugins installed | xargs -n1 packer plugins remove

#echo "executing /bin/packer init -upgrade ./config.pkr.hcl"
echo "executing /bin/packer init -upgrade ./config.pkr.hcl"
/bin/packer init -upgrade ./config.pkr.hcl

echo "packer env checks..."
Expand All @@ -46,8 +46,7 @@ else
unset PACKER_LOG
fi

#echo "executing /bin/packer build -debug ./$PACKER_SCRIPT | tee /usr/local/packer/logs/$UOMI_NAME.log"
/bin/packer build ./$PACKER_SCRIPT | tee /usr/local/packer/logs/$UOMI_NAME.log
/bin/packer build -var "product_codes=[\"${OUTSCALE_PRODUCT_CODES//,/\",\"}\"]" ./$PACKER_SCRIPT | tee /usr/local/packer/logs/$UOMI_NAME.log

# Workaround for bad Packer exit code
grep successful /usr/local/packer/logs/$UOMI_NAME.log > /dev/null
Expand Down
6 changes: 3 additions & 3 deletions linux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ variable "username" {
}

variable "product_codes" {
type = string
default = "${env("OUTSCALE_PRODUCT_CODES")}"
type = list(string)
default = []
}

source "outscale-bsusurrogate" "builder" {
Expand All @@ -52,7 +52,7 @@ source "outscale-bsusurrogate" "builder" {
ssh_interface = "public_ip"
ssh_username = "${var.username}"
vm_type = "tinav5.c2r4p1"
product_codes = ["${var.product_codes}"]
product_codes = "${var.product_codes}"
}

build {
Expand Down
8 changes: 5 additions & 3 deletions windows-sql.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ variable "volsize" {
}

variable "product_codes" {
type = string
default = "${env("OUTSCALE_PRODUCT_CODES")}"
type = list(string)
default = []
}

source "outscale-bsu" "windows" {
Expand All @@ -42,7 +42,7 @@ source "outscale-bsu" "windows" {
winrm_insecure = true
winrm_use_ssl = true
winrm_username = "Administrator"
product_codes = ["${var.product_codes}"]
product_codes = "${var.product_codes}"
}

build {
Expand All @@ -57,6 +57,7 @@ build {
destination = "C:\\Windows\\Outscale\\"
source = "files/windows/"
}
/*
provisioner "powershell" {
environment_vars = ["ISO_URL=${var.iso}"]
scripts = [
Expand All @@ -68,6 +69,7 @@ build {
]
}
provisioner "windows-update" {}
*/
provisioner "powershell" {
scripts = [ "scripts/windows/sysprep.ps1" ]
}
Expand Down
6 changes: 3 additions & 3 deletions windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ variable "volsize" {
}

variable "product_codes" {
type = string
default = "${env("OUTSCALE_PRODUCT_CODES")}"
type = list(string)
default = []
}

source "outscale-bsu" "windows" {
Expand All @@ -42,7 +42,7 @@ source "outscale-bsu" "windows" {
winrm_insecure = true
winrm_use_ssl = true
winrm_username = "Administrator"
product_codes = ["${var.product_codes}"]
product_codes = "${var.product_codes}"
}

build {
Expand Down

0 comments on commit b8a8f43

Please sign in to comment.