diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4d38780d6..1cfce68a1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,6 +8,3 @@ Remove this section if not relevant ### New Behavior Remove this section if not relevant -### Tests written? - -Yes/No diff --git a/AUTHORS.rst b/AUTHORS.rst index 1f5caa6c0..1df5846e9 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -35,6 +35,8 @@ Denys Havrysh vutny denys.gavrysh@gmail.com deployboy deployboy Diego Woitasen diegows diego@flugel.it Elias Probst eliasp +eliezerlp eliezerlp +Emiel Kollof ekollof Erik Ankrom erikankrom Erik Johnson terminalmage erik@saltstack.com EYJ eyj @@ -66,6 +68,7 @@ markgaylard markgaylard Matt Black mafrosis Matthew Garrett cingeyedog matt@clemson.edu Matthew Mead-Briggs mattmb +Matthew Richardson mrichar1 Matthew Willson ixela Matthieu Guegan mguegan Michael A. Smith kojiromike michaels@syapse.com @@ -84,6 +87,7 @@ Pavel Snagovsky paha Pedro Algarvio s0undt3ch pedro@algarvio.me Pedro Paulo pedropaulovc Peter Tripp notpeter +Petr Michalec epcim Prayag Verma pra85 prayag.verma@gmail.com ptonelli ptonelli Randy Thompson beardedeagle randy@heroictek.com diff --git a/ChangeLog b/ChangeLog index 1392859f5..c1dd062be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,21 @@ +Version 2016.07.07: + * Add new contributors to authors list. (rallytime) #910 + * Split up python-requests and python-msgpack packages for newer Fedora. (rallytime) #909 + * Fix typo in repository configuration for FreeBSD. (ekollof) #907 + * Make sure $STABLE_REV is set before setting up SaltStack repo. (rallytime) #906 + * Remove tests written question from template. (rallytime) #904 + * Adding support for Linux Mint 18 (based on Ubuntu 16.04). (eliezerlp) #902 + * Allow git installation for SLES 12. (rallytime) #903 + * Set repo_arch for raspberry pi installs. (mrichar1) #899 + * Change temporary directory for storing executable to C:\Windows\Temp. (themalkolm) #897 + * 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 + Version 2016.06.27: - * Fix race condition when doing one-liner bootstrap - * Add space back in between 'install' and '--install' + * Fix race condition when doing one-liner bootstrap. (vutny) #889 + * Add space back in between 'install' and '--install'. (rallytime) #890 Version 2016.06.24: * Save invocation command and arguments into variables. (jfindlay) #885 diff --git a/README.rst b/README.rst index 9c597a1f3..c7d54f8a5 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,8 @@ Bootstrapping Salt ================== +|windows_build| + Before `Salt`_ can be used for provisioning on the desired machine, the binaries need to be installed. Since `Salt`_ supports many different distributions and versions of operating systems, the `Salt`_ installation process is handled by this shell script ``bootstrap-salt.sh``. This @@ -236,7 +238,7 @@ Ubuntu and derivatives - Elementary OS 0.2 (based on Ubuntu 12.04) - Linaro 12.04 -- Linux Mint 13/14/16/17 +- Linux Mint 13/14/16/17/18 - Trisquel GNU/Linux 6 (based on Ubuntu 12.04) - Ubuntu 10.x/11.x/12.x/13.x/14.x/15.x/16.04 @@ -535,3 +537,7 @@ Salt is ready and working in the Docker container with Minion authenticated on M .. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et + +.. |windows_build| image:: https://ci.appveyor.com/api/projects/status/github/themalkolm/salt-bootstrap?branch=develop&svg=true + :target: https://ci.appveyor.com/project/themalkolm/salt-bootstrap + :alt: Build status of the develop branch on Windows diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..6c7b57b0d --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,32 @@ +platform: Any CPU + +environment: + matrix: + - bootstrap_args: + test_args: -master salt -runservice + + - bootstrap_args: -runservice false + test_args: -master salt -noservice + + - bootstrap_args: -minion a-minion + test_args: -minion a-minion -master salt -runservice + + - bootstrap_args: -minion a-minion -master a-master + test_args: -minion a-minion -master a-master -runservice + +build_script: + - ps: | + $Path = (Get-Location).Path | Join-Path -ChildPath bootstrap-salt.ps1 + Invoke-Expression "$Path -verbose $env:bootstrap_args" + +before_test: + - SET PATH=%PATH%;C:\salt + - salt-call --version + +test_script: + - ps: | + $Path = (Get-Location).Path | Join-Path -ChildPath tests\runtests.ps1 + Invoke-Expression "$Path -verbose $env:test_args" + +matrix: + fast_finish: true diff --git a/bootstrap-salt.ps1 b/bootstrap-salt.ps1 index 2bff69e39..2f51d23e5 100644 --- a/bootstrap-salt.ps1 +++ b/bootstrap-salt.ps1 @@ -217,10 +217,11 @@ If (!$version) { #=============================================================================== # Download minion setup file #=============================================================================== -Write-Output "Downloading Salt minion installer Salt-Minion-$version-$arch-Setup.exe" +$saltExe = "Salt-Minion-$version-$arch-Setup.exe" +Write-Output "Downloading Salt minion installer $saltExe" $webclient = New-Object System.Net.WebClient -$url = "$repourl/Salt-Minion-$version-$arch-Setup.exe" -$file = "C:\tmp\salt.exe" +$url = "$repourl/$saltExe" +$file = "C:\Windows\Temp\$saltExe" $webclient.DownloadFile($url, $file) #=============================================================================== @@ -240,7 +241,7 @@ If($runservice -eq $false) {$parameters = "$parameters /start-service=0"} #=============================================================================== #Wait for process to exit before continuing. Write-Output "Installing Salt minion" -Start-Process C:\tmp\salt.exe -ArgumentList "/S $parameters" -Wait -NoNewWindow -PassThru | Out-Null +Start-Process C:\Windows\Temp\$saltExe -ArgumentList "/S $parameters" -Wait -NoNewWindow -PassThru | Out-Null #=============================================================================== # Configure the minion service diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 2f2b3bddb..b894cfaee 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -18,11 +18,11 @@ #====================================================================================================================== set -o nounset # Treat unset variables as an error -__ScriptVersion="2016.06.27" +__ScriptVersion="2016.07.07" __ScriptName="bootstrap-salt.sh" -__ScriptFullName="${0}" -__ScriptArgs="${*}" +__ScriptFullName="$0" +__ScriptArgs="$*" #====================================================================================================================== # Environment variables taken into account. @@ -630,7 +630,7 @@ fi echoinfo "Running version: ${__ScriptVersion}" echoinfo "Executed by: ${CALLER}" -echoinfo "Command line: \"${__ScriptFullName} ${__ScriptArgs}\"" +echoinfo "Command line: '${__ScriptFullName} ${__ScriptArgs}'" #echowarn "Running the unstable version of ${__ScriptName}" #--- FUNCTION ------------------------------------------------------------------------------------------------------- @@ -1180,6 +1180,7 @@ __ubuntu_derivatives_translation() { linuxmint_16_ubuntu_base="13.10" linuxmint_17_ubuntu_base="14.04" + linuxmint_18_ubuntu_base="16.04" linaro_12_ubuntu_base="12.04" elementary_os_02_ubuntu_base="12.04" @@ -2366,6 +2367,11 @@ install_ubuntu_stable_deps() { set -o nounset fi + # Make sure https transport is available + if [ "$HTTP_VAL" = "https" ] ; then + __apt_get_install_noinput ca-certificates apt-transport-https || return 1 + fi + # Make sure wget is available __apt_get_install_noinput wget @@ -2714,6 +2720,8 @@ install_debian_7_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then if [ "$CPU_ARCH_L" = "amd64" ] || [ "$CPU_ARCH_L" = "x86_64" ]; then repo_arch="amd64" + elif [ "$CPU_ARCH_L" = "armv7l" ]; then + repo_arch="armhf" elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Debian (yet?)" repo_arch="i386" @@ -2790,6 +2798,8 @@ install_debian_8_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then if [ "$CPU_ARCH_L" = "amd64" ] || [ "$CPU_ARCH_L" = "x86_64" ]; then repo_arch="amd64" + elif [ "$CPU_ARCH_L" = "armv7l" ]; then + repo_arch="armhf" elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Debian (yet?)" repo_arch="i386" @@ -3113,7 +3123,13 @@ install_fedora_deps() { __install_saltstack_copr_salt_repository || return 1 fi - __PACKAGES="yum-utils PyYAML libyaml m2crypto python-crypto python-jinja2 python-msgpack python-zmq python-requests" + __PACKAGES="yum-utils PyYAML libyaml m2crypto python-crypto python-jinja2 python-zmq" + + if [ "$DISTRO_MAJOR_VERSION" -ge 23 ]; then + __PACKAGES="${__PACKAGES} python2-msgpack python2-requests" + else + __PACKAGES="${__PACKAGES} python-msgpack python-requests" + fi if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} python-libcloud" @@ -4082,6 +4098,14 @@ _eof } install_amazon_linux_ami_git_deps() { + + # When installing from git, this variable might not be set yet for amazon linux. Set this + # to "latest" in order to set up the SaltStack repository and avoid a malformed baseurl + # and gpgkey reference in the install_amazon_linux_amI_deps function. + if [ "$STABLE_REV" = "" ]; then + STABLE_REV="latest" + fi + install_amazon_linux_ami_deps || return 1 if ! __check_command_exists git; then @@ -4098,7 +4122,6 @@ install_amazon_linux_ami_git_deps() { fi fi - # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" @@ -4410,7 +4433,7 @@ __configure_freebsd_pkg_details() { echo " url: \"${SALTPKGCONFURL}\"," echo " mirror_type: \"http\"," echo " enabled: true" - echo " prioroity: 10" + echo " priority: 10" echo "}" } > $salt_conf_file FROM_SALTSTACK="-r SaltStack" @@ -5204,7 +5227,16 @@ install_opensuse_git_post() { [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /bin/systemctl ]; then + use_usr_lib=$BS_FALSE if [ "${DISTRO_MAJOR_VERSION}" -gt 13 ] || ([ "${DISTRO_MAJOR_VERSION}" -eq 13 ] && [ "${DISTRO_MINOR_VERSION}" -ge 2 ]); then + use_usr_lib=$BS_TRUE + fi + + if [ "${DISTRO_MAJOR_VERSION}" -eq 12 ] && [ -d "/usr/lib/systemd/" ]; then + use_usr_lib=$BS_TRUE + fi + + if [ "${use_usr_lib}" -eq $BS_TRUE ]; then __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.service" "/usr/lib/systemd/system/salt-${fname}.service" else __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service" @@ -5371,7 +5403,7 @@ install_suse_12_stable_deps() { } install_suse_12_git_deps() { - install_suse_11_stable_deps || return 1 + install_suse_12_stable_deps || return 1 if ! __check_command_exists git; then __zypper_install git || return 1 diff --git a/tests/runtests.ps1 b/tests/runtests.ps1 new file mode 100644 index 000000000..3d83b85be --- /dev/null +++ b/tests/runtests.ps1 @@ -0,0 +1,105 @@ +<# +.SYNOPSIS + A simple Powershell script to test installed salt minion on windows. + +.PARAMETER version + Salt version installed. + +.PARAMETER runservice + Boolean flag whenever to test if service is running. + +.PARAMETER noservice + Boolean flag whenever to test if service is not running. + +.PARAMETER minion + Name of the minion installed on this host. + +.PARAMETER master + Name of the master configured on this host. + +.EXAMPLE + ./runtests.ps1 + Runs without any parameters. Uses all the default values/settings. +#> + +#=============================================================================== +# Commandlet Binding +#=============================================================================== +[CmdletBinding()] +Param( + [Parameter(Mandatory=$False,ValueFromPipeline=$True)] + [string]$version = $null, + + [Parameter(Mandatory=$False,ValueFromPipeline=$True)] + [switch]$runservice, + + [Parameter(Mandatory=$False,ValueFromPipeline=$True)] + [switch]$noservice, + + [Parameter(Mandatory=$False,ValueFromPipeline=$True)] + [string]$minion = $null, + + [Parameter(Mandatory=$False,ValueFromPipeline=$True)] + [string]$master = $null +) + +#=============================================================================== +# Script Functions +#=============================================================================== +function Get-Grains ([string]$Name) { + $Command = "salt-call --local --out json --out-indent -1 grains.get $Name" + $Result = iex $Command | Out-String | ConvertFrom-Json + + Write-Verbose "salt-call grains.get ${Name}:`n${Result}" + return $Result."local" +} + +function Get-Service-Status([string]$Name) { + $Service = Get-Service $Name -ErrorAction Stop + $Status = $Service.Status + + Write-Verbose "${Name}: ${Status}" + return $Status +} + +function Assert-Equal { + [CmdletBinding()] + Param ( + [Parameter(Mandatory=$True,ValueFromPipeline=$True)] + [string]$Actual, + + [Parameter(Mandatory=$True,ValueFromPipeline=$True)] + [string]$Expected + ) + + If ($Actual -ne $Expected) { + throw "Assert: $Actual != $Expected" + } +} + +#=============================================================================== +# Do enabled checks +#=============================================================================== +if ($True) { + Get-Grains -Name os_family | Assert-Equal -Expected "Windows" +} + +if ($version) { + Get-Grains -Name saltversion | Assert-Equal -Expected $version +} + +if ($master) { + Get-Grains -Name master | Assert-Equal -Expected $master +} + +if ($minion) { + Get-Grains -Name id | Assert-Equal -Expected $minion +} + +if ($runservice) { + Get-Service-Status salt-minion | Assert-Equal -Expected "Running" +} + +if ($noservice) { + Get-Service-Status salt-minion | Assert-Equal -Expected "Stopped" +}