From 9dfee89de38ee6a5a9883c21ef20a4ea32e67ce3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 18 Feb 2022 12:23:51 +0300 Subject: [PATCH] Remove .packer Signed-off-by: safinsaf --- .packer/README.md | 21 ---- .packer/win/files/packages.config | 12 --- .packer/win/scripts/SetUpDevTools.ps1 | 26 ----- .packer/win/scripts/SetUpWinRM.ps1 | 43 -------- .packer/win/scripts/vcpkg.ps1 | 25 ----- .../win/scripts/vcpkg_for_multiple_branch.ps1 | 38 ------- .packer/win/windows-build-server.json | 100 ------------------ 7 files changed, 265 deletions(-) delete mode 100644 .packer/README.md delete mode 100644 .packer/win/files/packages.config delete mode 100644 .packer/win/scripts/SetUpDevTools.ps1 delete mode 100644 .packer/win/scripts/SetUpWinRM.ps1 delete mode 100644 .packer/win/scripts/vcpkg.ps1 delete mode 100644 .packer/win/scripts/vcpkg_for_multiple_branch.ps1 delete mode 100644 .packer/win/windows-build-server.json diff --git a/.packer/README.md b/.packer/README.md deleted file mode 100644 index 7d9dcd95fb1..00000000000 --- a/.packer/README.md +++ /dev/null @@ -1,21 +0,0 @@ -## Quick Start -``` -cd win/ -packer build -var 'windows_password=' -var 'security_group_id=' -var 'iroha_repo=https://github.com/hyperledger/iroha.git' -var 'iroha_branches=main, support/1.1.x' windows-build-server.json -``` -Where : - -`security_group_id` - any aws security_group_id, what have RDP and WinRM ports open (3389/TCP, 5985 - 5986/TCP,) - -`windows_password` - password for Administrator user which will be created in ami. - -`iroha_repo` - Iroha repository - -`iroha_branches` - branches to use as source for building vcpkg - -## Description -This Packer template generates AWS AMI intended to use as on-demand agent in Jenkins jobs. -It installs Dev tools (e.g git, curl ...). -Any extra packages are left out for the sake of keeping AMI as clean and lightweight as possible. - -See available variables in `windows-build-server.json` diff --git a/.packer/win/files/packages.config b/.packer/win/files/packages.config deleted file mode 100644 index e0a1a9866e2..00000000000 --- a/.packer/win/files/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/.packer/win/scripts/SetUpDevTools.ps1 b/.packer/win/scripts/SetUpDevTools.ps1 deleted file mode 100644 index 4869bf40dda..00000000000 --- a/.packer/win/scripts/SetUpDevTools.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; - -# Install Chocolatey -iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) - -# Globally Auto confirm every action -choco feature enable -n allowGlobalConfirmation - -# Install all required dependencies with choco -choco install c:\Windows\Temp\packages.config - -# Make `refreshenv` available right away, by defining the $env:ChocolateyInstall -# variable and importing the Chocolatey profile module. -# Note: Using `. $PROFILE` instead *may* work, but isn't guaranteed to. -$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." -Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - -# Reload environment variables -refreshenv - -# Enable prepared transactions in PostgreSQL -$Env:PGPASSWORD='mysecretpassword'; 'ALTER SYSTEM SET max_prepared_transactions = 100;' | psql -Upostgres - -# Install Python packages -python -m pip install setuptools wheel -python -m pip install grpcio_tools pysha3 iroha==0.0.5.4 lxml diff --git a/.packer/win/scripts/SetUpWinRM.ps1 b/.packer/win/scripts/SetUpWinRM.ps1 deleted file mode 100644 index 6672c809531..00000000000 --- a/.packer/win/scripts/SetUpWinRM.ps1 +++ /dev/null @@ -1,43 +0,0 @@ - -write-output "Running User Data Script" -write-host "(host) Running User Data Script" - -Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore - -# Don't set this before Set-ExecutionPolicy as it throws an error -$ErrorActionPreference = "stop" - -# Remove HTTP listener -Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse - -Set-Item WSMan:\localhost\MaxTimeoutms 1800000 -Set-Item WSMan:\localhost\Service\Auth\Basic $true - -Enable-PSRemoting -force -Set-Item WSMan:\localhost\Client\trustedhosts -value * -force - -$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "packer" -New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force - -# WinRM -write-output "Setting up WinRM" -write-host "(host) setting up WinRM" - -cmd.exe /c winrm quickconfig -q -cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}' -cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="0"}' -cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}' -cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}' -cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}' -cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}' -#cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}' -cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTPS" "@{Port=`"5986`";Hostname=`"packer`";CertificateThumbprint=`"$($Cert.Thumbprint)`"}" -cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes -cmd.exe /c netsh firewall add portopening TCP 5986 "Port 5986" -cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" -cmd.exe /c netsh firewall add portopening TCP 445 "Port 445 SMB Jenkins" -Enable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart -cmd.exe /c net stop winrm -cmd.exe /c sc config winrm start= auto -cmd.exe /c net start winrm - \ No newline at end of file diff --git a/.packer/win/scripts/vcpkg.ps1 b/.packer/win/scripts/vcpkg.ps1 deleted file mode 100644 index 405aa441fbb..00000000000 --- a/.packer/win/scripts/vcpkg.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -param ( - [string]$vcpkg_path = "C:\vcpkg", - [string]$iroha_vcpkg_path = "C:\Windows\Temp\vcpkg" -) - -$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; - -echo "Cloning and setting up vcpkg" -git clone https://github.com/Microsoft/vcpkg.git $vcpkg_path - -echo "Checkout to commit" -git -C $vcpkg_path checkout (Get-Content -Path $iroha_vcpkg_path\VCPKG_COMMIT_SHA) - -echo "Apply patches to vcpkg" -foreach($file in Get-ChildItem $iroha_vcpkg_path\patches -Filter *.patch) { git -C $vcpkg_path apply --ignore-whitespace $file.FullName } - -echo "Run bootstrap-vcpkg.bat" -Invoke-Expression "$vcpkg_path\bootstrap-vcpkg.bat" - -echo "Installing vcpkg packages" -Invoke-Expression "$vcpkg_path\vcpkg.exe install --triplet x64-windows (Get-Content -Path $iroha_vcpkg_path\VCPKG_DEPS_LIST)" -#Invoke-Expression "$vcpkg_path\vcpkg.exe install --triplet x64-windows --head (Get-Content -Path $iroha_vcpkg_path\VCPKG_HEAD_DEPS_LIST)" - -echo "Run vcpkg.exe integrate install" -Invoke-Expression "$vcpkg_path\vcpkg.exe integrate install" diff --git a/.packer/win/scripts/vcpkg_for_multiple_branch.ps1 b/.packer/win/scripts/vcpkg_for_multiple_branch.ps1 deleted file mode 100644 index 3d4b11d25c6..00000000000 --- a/.packer/win/scripts/vcpkg_for_multiple_branch.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -# This script runs vcpkg.ps1 multiple time with different iroha branches -# It is very helpful then you need setup multiple vcpkg on windows build agent, -# for example build main and develop from one ami - -param( - [string] $iroha_repo = "https://github.com/hyperledger/iroha.git", - [array] $branches = "main" -) -$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; - -$tmp_iroha_dir = "C:\Windows\Temp\iroha" - -echo "Cloning Iroha" -git clone $iroha_repo $tmp_iroha_dir - -ForEach ($branch in $branches ) { - echo "Checkout to branch: $branch" - git -C $tmp_iroha_dir checkout $branch - - $vcpkg_path = "c:\vcpkg-$(python C:\Windows\Temp\hash.py $tmp_iroha_dir\vcpkg)" - - if (!(Test-Path $vcpkg_path)) { - # logging - Add-Content c:\\vcpkg-map.txt "\$(Get-Date): $branch start build ${vcpkg_path}..." - - echo "Start vcpkg.ps1 script" - C:\Windows\Temp\scripts\vcpkg.ps1 -vcpkg_path $vcpkg_path -iroha_vcpkg_path "${tmp_iroha_dir}\vcpkg" - - echo "vcpkg.ps1 script finished" - Add-Content c:\\vcpkg-map.txt "\$(Get-Date): $branch finish build ${vcpkg_path}" - } - else { echo "$vcpkg_path already exists" } - -} - -echo "Remove Iroha tmp dir" -Remove-Item $tmp_iroha_dir -Recurse -Force - diff --git a/.packer/win/windows-build-server.json b/.packer/win/windows-build-server.json deleted file mode 100644 index 36cab89846d..00000000000 --- a/.packer/win/windows-build-server.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "variables": { - "aws_access_key": "", - "aws_secret_key": "", - "instance_type": "c5.2xlarge", - "security_group_id": "", - "windows_password": "", - "iroha_repo": "", - "iroha_branches": "" - }, - "builders": [ - { - "force_deregister": true, - "force_delete_snapshot": true, - "type": "amazon-ebs", - "access_key": "{{user `aws_access_key`}}", - "secret_key": "{{user `aws_secret_key`}}", - "region": "eu-west-1", - "instance_type": "{{user `instance_type`}}", - "source_ami_filter": { - "filters": { - "name": "Windows_Server-2019-English-Full-Base-*" - }, - "owners": ["801119661308"], - "most_recent": true - }, - "ami_name": "packer-jenkins-win-slave-iroha", - "security_group_id": "{{user `security_group_id`}}", - "user_data_file": "./scripts/SetUpWinRM.ps1", - "communicator": "winrm", - "winrm_username": "Administrator", - "winrm_use_ssl": true, - "winrm_insecure": true, - "launch_block_device_mappings": [ - { - "device_name": "/dev/sda1", - "volume_size": 240, - "volume_type": "gp2", - "delete_on_termination": true - } - ], - "tags": { - "Name": "ami-packer-jenkins-win-slave-iroha", - "Project": "iroha", - "Environment": "dev", - "Base_AMI_Name": "{{ .SourceAMIName }}" - } - } - ], - "provisioners": [ - { - "type": "file", - "sources": [ - "./files/packages.config", - "../../.jenkinsci/helpers/hash.py", - "./scripts" - ], - "destination": "C:\\Windows\\Temp\\" - }, - { - "type": "powershell", - "scripts": [ - "./scripts/SetUpDevTools.ps1" - ], - "valid_exit_codes": [0, 3010] - }, - { - "type": "windows-restart" - }, - { - "type": "powershell", - "inline": [ - "C:\\Windows\\Temp\\scripts\\vcpkg_for_multiple_branch.ps1 {{user `iroha_repo`}} {{user `iroha_branches`}}", - "dir c:\\" - ] - }, - { - "type": "powershell", - "inline": [ - "$launchConfig = Get-Content -Path C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Config\\LaunchConfig.json | ConvertFrom-Json", - "$launchConfig.adminPasswordType = 'Specify'", - "$launchConfig.adminPassword = '{{user `windows_password`}}'", - "$launchConfig", - "Set-Content -Value ($launchConfig | ConvertTo-Json) -Path C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Config\\LaunchConfig.json" - ] - }, - { - "type": "powershell", - "inline": [ - "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule", - "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown" - ] - } - ], "post-processors": [ - { - "type": "manifest" - } - ] -} -