From bbaa32a888b4def23a38832c4003d13c8f754e37 Mon Sep 17 00:00:00 2001 From: Salt Project Packaging Date: Fri, 29 Nov 2024 17:58:54 +0000 Subject: [PATCH 1/5] Update README.rst with 2024.11.29 release sha256sum --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 745b41917..cf80f3943 100644 --- a/README.rst +++ b/README.rst @@ -37,6 +37,7 @@ sum** of the downloaded ``bootstrap-salt.sh`` file. The SHA256 sum of the ``bootstrap-salt.sh`` file, per release, is: +- 2024.11.29: ``0ac87384dee051aceded69704485a5de0e4a308551a462b10c262111b57acff0`` - 2024.11.27: ``e972bd1ef01d09cd1d9294374ef974c9e3dd9a2aee37cf3859144585fd8bf1d0`` - 2024.11.26: ``832c7a20b96e1df171d715323df9afff8a11aef42d15598c007f240bc89d723c`` - 2024.11.21: ``ddf624c3a94d721da3f7629402a6c7ecc9dd96d13c1ead2a626314e97cee982a`` From c4fdafaef3bc5a435810a702c62c646d4701eb25 Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 4 Dec 2024 08:40:04 -0700 Subject: [PATCH 2/5] Fix quickstart for Windows with new repo --- salt-quick-start.ps1 | 251 ++++++++++++++++++++++++++++++------------- 1 file changed, 178 insertions(+), 73 deletions(-) diff --git a/salt-quick-start.ps1 b/salt-quick-start.ps1 index 16c705554..f6f79c724 100644 --- a/salt-quick-start.ps1 +++ b/salt-quick-start.ps1 @@ -1,39 +1,31 @@ -function Convert-PSObjectToHashtable { - param ( - [Parameter(ValueFromPipeline)] - $InputObject - ) - if ($null -eq $InputObject) { return $null } - - $is_enum = $InputObject -is [System.Collections.IEnumerable] - $not_string = $InputObject -isnot [string] - if ($is_enum -and $not_string) { - $collection = @( - foreach ($object in $InputObject) { - Convert-PSObjectToHashtable $object - } - ) +<# +.SYNOPSIS + A simple Powershell script to quickly start using Salt. - Write-Host -NoEnumerate $collection - } elseif ($InputObject -is [PSObject]) { - $hash = @{} +.DESCRIPTION + This script will download the latest onedir version of Salt and extract it + into the same directory where the script is run. The script sets up an + environment that will allow you to run salt-call commands. To remove, just + delete the `salt` directory. The environment variables will only be set for + the current powershell session. - foreach ($property in $InputObject.PSObject.Properties) { - $hash[$property.Name] = Convert-PSObjectToHashtable $property.Value - } +.EXAMPLE + ./salt-quick-start.ps1 - $hash - } else { - $InputObject - } -} +.LINK + Salt Bootstrap GitHub Project (script home) - https://github.com/saltstack/salt-bootstrap + Original Vagrant Provisioner Project - https://github.com/saltstack/salty-vagrant + Vagrant Project (utilizes this script) - https://github.com/mitchellh/vagrant + Salt Download Location - https://packages.broadcom.com/artifactory/saltproject-generic/windows/ + Salt Manual Install Directions (Windows) - https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/windows.html +#> + +# This is so the -Verbose parameter will work +[CmdletBinding()] param() function Expand-ZipFile { # Extract a zip file # - # Used by: - # - Install-SaltMinion - # # Args: # ZipFile (string): The file to extract # Destination (string): The location to extract to @@ -81,60 +73,151 @@ function Expand-ZipFile { Write-Debug "Finished unzipping '$ZipFile' to '$Destination'" } +function Get-FileHash { + # Get-FileHash is a built-in cmdlet in powershell 5+ but we need to support + # powershell 3. This will overwrite the powershell 5 commandlet only for + # this script. But it will provide the missing cmdlet for powershell 3 + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)] + [String] $Path, -[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls12' + [Parameter(Mandatory=$false)] + [ValidateSet( + "SHA1", + "SHA256", + "SHA384", + "SHA512", + # https://serverfault.com/questions/820300/ + # why-isnt-mactripledes-algorithm-output-in-powershell-stable + "MACTripleDES", # don't use + "MD5", + "RIPEMD160", + IgnoreCase=$true)] + [String] $Algorithm = "SHA256" + ) -$global:ProgressPreference = 'SilentlyContinue' + if ( !(Test-Path $Path) ) { + Write-Verbose "Invalid path for hashing: $Path" + return @{} + } -$RepoUrl = "https://repo.saltproject.io/salt/py3/onedir" + if ( (Get-Item -Path $Path) -isnot [System.IO.FileInfo]) { + Write-Verbose "Not a file for hashing: $Path" + return @{} + } -if ([IntPtr]::Size -eq 4) { - $arch = "x86" -} else { - $arch = "amd64" -} -$enc = [System.Text.Encoding]::UTF8 -try { - $response = Invoke-WebRequest -Uri "$RepoUrl/repo.json" -UseBasicParsing - if ($response.Content.GetType().Name -eq "Byte[]") { - $psobj = $enc.GetString($response.Content) | ConvertFrom-Json + $Path = Resolve-Path -Path $Path - } else { - $psobj = $response.Content | ConvertFrom-Json - } - $hash = Convert-PSObjectToHashtable $psobj -} catch { - Write-Host "repo.json not found at: $RepoUrl" - $hash = @{} -} -$searchVersion = "latest" -if ( $hash.Contains($searchVersion)) { - foreach ($item in $hash.($searchVersion).Keys) { - if ( $item.EndsWith(".zip") ) { - if ( $item.Contains($arch) ) { - $saltFileName = $hash.($searchVersion).($item).name - $saltVersion = $hash.($searchVersion).($item).version - $saltSha512 = $hash.($searchVersion).($item).SHA512 - } + Switch ($Algorithm) { + SHA1 { + $hasher = [System.Security.Cryptography.SHA1CryptoServiceProvider]::Create() + } + SHA256 { + $hasher = [System.Security.Cryptography.SHA256]::Create() + } + SHA384 { + $hasher = [System.Security.Cryptography.SHA384]::Create() + } + SHA512 { + $hasher = [System.Security.Cryptography.SHA512]::Create() + } + MACTripleDES { + $hasher = [System.Security.Cryptography.MACTripleDES]::Create() + } + MD5 { + $hasher = [System.Security.Cryptography.MD5]::Create() + } + RIPEMD160 { + $hasher = [System.Security.Cryptography.RIPEMD160]::Create() } } -} -if ( $saltFileName -and $saltVersion -and $saltSha512 ) { - if ( $RepoUrl.Contains("minor") ) { - $saltFileUrl = @($RepoUrl, $saltVersion, $saltFileName) -join "/" - } else { - $saltFileUrl = @($RepoUrl, "minor", $saltVersion, $saltFileName) -join "/" + + Write-Verbose "Hashing using $Algorithm algorithm" + try { + $data = [System.IO.File]::OpenRead($Path) + $hash = $hasher.ComputeHash($data) + $hash = [System.BitConverter]::ToString($hash) -replace "-","" + return @{ + Path = $Path; + Algorithm = $Algorithm.ToUpper(); + Hash = $hash + } + } catch { + Write-Verbose "Error hashing: $Path" + Write-Verbose "ERROR: $_" + return @{} + } finally { + if ($null -ne $data) { + $data.Close() + } } } -Write-Host "* INFO: Downloading Salt" +#=============================================================================== +# Script settings +#=============================================================================== +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls12' +$global:ProgressPreference = 'SilentlyContinue' + +#=============================================================================== +# Declare Variables +#=============================================================================== +$ApiUrl = "https://packages.broadcom.com/artifactory/api/storage/saltproject-generic/onedir" +# Detect architecture ($arch) +if ([IntPtr]::Size -eq 4) { $arch = "x86" } else { $arch = "amd64" } + +#=============================================================================== +# Setting up quickstart environment +#=============================================================================== +Write-Host "" +Write-Host "Setting up quickstart environment for Salt" -ForegroundColor Cyan + +Write-Verbose "Getting version information from Artifactory" +$response = Invoke-WebRequest $ApiUrl -UseBasicParsing +# Convert the output to a powershell object +$psobj = $response.ToString() | ConvertFrom-Json +$Version = $psobj.children[-1].uri.Trim("/") + +Write-Verbose "Getting sha256 hash and download url from Artifactory" +$saltFileName = "salt-$Version-onedir-windows-$arch.zip" +$response = Invoke-WebRequest "$ApiUrl/$Version/$saltFileName" -UseBasicParsing +$psobj = $response.ToString() | ConvertFrom-Json +$saltFileUrl = $psobj.downloadUri +$saltSha256 = $psobj.checksums.sha256 + +Write-Verbose "URL: $saltFileUrl" +Write-Host "* INFO: Downloading Salt: " -NoNewline Invoke-WebRequest -Uri $saltFileUrl -OutFile .\salt.zip +if ( Test-Path -Path .\salt.zip ) { + Write-Host "Success" -ForegroundColor Green +} else { + Write-Host "Failed" -ForegroundColor Red + exit 1 +} +$localSha256 = (Get-FileHash -Path .\salt.zip -Algorithm SHA256).Hash +Write-Verbose "Local Hash: $localSha256" +Write-Verbose "Remote Hash: $saltSha256" + +Write-Host "* INFO: Comparing Hash: " -NoNewline +if ( $localSha256 -eq $saltSha256 ) { + Write-Host "Success" -ForegroundColor Green +} else { + Write-Host "Failed" -ForegroundColor Red + exit 1 +} -Write-Host "* INFO: Extracting Salt" +Write-Host "* INFO: Extracting Salt: " -NoNewline Expand-ZipFile -ZipFile .\salt.zip -Destination . +if ( Test-Path -Path .\salt\Scripts\python.exe ) { + Write-Host "Success" -ForegroundColor Green +} else { + Write-Host "Failed" -ForegroundColor Red + exit 1 +} +Write-Host "* INFO: Creating Saltfile: " -NoNewline $PATH = $(Get-Location).Path - $saltfile_contents = @" salt-call: local: True @@ -143,20 +226,42 @@ salt-call: cachedir: $PATH\salt\var\cache\salt file_root: $PATH\salt\srv\salt "@ - Set-Content -Path .\salt\Saltfile -Value $saltfile_contents +if ( Test-Path -Path .\salt\Saltfile ) { + Write-Host "Success" -ForegroundColor Green +} else { + Write-Host "Failed" -ForegroundColor Red + exit 1 +} New-Item -Path "$PATH\salt\var\log\salt" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\conf" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\var\cache\salt" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\srv\salt" -Type Directory -Force | Out-Null -Write-Host "* INFO: Adding Salt to current path" -Write-Host "* INFO: $PATH\salt" +Write-Host "* INFO: Adding Salt to current path: " -NoNewline $env:Path = "$PATH\salt;$env:PATH" +Write-Verbose $env:Path +if ( $env:PATH -Like "*$PATH\salt*" ) { + Write-Host "Success" -ForegroundColor Green +} else { + Write-Host "Failed" -ForegroundColor Red + exit 1 +} +Write-Host "* INFO: $PATH\salt" -Write-Host "* INFO: Setting the SALT_SALTFILE environment variable" -Write-Host "* INFO: $PATH\salt\Saltfile" +Write-Host "* INFO: Setting the SALT_SALTFILE environment variable: "-NoNewline $env:SALT_SALTFILE="$PATH\salt\Saltfile" +if ( Test-Path -Path $env:SALT_SALTFILE ) { + Write-Host "Success" -ForegroundColor Green +} else { + Write-Host "Failed" -ForegroundColor Red + exit 1 +} +Write-Host "* INFO: $PATH\salt\Saltfile" +Write-Host "" +Write-Host "You can now run simple salt-call commands" -ForegroundColor Cyan Write-Host "* INFO: Create Salt states in $PATH\salt\srv\salt" +Write-Host "* INFO: Try running salt-call test.ping" +Write-Host "" From 1b98100152462314aa4c75c64314f1dabb6eae9c Mon Sep 17 00:00:00 2001 From: David Murphy Date: Wed, 4 Dec 2024 09:51:13 -0700 Subject: [PATCH 3/5] Removed unused variable --- bootstrap-salt.sh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 49c71d3cd..06a8355a0 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -26,7 +26,7 @@ #====================================================================================================================== set -o nounset # Treat unset variables as an error -__ScriptVersion="2024.11.29" +__ScriptVersion="2024.12.03" __ScriptName="bootstrap-salt.sh" __ScriptFullName="$0" @@ -6634,36 +6634,39 @@ __ZYPPER_REQUIRES_REPLACE_FILES=-1 __set_suse_pkg_repo() { - # Set distro repo variable - if [ "${DISTRO_MAJOR_VERSION}" -gt 2015 ]; then - DISTRO_REPO="openSUSE_Tumbleweed" - elif [ "${DISTRO_MAJOR_VERSION}" -eq 15 ] && [ "${DISTRO_MINOR_VERSION}" -ge 4 ]; then - DISTRO_REPO="${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}" - elif [ "${DISTRO_MAJOR_VERSION}" -ge 42 ] || [ "${DISTRO_MAJOR_VERSION}" -eq 15 ]; then - DISTRO_REPO="openSUSE_Leap_${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}" - else - DISTRO_REPO="SLE_${DISTRO_MAJOR_VERSION}_SP${SUSE_PATCHLEVEL}" - fi + ## DGM # Set distro repo variable + ## DGM if [ "${DISTRO_MAJOR_VERSION}" -gt 2015 ]; then + ## DGM DISTRO_REPO="openSUSE_Tumbleweed" + ## DGM elif [ "${DISTRO_MAJOR_VERSION}" -eq 15 ] && [ "${DISTRO_MINOR_VERSION}" -ge 4 ]; then + ## DGM DISTRO_REPO="${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}" + ## DGM elif [ "${DISTRO_MAJOR_VERSION}" -ge 42 ] || [ "${DISTRO_MAJOR_VERSION}" -eq 15 ]; then + ## DGM DISTRO_REPO="openSUSE_Leap_${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}" + ## DGM else + ## DGM DISTRO_REPO="SLE_${DISTRO_MAJOR_VERSION}_SP${SUSE_PATCHLEVEL}" + ## DGM fi - suse_pkg_url_base="https://download.opensuse.org/repositories/systemsmanagement:/saltstack" - suse_pkg_url_path="${DISTRO_REPO}/systemsmanagement:saltstack.repo" - SUSE_PKG_URL="$suse_pkg_url_base/$suse_pkg_url_path" + ## DGM suse_pkg_url_base="https://download.opensuse.org/repositories/systemsmanagement:/saltstack" + ## DGM suse_pkg_url_path="${DISTRO_REPO}/systemsmanagement:saltstack.repo" + ## DGM SUSE_PKG_URL="$suse_pkg_url_base/$suse_pkg_url_path" + SUSE_PKG_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo" } __check_and_refresh_suse_pkg_repo() { # Check to see if systemsmanagement_saltstack exists - __zypper repos | grep -q systemsmanagement_saltstack + ## DGM __zypper repos | grep -q systemsmanagement_saltstack + __zypper repos | grep -q 'salt.repo' if [ $? -eq 1 ]; then - # zypper does not yet know anything about systemsmanagement_saltstack + ## DGM # zypper does not yet know anything about systemsmanagement_saltstack + # zypper does not yet know anything about salt.repo __zypper addrepo --refresh "${SUSE_PKG_URL}" || return 1 fi } __version_lte() { - if ! __check_command_exists python; then - zypper --non-interactive install --replacefiles --auto-agree-with-licenses python || \ - zypper --non-interactive install --auto-agree-with-licenses python || return 1 + if ! __check_command_exists python3; then + zypper --non-interactive install --replacefiles --auto-agree-with-licenses python3 || \ + zypper --non-interactive install --auto-agree-with-licenses python3 || return 1 fi if [ "$(${_PY_EXE} -c 'import sys; V1=tuple([int(i) for i in sys.argv[1].split(".")]); V2=tuple([int(i) for i in sys.argv[2].split(".")]); print(V1<=V2)' "$1" "$2")" = "True" ]; then From 644dfd1c57d20defdb8ded1c546675c3358081c5 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Mon, 9 Dec 2024 13:59:19 -0700 Subject: [PATCH 4/5] Updates to correctly support SLES 15 (sled), with allowance for minor versions --- bootstrap-salt.sh | 227 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 183 insertions(+), 44 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 06a8355a0..0a6398d75 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -26,7 +26,7 @@ #====================================================================================================================== set -o nounset # Treat unset variables as an error -__ScriptVersion="2024.12.03" +__ScriptVersion="2024.12.09" __ScriptName="bootstrap-salt.sh" __ScriptFullName="$0" @@ -3053,8 +3053,9 @@ __install_saltstack_ubuntu_onedir_repository() { echo "Pin: version $ONEDIR_REV.*" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001 - echo "Pin: version $ONEDIR_REV" >> /etc/apt/preferences.d/salt-pin-1001 + echo "Pin: version $ONEDIR_REV_DOT" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 fi fi @@ -3506,8 +3507,10 @@ __install_saltstack_debian_repository() { echo "Pin: version $STABLE_REV.*" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then + STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./') + MINOR_VER_STRG="-$STABLE_REV_DOT" echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001 - echo "Pin: version $STABLE_REV" >> /etc/apt/preferences.d/salt-pin-1001 + echo "Pin: version $STABLE_REV_DOT" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 fi fi @@ -3549,8 +3552,9 @@ __install_saltstack_debian_onedir_repository() { echo "Pin: version $ONEDIR_REV.*" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001 - echo "Pin: version $ONEDIR_REV" >> /etc/apt/preferences.d/salt-pin-1001 + echo "Pin: version $ONEDIR_REV_DOT" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 fi fi @@ -3895,9 +3899,10 @@ __install_saltstack_fedora_onedir_repository() { fi elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # using minor version - echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}" # shellcheck disable=SC2129 - echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" + echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}" @@ -4140,7 +4145,8 @@ install_fedora_onedir() { MINOR_VER_STRG="" elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # Minor version Salt, need to add specific minor version - MINOR_VER_STRG="-$STABLE_REV" + STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./') + MINOR_VER_STRG="-$STABLE_REV_DOT" else MINOR_VER_STRG="" fi @@ -4223,9 +4229,10 @@ __install_saltstack_rhel_onedir_repository() { fi elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # using minor version - echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}" # shellcheck disable=SC2129 - echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" + echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}" @@ -4297,7 +4304,8 @@ install_centos_stable() { MINOR_VER_STRG="" elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # Minor version Salt, need to add specific minor version - MINOR_VER_STRG="-$STABLE_REV" + STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./') + MINOR_VER_STRG="-$STABLE_REV_DOT" else MINOR_VER_STRG="" fi @@ -4525,7 +4533,8 @@ install_centos_onedir() { MINOR_VER_STRG="" elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # Minor version Salt, need to add specific minor version - MINOR_VER_STRG="-$ONEDIR_REV" + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + MINOR_VER_STRG="-$ONEDIR_REV_DOT" else MINOR_VER_STRG="" fi @@ -5657,9 +5666,10 @@ install_amazon_linux_ami_2_deps() { fi elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # using minor version - echo "[salt-repo-${STABLE_REV}-lts]" > "${YUM_REPO_FILE}" + STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./') + echo "[salt-repo-${STABLE_REV_DOT}-lts]" > "${YUM_REPO_FILE}" # shellcheck disable=SC2129 - echo "name=Salt Repo for Salt v${STABLE_REV} LTS" >> "${YUM_REPO_FILE}" + echo "name=Salt Repo for Salt v${STABLE_REV_DOT} LTS" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}" @@ -5721,9 +5731,10 @@ install_amazon_linux_ami_2_onedir_deps() { fi elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # using minor version - echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}" # shellcheck disable=SC2129 - echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" + echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}" @@ -5873,9 +5884,10 @@ install_amazon_linux_ami_2023_onedir_deps() { fi elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # using minor version - echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}" # shellcheck disable=SC2129 - echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" + echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}" @@ -6286,8 +6298,9 @@ __install_saltstack_photon_onedir_repository() { fi elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # using minor version - echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" - echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}" + echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}" @@ -6582,7 +6595,8 @@ install_photon_onedir() { MINOR_VER_STRG="-$_GENERIC_PKG_VERSION" elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # Minor version Salt, need to add specific minor version - MINOR_VER_STRG="-$STABLE_REV" + STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./') + MINOR_VER_STRG="-$STABLE_REV_DOT" else # default to latest version Salt, config and repo already setup __get_packagesite_onedir_latest @@ -6632,34 +6646,78 @@ install_photon_onedir_post() { # __ZYPPER_REQUIRES_REPLACE_FILES=-1 -__set_suse_pkg_repo() { - - ## DGM # Set distro repo variable - ## DGM if [ "${DISTRO_MAJOR_VERSION}" -gt 2015 ]; then - ## DGM DISTRO_REPO="openSUSE_Tumbleweed" - ## DGM elif [ "${DISTRO_MAJOR_VERSION}" -eq 15 ] && [ "${DISTRO_MINOR_VERSION}" -ge 4 ]; then - ## DGM DISTRO_REPO="${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}" - ## DGM elif [ "${DISTRO_MAJOR_VERSION}" -ge 42 ] || [ "${DISTRO_MAJOR_VERSION}" -eq 15 ]; then - ## DGM DISTRO_REPO="openSUSE_Leap_${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}" - ## DGM else - ## DGM DISTRO_REPO="SLE_${DISTRO_MAJOR_VERSION}_SP${SUSE_PATCHLEVEL}" - ## DGM fi - - ## DGM suse_pkg_url_base="https://download.opensuse.org/repositories/systemsmanagement:/saltstack" - ## DGM suse_pkg_url_path="${DISTRO_REPO}/systemsmanagement:saltstack.repo" - ## DGM SUSE_PKG_URL="$suse_pkg_url_base/$suse_pkg_url_path" - SUSE_PKG_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo" -} __check_and_refresh_suse_pkg_repo() { # Check to see if systemsmanagement_saltstack exists - ## DGM __zypper repos | grep -q systemsmanagement_saltstack __zypper repos | grep -q 'salt.repo' if [ $? -eq 1 ]; then - ## DGM # zypper does not yet know anything about systemsmanagement_saltstack # zypper does not yet know anything about salt.repo - __zypper addrepo --refresh "${SUSE_PKG_URL}" || return 1 + # zypper does not support exclude similar to Photon, hence have to do following + ZYPPER_REPO_FILE="/etc/zypp/repos.d/salt.repo" + # shellcheck disable=SC2129 + if [ "$ONEDIR_REV" != "latest" ]; then + # 3006.x is default, and latest for 3006.x branch + if [ "$(echo "$ONEDIR_REV" | grep -E '^(3006|3007)$')" != "" ]; then + # latest version for branch 3006 | 3007 + REPO_REV_MAJOR=$(echo "$ONEDIR_REV" | cut -d '.' -f 1) + if [ "$REPO_REV_MAJOR" -eq "3007" ]; then + # Enable the Salt 3007 STS repo + echo "[salt-repo-3007-sts]" > "${ZYPPER_REPO_FILE}" + echo "name=Salt Repo for Salt v3007 STS" >> "${ZYPPER_REPO_FILE}" + echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}" + echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}" + echo "priority=10" >> "${ZYPPER_REPO_FILE}" + echo "enabled=1" >> "${ZYPPER_REPO_FILE}" + echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}" + echo "exclude=*3006* *3008* *3009* *3010*" >> "${ZYPPER_REPO_FILE}" + echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}" + echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}" + zypper addlock "salt-* < 3007" && zypper addlock "salt-* >= 3008" + else + # Salt 3006 repo + echo "[salt-repo-3006-lts]" > "${ZYPPER_REPO_FILE}" + echo "name=Salt Repo for Salt v3006 LTS" >> "${ZYPPER_REPO_FILE}" + echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}" + echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}" + echo "priority=10" >> "${ZYPPER_REPO_FILE}" + echo "enabled=1" >> "${ZYPPER_REPO_FILE}" + echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}" + echo "exclude=*3007* *3008* *3009* *3010*" >> "${ZYPPER_REPO_FILE}" + echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}" + echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}" + zypper addlock "salt-* < 3006" && zypper addlock "salt-* >= 3007" + fi + elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then + # using minor version + ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./') + echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${ZYPPER_REPO_FILE}" + echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${ZYPPER_REPO_FILE}" + echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}" + echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}" + echo "priority=10" >> "${ZYPPER_REPO_FILE}" + echo "enabled=1" >> "${ZYPPER_REPO_FILE}" + echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}" + echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}" + echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}"a + ONEDIR_MAJ_VER=$(echo "${ONEDIR_REV_DOT}" | awk -F '.' '{print $1}') + # shellcheck disable=SC2004 + ONEDIR_MAJ_VER_PLUS=$((${ONEDIR_MAJ_VER} + 1)) + zypper addlock "salt-* < ${ONEDIR_MAJ_VER}" && zypper addlock "salt-* >= ${ONEDIR_MAJ_VER_PLUS}" + fi + else + # Enable the Salt LATEST repo + echo "[salt-repo-latest]" > "${ZYPPER_REPO_FILE}" + echo "name=Salt Repo for Salt LATEST release" >> "${ZYPPER_REPO_FILE}" + echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}" + echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}" + echo "priority=10" >> "${ZYPPER_REPO_FILE}" + echo "enabled=1" >> "${ZYPPER_REPO_FILE}" + echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}" + echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}" + echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}" + fi + __zypper addrepo --refresh "${ZYPPER_REPO_FILE}" || return 1 fi } @@ -6710,8 +6768,6 @@ __zypper_install() { __opensuse_prep_install() { # DRY function for common installation preparatory steps for SUSE if [ "$_DISABLE_REPOS" -eq $BS_FALSE ]; then - # Is the repository already known - __set_suse_pkg_repo # Check zypper repos and refresh if necessary __check_and_refresh_suse_pkg_repo fi @@ -6798,7 +6854,8 @@ install_opensuse_stable() { MINOR_VER_STRG="" elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # Minor version Salt, need to add specific minor version - MINOR_VER_STRG="-$STABLE_REV" + STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./') + MINOR_VER_STRG="-$STABLE_REV_DOT" else MINOR_VER_STRG="" fi @@ -7113,12 +7170,94 @@ install_suse_15_restart_daemons() { return 0 } +install_suse_15_check_services() { + install_opensuse_check_services || return 1 + return 0 +} + # # End of SUSE Enterprise 15 # ####################################################################################################################### +####################################################################################################################### +# +# SUSE Enterprise 15, now has ID sled +# + +install_sled_15_stable_deps() { + __opensuse_prep_install || return 1 + install_opensuse_15_stable_deps || return 1 + + return 0 +} + +install_sled_15_git_deps() { + install_suse_15_stable_deps || return 1 + + if ! __check_command_exists git; then + __zypper_install git-core || return 1 + fi + + install_opensuse_15_git_deps || return 1 + + return 0 +} + +install_sled_15_onedir_deps() { + __opensuse_prep_install || return 1 + install_opensuse_15_onedir_deps || return 1 + + return 0 +} + +install_sled_15_stable() { + install_opensuse_stable || return 1 + return 0 +} + +install_sled_15_git() { + install_opensuse_15_git || return 1 + return 0 +} + +install_sled_15_onedir() { + install_opensuse_stable || return 1 + return 0 +} + +install_sled_15_stable_post() { + install_opensuse_stable_post || return 1 + return 0 +} + +install_sled_15_git_post() { + install_opensuse_git_post || return 1 + return 0 +} + +install_sled_15_onedir_post() { + install_opensuse_stable_post || return 1 + return 0 +} + +install_sled_15_restart_daemons() { + install_opensuse_restart_daemons || return 1 + return 0 +} + +install_sled_15_check_services() { + install_opensuse_check_services || return 1 + return 0 +} + +# +# End of SUSE Enterprise 15 aka sled +# +####################################################################################################################### + + ####################################################################################################################### # # Gentoo Install Functions. From 0bd577de501d72d1425233efddec18edbcd80904 Mon Sep 17 00:00:00 2001 From: Salt Project Packaging Date: Mon, 9 Dec 2024 23:10:33 +0000 Subject: [PATCH 5/5] Update develop branch for the v2024.12.09 release --- CHANGELOG.md | 9 +++++++++ bootstrap-salt.ps1 | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2b85d2d6..16e7ac943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# v2024.12.09 + +## What's Changed + +- Fix quickstart for Windows with new repo by @twangboy in https://github.com/saltstack/salt-bootstrap/pull/2065 +- Utilize salt-project packages with SUSE by @dmurphy18 in https://github.com/saltstack/salt-bootstrap/pull/2066 + +**Full Changelog**: https://github.com/saltstack/salt-bootstrap/compare/v2024.11.29...v2024.12.09 + # v2024.11.29 ## What's Changed diff --git a/bootstrap-salt.ps1 b/bootstrap-salt.ps1 index 8d0c3c628..f355e0cd1 100644 --- a/bootstrap-salt.ps1 +++ b/bootstrap-salt.ps1 @@ -108,7 +108,7 @@ if ($help) { exit 0 } -$__ScriptVersion = "2024.11.29" +$__ScriptVersion = "2024.12.09" $ScriptName = $myInvocation.MyCommand.Name # We'll check for the Version next, because it also has no requirements