mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 01:30:21 +00:00
Merge develop into stable for v2024.04.03 release
This commit is contained in:
commit
b5c189488d
10 changed files with 319 additions and 270 deletions
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
@ -16,13 +16,13 @@ jobs:
|
|||
outputs:
|
||||
run-tests: ${{ steps.set-output.outputs.run-tests }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get specific changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v25
|
||||
uses: tj-actions/changed-files@v42
|
||||
with:
|
||||
separator: ","
|
||||
files: |
|
||||
|
@ -47,7 +47,7 @@ jobs:
|
|||
|
||||
- name: Upload Exit Status
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
@ -59,7 +59,7 @@ jobs:
|
|||
|
||||
if: github.event_name == 'push' || needs.collect-changed-files.outputs.run-tests == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v4
|
||||
|
@ -84,7 +84,7 @@ jobs:
|
|||
|
||||
- name: Upload Exit Status
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
@ -96,7 +96,7 @@ jobs:
|
|||
container: koalaman/shellcheck-alpine:v0.7.0
|
||||
if: github.event_name == 'push' || needs.collect-changed-files.outputs.run-tests == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: ShellCheck
|
||||
run: |
|
||||
shellcheck -s sh -f tty bootstrap-salt.sh
|
||||
|
@ -109,7 +109,7 @@ jobs:
|
|||
|
||||
- name: Upload Exit Status
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
@ -603,14 +603,14 @@ jobs:
|
|||
|
||||
- name: Download Exit Status Files
|
||||
if: always()
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
||||
- name: Delete Exit Status Artifacts
|
||||
if: always()
|
||||
uses: geekyeggo/delete-artifact@v1
|
||||
uses: geekyeggo/delete-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
failOnError: false
|
||||
|
|
92
.github/workflows/release.yml
vendored
92
.github/workflows/release.yml
vendored
|
@ -444,95 +444,3 @@ jobs:
|
|||
atomic: true
|
||||
branch: develop
|
||||
repository: ${{ github.repository }}
|
||||
|
||||
|
||||
salt:
|
||||
name: Update Release on Salt Repo
|
||||
runs-on:
|
||||
- self-hosted
|
||||
- linux
|
||||
- repo-release
|
||||
needs:
|
||||
- update-develop-checksums
|
||||
environment: release
|
||||
permissions:
|
||||
contents: write # For action peter-evans/create-pull-request
|
||||
pull-requests: write # For action peter-evans/create-pull-request
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: stable
|
||||
repository: ${{ github.repository }}
|
||||
|
||||
- name: Get bootstrap version
|
||||
run: |
|
||||
echo "BS_VERSION=$(sh bootstrap-salt.sh -v | awk '{ print $4 }')" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: saltstack/salt
|
||||
ref: master
|
||||
path: salt-checkout
|
||||
token: ${{ secrets.SALT_REPO_WRITE_TOKEN }}
|
||||
|
||||
- name: Setup GnuPG
|
||||
run: |
|
||||
sudo install -d -m 0700 -o "$(id -u)" -g "$(id -g)" /run/gpg
|
||||
GNUPGHOME="$(mktemp -d -p /run/gpg)"
|
||||
echo "GNUPGHOME=${GNUPGHOME}" >> "$GITHUB_ENV"
|
||||
cat <<EOF > "${GNUPGHOME}/gpg.conf"
|
||||
batch
|
||||
no-tty
|
||||
pinentry-mode loopback
|
||||
EOF
|
||||
|
||||
- name: Get Secrets
|
||||
id: get-secrets
|
||||
env:
|
||||
SECRETS_KEY: ${{ secrets.SECRETS_KEY }}
|
||||
run: |
|
||||
SECRETS_KEY_FILE=$(mktemp /tmp/output.XXXXXXXXXX)
|
||||
echo "$SECRETS_KEY" > "$SECRETS_KEY_FILE"
|
||||
aws --region us-west-2 secretsmanager get-secret-value --secret-id /cmbu-saltstack/signing/repo-signing-keys-sha256-2023 \
|
||||
--query SecretString --output text | jq .default_key -r | base64 -d \
|
||||
| gpg --passphrase-file "${SECRETS_KEY_FILE}" -d - \
|
||||
| gpg --import -
|
||||
sync
|
||||
aws --region us-west-2 secretsmanager get-secret-value --secret-id /cmbu-saltstack/signing/repo-signing-keys-sha256-2023 \
|
||||
--query SecretString --output text| jq .default_passphrase -r | base64 -d \
|
||||
| gpg --passphrase-file "${SECRETS_KEY_FILE}" -o "${GNUPGHOME}/passphrase" -d -
|
||||
sync
|
||||
rm "$SECRETS_KEY_FILE"
|
||||
echo "passphrase-file ${GNUPGHOME}/passphrase" >> "${GNUPGHOME}/gpg.conf"
|
||||
|
||||
- name: Configure Git
|
||||
shell: bash
|
||||
run: |
|
||||
git config --global --add safe.directory "$(pwd)"
|
||||
git config --global user.name "Salt Project Packaging"
|
||||
git config --global user.email saltproject-packaging@vmware.com
|
||||
git config --global user.signingkey 64CBBC8173D76B3F
|
||||
git config --global commit.gpgsign true
|
||||
|
||||
- name: Update bootstrap script on Salt
|
||||
run: |
|
||||
cp bootstrap-salt.sh salt-checkout/salt/cloud/deploy/bootstrap-salt.sh
|
||||
|
||||
- name: Commit Changes
|
||||
working-directory: salt-checkout/
|
||||
run: |
|
||||
git commit -am "Update the bootstrap script to v${{ env.BS_VERSION }}"
|
||||
|
||||
- name: Create Pull Request Against Develop
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
title: "Update the bootstrap script to v${{ env.BS_VERSION }}"
|
||||
path: salt-checkout
|
||||
base: master
|
||||
token: ${{ secrets.SALT_REPO_WRITE_TOKEN }}
|
||||
author: "Salt Project Packaging <saltproject-packaging@vmware.com>"
|
||||
committer: "Salt Project Packaging <saltproject-packaging@vmware.com>"
|
||||
commit-message: Update the bootstrap script to v${{ env.BS_VERSION }}
|
||||
signoff: true
|
||||
delete-branch: true
|
||||
|
|
4
.github/workflows/templates/ci-tail.yml
vendored
4
.github/workflows/templates/ci-tail.yml
vendored
|
@ -11,14 +11,14 @@
|
|||
|
||||
- name: Download Exit Status Files
|
||||
if: always()
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
||||
- name: Delete Exit Status Artifacts
|
||||
if: always()
|
||||
uses: geekyeggo/delete-artifact@v1
|
||||
uses: geekyeggo/delete-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
failOnError: false
|
||||
|
|
14
.github/workflows/templates/ci.yml
vendored
14
.github/workflows/templates/ci.yml
vendored
|
@ -16,13 +16,13 @@ jobs:
|
|||
outputs:
|
||||
run-tests: ${{ steps.set-output.outputs.run-tests }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get specific changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v25
|
||||
uses: tj-actions/changed-files@v42
|
||||
with:
|
||||
separator: ","
|
||||
files: |
|
||||
|
@ -47,7 +47,7 @@ jobs:
|
|||
|
||||
- name: Upload Exit Status
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
@ -59,7 +59,7 @@ jobs:
|
|||
|
||||
if: github.event_name == 'push' || needs.collect-changed-files.outputs.run-tests == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v4
|
||||
|
@ -84,7 +84,7 @@ jobs:
|
|||
|
||||
- name: Upload Exit Status
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
@ -96,7 +96,7 @@ jobs:
|
|||
container: koalaman/shellcheck-alpine:v0.7.0
|
||||
if: github.event_name == 'push' || needs.collect-changed-files.outputs.run-tests == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: ShellCheck
|
||||
run: |
|
||||
shellcheck -s sh -f tty bootstrap-salt.sh
|
||||
|
@ -109,7 +109,7 @@ jobs:
|
|||
|
||||
- name: Upload Exit Status
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: exitstatus
|
||||
path: exitstatus
|
||||
|
|
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -1,3 +1,18 @@
|
|||
# v2024.04.03
|
||||
|
||||
## What's Changed
|
||||
|
||||
- Remove automated PR against salt repo at release by @ScriptAutomate in https://github.com/saltstack/salt-bootstrap/pull/1984
|
||||
- Update actions by @twangboy in https://github.com/saltstack/salt-bootstrap/pull/1985
|
||||
- Fix DEBIAN Keyring url by @Dudek-AMS in https://github.com/saltstack/salt-bootstrap/pull/1983
|
||||
- Fix script to support installing RC on Windows by @twangboy in https://github.com/saltstack/salt-bootstrap/pull/1993
|
||||
|
||||
## New Contributors
|
||||
|
||||
- @Dudek-AMS made their first contribution in https://github.com/saltstack/salt-bootstrap/pull/1983
|
||||
|
||||
**Full Changelog**: https://github.com/saltstack/salt-bootstrap/compare/v2024.01.04...v2024.04.03
|
||||
|
||||
# v2024.01.04
|
||||
|
||||
## What's Changed
|
||||
|
@ -565,7 +580,7 @@
|
|||
- add apt-transport-https for ubuntu. (epcim) #896
|
||||
- Fix expanding shell script position parameters with nounset enabled. (vutny) #895
|
||||
- RFC: Add tests for bootstrap-salt.ps1. (themalkolm) #893
|
||||
- Keep original name of salt executable executable. (themalkolm) #857
|
||||
- Keep original name of salt executable. (themalkolm) #857
|
||||
|
||||
# v2016.06.27:
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ sum** of the downloaded ``bootstrap-salt.sh`` file.
|
|||
|
||||
The SHA256 sum of the ``bootstrap-salt.sh`` file, per release, is:
|
||||
|
||||
- 2024.01.04: ``cebcbc67895e238d1cf0024922a7fe5c772b9aaba346490c8fa6193bb0d993d4``
|
||||
- 2023.11.16: ``3757ed82161113fed4c711fd7332e922265eeeb54e6e4f657a08ea82d57cc3a2``
|
||||
- 2023.11.07: ``91f8a3bfb8b14476f7793c7f20cec7bfc638c10c073786f9a8904a858a929784``
|
||||
- 2023.08.03: ``963e559bdb85adecfbbec2c3b81190392bc59b24992e4491e919cd748eeafcb8``
|
||||
|
|
11
RELEASE.md
11
RELEASE.md
|
@ -3,13 +3,10 @@
|
|||
- See if there are any PRs worth squeezing into release.
|
||||
- Go through the changes since last release, add them to changelog.
|
||||
- Add any new authors to the AUTHORS file.
|
||||
- If there's a new Salt release(major), update the script to add support for it.
|
||||
- If there's a new Salt release (major), update the script to add support for it.
|
||||
- Bump version for release.
|
||||
- Open PR against develop with these changes.
|
||||
- Once the above PR is merged, open a PR against stable with the changes from develop.
|
||||
- Once the above PR is merged, wait until an automatic PR is opened against stable which updates the checksums.
|
||||
- Once the above PR is merged, tag the release `v{version-here}` and push the tag.
|
||||
- Wait until an automatic PR is opened against the develop branch updating the checksums in `README.rst`. Merge it.
|
||||
- Check that an automated PR was opened against the salt repo updating the bootstrap script, located in `salt/cloud/deploy/bootstrap-salt.sh`
|
||||
|
||||
- Once the above PR is merged, go to [Cut Release](https://github.com/saltstack/salt-bootstrap/actions/workflows/release.yml) and `Run workflow` against `develop` branch
|
||||
- Open a new PR against the branch of the oldest supported version of [the salt repo](https://github.com/saltstack/salt) (ex. `3006.x`), and replace `salt/cloud/deploy/bootstrap-salt.sh` with the latest `bootstrap-salt.sh` file
|
||||
- When that PR is merged into [the salt repo](https://github.com/saltstack/salt), merge-forwards into the latest branches and `master` will ensure that the latest bootstrap script is available
|
||||
- Victory!
|
||||
|
|
|
@ -5,61 +5,32 @@
|
|||
.DESCRIPTION
|
||||
The script will download the official Salt package from SaltProject. It will
|
||||
install a specific package version and accept parameters for the master and
|
||||
minion ids. Finally, it can stop and set the Windows service to "manual" for
|
||||
minion IDs. Finally, it can stop and set the Windows service to "manual" for
|
||||
local testing.
|
||||
|
||||
.EXAMPLE
|
||||
./bootstrap-salt.ps1
|
||||
Runs without any parameters. Uses all the default values/settings.
|
||||
Runs without any parameters. Uses all the default values/settings. Will
|
||||
install the latest version of Salt
|
||||
|
||||
.EXAMPLE
|
||||
./bootstrap-salt.ps1 -version 2017.7.0
|
||||
./bootstrap-salt.ps1 -Version 3006.7
|
||||
Specifies a particular version of the installer.
|
||||
|
||||
.EXAMPLE
|
||||
./bootstrap-salt.ps1 -pythonVersion 3
|
||||
Specifies the Python version of the installer. Can be "2" or "3". Defaults
|
||||
to "2". Python 3 installers are only available for Salt 2017.7.0 and newer.
|
||||
Starting with Python 3002 only Python 3 installers are available.
|
||||
|
||||
.EXAMPLE
|
||||
./bootstrap-salt.ps1 -runservice false
|
||||
./bootstrap-salt.ps1 -RunService false
|
||||
Specifies the salt-minion service to stop and be set to manual. Useful for
|
||||
testing locally from the command line with the --local switch
|
||||
|
||||
.EXAMPLE
|
||||
./bootstrap-salt.ps1 -minion minion-box -master master-box
|
||||
./bootstrap-salt.ps1 -Minion minion-box -Master master-box
|
||||
Specifies the minion and master ids in the minion config. Defaults to the
|
||||
installer values of host name for the minion id and "salt" for the master.
|
||||
|
||||
.EXAMPLE
|
||||
./bootstrap-salt.ps1 -minion minion-box -master master-box -version 2017.7.0 -runservice false
|
||||
./bootstrap-salt.ps1 -Minion minion-box -Master master-box -Version 3006.7 -RunService false
|
||||
Specifies all the optional parameters in no particular order.
|
||||
|
||||
.PARAMETER version
|
||||
The version of the Salt minion to install. Default is "latest" which will
|
||||
install the latest version of Salt minion available.
|
||||
|
||||
.PARAMETER pythonVersion
|
||||
The version of Python the installer should use. Specify either "2" or "3".
|
||||
Beginning with Salt 2017.7.0, Salt will run on either Python 2 or Python 3.
|
||||
The default is Python 2 if not specified. This parameter only works for Salt
|
||||
|
||||
.PARAMETER runservice
|
||||
Boolean flag to start or stop the minion service. True will start the minion
|
||||
service. False will stop the minion service and set it to "manual". The
|
||||
installer starts it by default.
|
||||
|
||||
.PARAMETER minion
|
||||
Name of the minion being installed on this host. Installer defaults to the
|
||||
host name.
|
||||
|
||||
.PARAMETER master
|
||||
Name or IP of the master server. Installer defaults to "salt".
|
||||
|
||||
.PARAMETER repourl
|
||||
URL to the windows packages. Default is "https://repo.saltproject.io/windows"
|
||||
|
||||
.NOTES
|
||||
All of the parameters are optional. The default should be the latest
|
||||
version. The architecture is dynamically determined by the script.
|
||||
|
@ -68,7 +39,7 @@
|
|||
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://repo.saltproject.io/windows/
|
||||
Salt Download Location - https://repo.saltproject.io/salt/py3/windows
|
||||
#>
|
||||
|
||||
#===============================================================================
|
||||
|
@ -77,43 +48,62 @@
|
|||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
# Doesn't support versions prior to "YYYY.M.R-B"
|
||||
# Supports new version and latest
|
||||
# Option 1 means case insensitive
|
||||
[ValidatePattern('^(\d{4}(\.\d{1,2}){0,2}(\-\d{1})?)|(latest)$', Options=1)]
|
||||
[Alias("v")]
|
||||
# The version of the Salt minion to install. Default is "latest" which will
|
||||
# install the latest version of Salt minion available. Doesn't support
|
||||
# versions prior to "YYYY.M.R-B"
|
||||
[String]$Version = "latest",
|
||||
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
# Python 3 support was added in 2017. Python 2 support was dropped in
|
||||
# version 3001. This parameter is ignored for all versions before 2017 and
|
||||
# after 3000.
|
||||
[ValidateSet("2","3")]
|
||||
[Alias("p")]
|
||||
[String]$PythonVersion = "3",
|
||||
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
[ValidateSet("true","false")]
|
||||
[Alias("s")]
|
||||
# Boolean flag to start or stop the minion service. True will start the
|
||||
# minion service. False will stop the minion service and set it to "manual".
|
||||
# The installer starts it by default.
|
||||
[String]$RunService = "true",
|
||||
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
[Alias("m")]
|
||||
# Name of the minion being installed on this host. Installer defaults to the
|
||||
# host name.
|
||||
[String]$Minion = "not-specified",
|
||||
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
[Alias("a")]
|
||||
#Name or IP of the master server. Installer defaults to "salt".
|
||||
[String]$Master = "not-specified",
|
||||
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
[Alias("r")]
|
||||
# URL to the windows packages. Will look for a file named repo.json at the
|
||||
# root of the URL. This file is used to determine the name and location of
|
||||
# the installer in the repo. If repo.json is not found, it will look for the
|
||||
# file under the minor directory.
|
||||
# Default is "https://repo.saltproject.io/salt/py3/windows"
|
||||
[String]$RepoUrl = "https://repo.saltproject.io/salt/py3/windows",
|
||||
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$True)]
|
||||
[Alias("c")]
|
||||
[Switch]$ConfigureOnly
|
||||
# Vagrant only
|
||||
# Vagrant files are placed in "C:\tmp". Copies Salt config files from
|
||||
# Vagrant (C:\tmp) to Salt config locations and exits. Does not run the
|
||||
# installer
|
||||
[Switch]$ConfigureOnly,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[Alias("h")]
|
||||
# Displays help for this script.
|
||||
[Switch] $Help
|
||||
)
|
||||
|
||||
# We'll check for help first because it really has no requirements
|
||||
if ($help) {
|
||||
# Get the full script name
|
||||
$this_script = & {$myInvocation.ScriptName}
|
||||
Get-Help $this_script -Detailed
|
||||
exit 0
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
# Script Preferences
|
||||
|
@ -253,6 +243,7 @@ function Get-FileHash {
|
|||
}
|
||||
} catch {
|
||||
Write-Verbose "Error hashing: $Path"
|
||||
Write-Verbose "ERROR: $_"
|
||||
return @{}
|
||||
} finally {
|
||||
if ($null -ne $data) {
|
||||
|
@ -301,27 +292,11 @@ if (!(Get-IsAdministrator)) {
|
|||
$defaultUrl = "https://repo.saltproject.io/salt/py3/windows"
|
||||
$oldRepoUrl = "https://repo.saltproject.io/windows"
|
||||
$majorVersion = Get-MajorVersion -Version $Version
|
||||
$customUrl = $true
|
||||
if ( $Version.ToLower() -ne "latest" ) {
|
||||
# A specific version has been passed
|
||||
# We only want to modify the URL if a custom URL was not passed
|
||||
$uri = [Uri]($RepoUrl)
|
||||
if ( $uri.AbsoluteUri -eq $defaultUrl ) {
|
||||
# No customURL passed, let's check for a pre 3006 version
|
||||
$customUrl = $false
|
||||
if ( $majorVersion -lt "3006" ) {
|
||||
# This is an older version, use the old URL
|
||||
$RepoUrl = $oldRepoUrl
|
||||
} else {
|
||||
# This is a new URL, and a version was passed, let's look in minor
|
||||
if ( $Version.ToLower() -ne $majorVersion.ToLower() ) {
|
||||
$RepoUrl = "$RepoUrl/minor"
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( $RepoUrl -eq $defaultUrl ) {
|
||||
$customUrl = $false
|
||||
if ( [Uri]($RepoUrl).AbsoluteUri -eq $defaultUrl ) {
|
||||
# No customURL passed, let's check for a pre 3006 version
|
||||
if ($majorVersion -lt "3006") {
|
||||
# This is an older version, use the old URL
|
||||
$RepoUrl = $oldRepoUrl
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,9 +347,6 @@ $ConfDir = "$RootDir\conf"
|
|||
$PkiDir = "$ConfDir\pki\minion"
|
||||
Write-Verbose "ConfDir: $ConfDir"
|
||||
|
||||
# Create C:\tmp\
|
||||
New-Item C:\tmp\ -ItemType directory -Force | Out-Null
|
||||
|
||||
#===============================================================================
|
||||
# Copy Vagrant Files to their proper location.
|
||||
#===============================================================================
|
||||
|
@ -431,15 +403,61 @@ $saltFileName = ""
|
|||
$saltVersion = ""
|
||||
$saltSha512= ""
|
||||
$saltFileUrl = ""
|
||||
if ( ($customUrl) -or ($majorVersion -lt 3006) ) {
|
||||
$saltFileName = "Salt-Minion-$Version-Py3-$arch-Setup.exe"
|
||||
$saltVersion = $Version
|
||||
$saltFileUrl = "$RepoUrl/$saltFileName"
|
||||
} else {
|
||||
if ( $majorVersion -ge 3006 ) {
|
||||
$enc = [System.Text.Encoding]::UTF8
|
||||
# Look for a repo.json file
|
||||
try {
|
||||
Write-Verbose "Looking for $RepoUrl/repo.json"
|
||||
$response = Invoke-WebRequest "$RepoUrl/repo.json" `
|
||||
-DisableKeepAlive `
|
||||
-UseBasicParsing `
|
||||
-Method Head
|
||||
if ( $response.StatusCode -eq "200" ) {
|
||||
Write-Verbose "Found $RepoUrl/repo.json"
|
||||
# This URL contains a repo.json file, let's use it
|
||||
$use_repo_json = $true
|
||||
} else {
|
||||
Write-Verbose "Did not find $RepoUrl/repo.json"
|
||||
# No repo.json file found at the default location
|
||||
$use_repo_json = $false
|
||||
}
|
||||
} catch {
|
||||
Write-Verbose "There was an error looking up $RepoUrl/repo.json"
|
||||
Write-Verbose "ERROR: $_"
|
||||
$use_repo_json = $false
|
||||
}
|
||||
if ( $use_repo_json ) {
|
||||
# We will use the json file to get the name of the installer
|
||||
$enc = [System.Text.Encoding]::UTF8
|
||||
try {
|
||||
Write-Verbose "Downloading $RepoUrl/repo.json"
|
||||
$response = Invoke-WebRequest -Uri "$RepoUrl/repo.json" -UseBasicParsing
|
||||
if ($response.Content.GetType().Name -eq "Byte[]") {
|
||||
$psobj = $enc.GetString($response.Content) | ConvertFrom-Json
|
||||
} else {
|
||||
$psobj = $response.Content | ConvertFrom-Json
|
||||
}
|
||||
$hash = Convert-PSObjectToHashtable $psobj
|
||||
} catch {
|
||||
Write-Verbose "repo.json not found at: $RepoUrl"
|
||||
Write-Host "ERROR: $_"
|
||||
$hash = @{}
|
||||
}
|
||||
|
||||
$searchVersion = $Version.ToLower()
|
||||
if ( $hash.Contains($searchVersion)) {
|
||||
Write-Verbose "Found $searchVersion in $RepoUrl/repo.json"
|
||||
foreach ($item in $hash.($searchVersion).Keys) {
|
||||
if ( $item.ToLower().EndsWith(".exe") ) {
|
||||
if ( $item.ToLower().Contains($arch.ToLower()) ) {
|
||||
$saltFileName = $hash.($searchVersion).($item).name
|
||||
$saltVersion = $hash.($searchVersion).($item).version
|
||||
$saltSha512 = $hash.($searchVersion).($item).SHA512
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri "$RepoUrl/repo.json" -UseBasicParsing
|
||||
Write-Verbose "Searching for $searchVersion in $RepoUrl/minor/repo.json"
|
||||
$response = Invoke-WebRequest -Uri "$RepoUrl/minor/repo.json" -UseBasicParsing
|
||||
if ($response.Content.GetType().Name -eq "Byte[]") {
|
||||
$psobj = $enc.GetString($response.Content) | ConvertFrom-Json
|
||||
} else {
|
||||
|
@ -447,32 +465,78 @@ if ( ($customUrl) -or ($majorVersion -lt 3006) ) {
|
|||
}
|
||||
$hash = Convert-PSObjectToHashtable $psobj
|
||||
} catch {
|
||||
Write-Verbose "repo.json not found at: $RepoUrl"
|
||||
Write-Verbose "repo.json not found at: $RepoUrl/minor/repo.json"
|
||||
Write-Verbose "ERROR: $_"
|
||||
$hash = @{}
|
||||
}
|
||||
|
||||
$searchVersion = $Version.ToLower()
|
||||
if ( $hash.Contains($searchVersion)) {
|
||||
Write-Verbose "Found $searchVersion in $RepoUrl/minor/repo.json"
|
||||
foreach ($item in $hash.($searchVersion).Keys) {
|
||||
if ( $item.EndsWith(".exe") ) {
|
||||
if ( $item.Contains($arch) ) {
|
||||
if ( $item.ToLower().EndsWith(".exe") ) {
|
||||
if ( $item.ToLower().Contains($arch.ToLower()) ) {
|
||||
$saltFileName = $hash.($searchVersion).($item).name
|
||||
$saltVersion = $hash.($searchVersion).($item).version
|
||||
$saltSha512 = $hash.($searchVersion).($item).SHA512
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $saltFileName -and $saltVersion -and $saltSha512 ) {
|
||||
if ( $RepoUrl.Contains("minor") ) {
|
||||
$saltFileUrl = @($RepoUrl, $saltVersion, $saltFileName) -join "/"
|
||||
} else {
|
||||
$saltFileUrl = @($RepoUrl, "minor", $saltVersion, $saltFileName) -join "/"
|
||||
}
|
||||
} else {
|
||||
Write-Verbose "Version not found in $RepoUrl/minor/repo.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $saltFileName -and $saltVersion -and $saltSha512 ) {
|
||||
Write-Verbose "Found Name, Version, and Sha"
|
||||
} else {
|
||||
# We will guess the name of the installer
|
||||
Write-Verbose "Failed to get Name, Version, and Sha from repo.json"
|
||||
Write-Verbose "We'll try to find the file in standard paths"
|
||||
$saltFileName = "Salt-Minion-$Version-Py3-$arch-Setup.exe"
|
||||
$saltVersion = $Version
|
||||
}
|
||||
|
||||
Write-Verbose "Creating list of urls using the following:"
|
||||
Write-Verbose "RepoUrl: $RepoUrl"
|
||||
Write-Verbose "Version: $saltVersion"
|
||||
Write-Verbose "File Name: $saltFileName"
|
||||
$urls = $(@($RepoUrl, $saltVersion, $saltFileName) -join "/"),
|
||||
$(@($RepoUrl, "minor", $saltVersion, $saltFileName) -join "/"),
|
||||
$(@($RepoUrl, $saltFileName) -join "/"),
|
||||
$(@($oldRepoUrl, $saltFileName) -join "/")
|
||||
|
||||
$saltFileUrl = $null
|
||||
|
||||
foreach ($url in $urls) {
|
||||
try {
|
||||
Write-Verbose "Looking for installer at: $url"
|
||||
$response = Invoke-WebRequest "$url" `
|
||||
-DisableKeepAlive `
|
||||
-UseBasicParsing `
|
||||
-Method Head
|
||||
if ( $response.StatusCode -eq "200" ) {
|
||||
Write-Verbose "Found installer"
|
||||
# This URL contains a repo.json file, let's use it
|
||||
$saltFileUrl = $url
|
||||
break
|
||||
} else {
|
||||
Write-Verbose "Installer not found: $url"
|
||||
}
|
||||
} catch {
|
||||
Write-Verbose "ERROR: $url"
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$saltFileUrl ) {
|
||||
Write-Host "Could not find an installer:"
|
||||
Write-Verbose "Here are the urls searched:"
|
||||
foreach ($url in $urls) {
|
||||
Write-Verbose $url
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Download minion setup file
|
||||
#===============================================================================
|
||||
|
@ -481,10 +545,19 @@ Write-Host " Bootstrapping Salt Minion" -ForegroundColor Green
|
|||
Write-Host " - version: $Version"
|
||||
Write-Host " - file name: $saltFileName"
|
||||
Write-Host " - file url: $saltFileUrl"
|
||||
Write-Host " - master: $Master"
|
||||
Write-Host " - minion id: $Minion"
|
||||
Write-Host " - start service: $RunService"
|
||||
Write-Host "-------------------------------------------------------------------------------" -ForegroundColor Yellow
|
||||
|
||||
$localFile = "$env:TEMP\$saltFileName"
|
||||
|
||||
Write-Host "Downloading Installer: " -NoNewline
|
||||
Write-Verbose ""
|
||||
Write-Verbose "Salt File URL: $saltFileUrl"
|
||||
Write-Verbose "Local File: $localFile"
|
||||
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
$localFile = "C:\Windows\Temp\$saltFileName"
|
||||
$webclient.DownloadFile($saltFileUrl, $localFile)
|
||||
|
||||
if ( Test-Path -Path $localFile ) {
|
||||
|
@ -496,6 +569,9 @@ if ( Test-Path -Path $localFile ) {
|
|||
if ( $saltSha512 ) {
|
||||
$localSha512 = (Get-FileHash -Path $localFile -Algorithm SHA512).Hash
|
||||
Write-Host "Comparing Hash: " -NoNewline
|
||||
Write-Verbose ""
|
||||
Write-Verbose "Local Hash: $localSha512"
|
||||
Write-Verbose "Remote Hash: $saltSha512"
|
||||
if ( $localSha512 -eq $saltSha512 ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
|
@ -514,72 +590,124 @@ if ( $saltSha512 ) {
|
|||
$parameters = ""
|
||||
if($Minion -ne "not-specified") {$parameters = "/minion-name=$Minion"}
|
||||
if($Master -ne "not-specified") {$parameters = "$parameters /master=$Master"}
|
||||
if($RunService -eq $false) {$parameters = "$parameters /start-service=0"}
|
||||
|
||||
#===============================================================================
|
||||
# Install minion silently
|
||||
#===============================================================================
|
||||
#Wait for process to exit before continuing.
|
||||
Write-Host "Installing Salt Minion: " -NoNewline
|
||||
Start-Process $localFile -ArgumentList "/S $parameters" -Wait -NoNewWindow -PassThru | Out-Null
|
||||
Write-Host "Installing Salt Minion (5 min timeout): " -NoNewline
|
||||
Write-Verbose ""
|
||||
Write-Verbose "Local File: $localFile"
|
||||
Write-Verbose "Parameters: $parameters"
|
||||
$process = Start-Process $localFile `
|
||||
-WorkingDirectory $(Split-Path $localFile -Parent) `
|
||||
-ArgumentList "/S /start-service=0 $parameters" `
|
||||
-NoNewWindow -PassThru
|
||||
|
||||
# Sometimes the installer hangs... we'll wait 5 minutes and then kill it
|
||||
Write-Verbose ""
|
||||
Write-Verbose "Waiting for installer to finish"
|
||||
$process | Wait-Process -Timeout 300 -ErrorAction SilentlyContinue
|
||||
$process.Refresh()
|
||||
|
||||
if ( !$process.HasExited ) {
|
||||
Write-Host "Timedout" -ForegroundColor Yellow
|
||||
Write-Host "Killing hung installer: " -NoNewline
|
||||
$process | Stop-Process
|
||||
$process.Refresh()
|
||||
if ( $process.HasExited ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Checking installed service: " -NoNewline
|
||||
}
|
||||
|
||||
# Wait for salt-minion service to be registered to verify successful
|
||||
# installation
|
||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||
$tries = 0
|
||||
$max_tries = 15 # We'll try for 30 seconds
|
||||
Write-Verbose "Checking that the service is installed"
|
||||
while ( ! $service ) {
|
||||
# We'll keep trying to get a service object until we're successful, or we
|
||||
# reach max_tries
|
||||
if ( $tries -le $max_tries ) {
|
||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 2
|
||||
$tries += 1
|
||||
} else {
|
||||
# If the salt-minion service is still not running, something
|
||||
# probably went wrong and user intervention is required - report
|
||||
# failure.
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
Write-Host "Timed out waiting for the salt-minion service to be installed"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
# If we get this far, the service was installed, we have a service object
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
||||
#===============================================================================
|
||||
# Configure the minion service
|
||||
#===============================================================================
|
||||
# Wait for salt-minion service to be registered before trying to start it
|
||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||
while (!$service) {
|
||||
Start-Sleep -s 2
|
||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ( $service ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
if($RunService) {
|
||||
# Start service
|
||||
if( $RunService ) {
|
||||
# Start the service
|
||||
Write-Host "Starting Service: " -NoNewline
|
||||
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
||||
|
||||
# Check if service is started, otherwise retry starting the
|
||||
# service 4 times.
|
||||
$try = 0
|
||||
while (($service.Status -ne "Running") -and ($try -ne 4)) {
|
||||
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||
Start-Sleep -s 2
|
||||
$try += 1
|
||||
Write-Verbose ""
|
||||
$tries = 0
|
||||
# We'll try for 2 minutes, sometimes the minion takes that long to start as
|
||||
# it compiles python code for the first time
|
||||
$max_tries = 60
|
||||
while ( $service.Status -ne "Running" ) {
|
||||
if ( $service.Status -eq "Stopped" ) {
|
||||
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
Write-Verbose "Checking the service status"
|
||||
$service.Refresh()
|
||||
if ( $service.Status -eq "Running" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
if ( $tries -le $max_tries ) {
|
||||
$tries += 1
|
||||
} else {
|
||||
# If the salt-minion service is still not running, something
|
||||
# probably went wrong and user intervention is required - report
|
||||
# failure.
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
Write-Host "Timed out waiting for the salt-minion service to start"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If the salt-minion service is still not running, something probably
|
||||
# went wrong and user intervention is required - report failure.
|
||||
if ($service.Status -eq "Running") {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
} else {
|
||||
Write-Host "Setting Service to 'Manual': " -NoNewline
|
||||
Set-Service "salt-minion" -StartupType "Manual"
|
||||
if ( (Get-Service "salt-minion").StartType -eq "Manual" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
# Set the service to manual start
|
||||
$service.Refresh()
|
||||
if ( $service.StartType -ne "Manual" ) {
|
||||
Write-Host "Setting Service Start Type to 'Manual': " -NoNewline
|
||||
Set-Service "salt-minion" -StartupType "Manual"
|
||||
$service.Refresh()
|
||||
if ( $service.StartType -eq "Manual" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Stopping Service: " -NoNewline
|
||||
Stop-Service "salt-minion"
|
||||
if ( (Get-Service "salt-minion").Status -eq "Stopped" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
# The installer should have installed the service stopped, but we'll make
|
||||
# sure it is stopped here
|
||||
if ( $service.Status -ne "Stopped" ) {
|
||||
Write-Host "Stopping Service: " -NoNewline
|
||||
Stop-Service "salt-minion"
|
||||
$service.Refresh()
|
||||
if ( $service.Status -eq "Stopped" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#======================================================================================================================
|
||||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
__ScriptVersion="2024.01.04"
|
||||
__ScriptVersion="2024.04.03"
|
||||
__ScriptName="bootstrap-salt.sh"
|
||||
|
||||
__ScriptFullName="$0"
|
||||
|
@ -3659,10 +3659,10 @@ __install_saltstack_debian_repository() {
|
|||
__apt_get_install_noinput ${__PACKAGES} || return 1
|
||||
|
||||
# amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location
|
||||
SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/${__PY_VERSION_REPO}/debian/${DEBIAN_RELEASE}/${__REPO_ARCH}/${STABLE_REV}"
|
||||
SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/${__PY_VERSION_REPO}/debian/${DEBIAN_RELEASE}/${__REPO_ARCH}"
|
||||
echo "$__REPO_ARCH_DEB $SALTSTACK_DEBIAN_URL $DEBIAN_CODENAME main" > "/etc/apt/sources.list.d/salt.list"
|
||||
|
||||
__apt_key_fetch "$SALTSTACK_DEBIAN_URL/salt-archive-keyring.gpg" || return 1
|
||||
__apt_key_fetch "$SALTSTACK_DEBIAN_URL/SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
|
||||
|
||||
__wait_for_apt apt-get update || return 1
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ driver:
|
|||
|
||||
provisioner:
|
||||
salt_bootstrap_url: D:/a/salt-bootstrap/salt-bootstrap/bootstrap-salt.ps1
|
||||
salt_bootstrap_options: -pythonVersion 3 -version %s
|
||||
salt_bootstrap_options: -Version %s -Verbose
|
||||
init_environment: ''
|
||||
|
||||
platforms:
|
||||
|
|
Loading…
Add table
Reference in a new issue