diff --git a/Jenkinsfile b/Jenkinsfile index e23d3b0..951480a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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" @@ -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 } diff --git a/JenkinsfileMKP b/JenkinsfileMKP index 609b5de..d4ae881 100644 --- a/JenkinsfileMKP +++ b/JenkinsfileMKP @@ -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" @@ -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 } diff --git a/build.sh b/build.sh index 5b4fe5f..c5078e3 100644 --- a/build.sh +++ b/build.sh @@ -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..." @@ -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 diff --git a/linux.pkr.hcl b/linux.pkr.hcl index e905e8a..7f54c54 100644 --- a/linux.pkr.hcl +++ b/linux.pkr.hcl @@ -28,8 +28,8 @@ variable "username" { } variable "product_codes" { - type = string - default = "${env("OUTSCALE_PRODUCT_CODES")}" + type = list(string) + default = [] } source "outscale-bsusurrogate" "builder" { @@ -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 { diff --git a/windows-sql.pkr.hcl b/windows-sql.pkr.hcl index 571b5c1..aab7d10 100644 --- a/windows-sql.pkr.hcl +++ b/windows-sql.pkr.hcl @@ -14,8 +14,8 @@ variable "volsize" { } variable "product_codes" { - type = string - default = "${env("OUTSCALE_PRODUCT_CODES")}" + type = list(string) + default = [] } source "outscale-bsu" "windows" { @@ -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 { @@ -57,6 +57,7 @@ build { destination = "C:\\Windows\\Outscale\\" source = "files/windows/" } +/* provisioner "powershell" { environment_vars = ["ISO_URL=${var.iso}"] scripts = [ @@ -68,6 +69,7 @@ build { ] } provisioner "windows-update" {} +*/ provisioner "powershell" { scripts = [ "scripts/windows/sysprep.ps1" ] } diff --git a/windows.pkr.hcl b/windows.pkr.hcl index c08a4aa..6357b74 100644 --- a/windows.pkr.hcl +++ b/windows.pkr.hcl @@ -14,8 +14,8 @@ variable "volsize" { } variable "product_codes" { - type = string - default = "${env("OUTSCALE_PRODUCT_CODES")}" + type = list(string) + default = [] } source "outscale-bsu" "windows" { @@ -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 {