diff --git a/.gitignore b/.gitignore index 33b2c38..3161da8 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,4 @@ /salt-2017.7.0.tar.gz /salt-2017.7.1.tar.gz /salt-2017.7.2.tar.gz +/salt-2017.7.3.tar.gz diff --git a/salt-api.service b/salt-api.service index c3e67d5..7ca582d 100644 --- a/salt-api.service +++ b/salt-api.service @@ -1,5 +1,6 @@ [Unit] Description=The Salt API +Documentation=man:salt-api(1) file:///usr/share/doc/salt/html/contents.html https://docs.saltstack.com/en/latest/contents.html After=network.target [Service] diff --git a/salt-master.service b/salt-master.service index 1f4650f..4996b96 100644 --- a/salt-master.service +++ b/salt-master.service @@ -1,5 +1,6 @@ [Unit] Description=The Salt Master Server +Documentation=man:salt-master(1) file:///usr/share/doc/salt/html/contents.html https://docs.saltstack.com/en/latest/contents.html After=network.target [Service] diff --git a/salt-minion b/salt-minion index 377ca93..6669e75 100644 --- a/salt-minion +++ b/salt-minion @@ -176,7 +176,7 @@ stop() { echo "Service $SERVICE:$MINION_USER:$MINION_ID is not running" return 0 fi - + echo -n "Stopping $SERVICE:$MINION_USER:$MINION_ID daemon: " local pid="$(_get_pid)" diff --git a/salt-minion.service b/salt-minion.service index a4a2b88..2d9a80d 100644 --- a/salt-minion.service +++ b/salt-minion.service @@ -1,8 +1,10 @@ [Unit] Description=The Salt Minion -After=network.target +Documentation=man:salt-minion(1) file:///usr/share/doc/salt/html/contents.html https://docs.saltstack.com/en/latest/contents.html +After=network.target salt-master.service [Service] +KillMode=process Type=notify NotifyAccess=all LimitNOFILE=8192 diff --git a/salt-proxy@.service b/salt-proxy@.service index f97120a..9c5d0a5 100644 --- a/salt-proxy@.service +++ b/salt-proxy@.service @@ -1,9 +1,10 @@ [Unit] -Description=salt-proxy service +Description=salt-proxy service for %i +Documentation=man:salt-proxy(1) file:///usr/share/doc/salt/html/contents.html https://docs.saltstack.com/en/latest/contents.html After=network.target [Service] -ExecStart=/usr/bin/salt-proxy --proxyid=%I +ExecStart=/usr/bin/salt-proxy --proxyid=%i Type=simple Restart=on-failure RestartSec=5s diff --git a/salt-syndic.service b/salt-syndic.service index 5068394..9c9a1e0 100644 --- a/salt-syndic.service +++ b/salt-syndic.service @@ -1,5 +1,6 @@ [Unit] Description=The Salt Master Server +Documentation=man:salt-syndic(1) file:///usr/share/doc/salt/html/contents.html https://docs.saltstack.com/en/latest/contents.html After=network.target [Service] diff --git a/salt.bash b/salt.bash index 7b178ce..00174c0 100644 --- a/salt.bash +++ b/salt.bash @@ -8,7 +8,6 @@ # TODO: --compound[tab] -- how? # TODO: use history to extract some words, esp. if ${cur} is empty # TODO: TEST EVERYTHING a lot -# TODO: cache results of some functions? where? how long? # TODO: is it ok to use '--timeout 2' ? @@ -16,7 +15,7 @@ _salt_get_grains(){ if [ "$1" = 'local' ] ; then salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' else - salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' + salt '*' --timeout 2 --hide-timeout --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' fi } @@ -24,12 +23,26 @@ _salt_get_grain_values(){ if [ "$1" = 'local' ] ; then salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' else - salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' + salt '*' --timeout 2 --hide-timeout --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' fi } +_salt_get_keys(){ + for type in $*; do + # remove header from data: + salt-key --no-color -l $type | tail -n+2 + done +} _salt(){ + CACHE_DIR="$HOME/.cache/salt-comp-cache_functions" + local _salt_cache_functions=${SALT_COMP_CACHE_FUNCTIONS:=$CACHE_DIR} + local _salt_cache_timeout=${SALT_COMP_CACHE_TIMEOUT:='last hour'} + + if [ ! -d "$(dirname ${_salt_cache_functions})" ]; then + mkdir -p "$(dirname ${_salt_cache_functions})" + fi + local cur prev opts _salt_grains _salt_coms pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -86,11 +99,11 @@ _salt(){ return 0 ;; salt) - COMPREPLY=($(compgen -W "\'*\' ${opts} `salt-key --no-color -l acc`" -- ${cur})) + COMPREPLY=($(compgen -W "\'*\' ${opts} $(_salt_get_keys acc)" -- ${cur})) return 0 ;; -E|--pcre) - COMPREPLY=($(compgen -W "`salt-key --no-color -l acc`" -- ${cur})) + COMPREPLY=($(compgen -W "$(_salt_get_keys acc)" -- ${cur})) return 0 ;; -G|--grain|--grain-pcre) @@ -116,7 +129,23 @@ _salt(){ ;; esac - _salt_coms="$(salt '*' --timeout 2 --out=txt -- sys.list_functions | sed 's/^.*\[//' | tr -d ",']" )" + # Regenerate cache if timed out + if [[ "$(stat --format=%Z ${_salt_cache_functions} 2>/dev/null)" -lt "$(date --date="${_salt_cache_timeout}" +%s)" ]]; then + # salt: get all functions on all minions + # sed: remove all array overhead and convert to newline separated list + # sort: chop out doubled entries, so overhead is minimal later during actual completion + salt '*' --timeout 2 --hide-timeout --out=txt -- sys.list_functions \ + | sed "s/^.*\[//;s/[],']//g;s/ /\n/g" \ + | sort -u \ + > "${_salt_cache_functions}" + fi + + # filter results, to only print the part to next dot (or end of function) + _salt_coms="$(sed 's/^\('${cur}'\(\.\|[^.]*\)\)\?.*/\1/' "${_salt_cache_functions}" | sort -u)" + + # If there are still dots in the suggestion, do not append space + grep "^${cur}.*\." "${_salt_cache_functions}" &>/dev/null && compopt -o nospace + all="${opts} ${_salt_coms}" COMPREPLY=( $(compgen -W "${all}" -- ${cur}) ) @@ -158,15 +187,15 @@ _saltkey(){ case "${prev}" in -a|--accept) - COMPREPLY=($(compgen -W "$(salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur})) + COMPREPLY=($(compgen -W "$(_salt_get_keys un rej)" -- ${cur})) return 0 ;; -r|--reject) - COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color)" -- ${cur})) + COMPREPLY=($(compgen -W "$(_salt_get_keys acc)" -- ${cur})) return 0 ;; -d|--delete) - COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur})) + COMPREPLY=($(compgen -W "$(_salt_get_keys acc un rej)" -- ${cur})) return 0 ;; -c|--config) @@ -185,7 +214,7 @@ _saltkey(){ return 0 ;; -p|--print) - COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur})) + COMPREPLY=($(compgen -W "$(_salt_get_keys acc un rej)" -- ${cur})) return 0 ;; -l|--list) @@ -280,7 +309,7 @@ _saltcp(){ case ${prev} in salt-cp) - COMPREPLY=($(compgen -W "${opts} `salt-key -l acc --no-color`" -- ${cur})) + COMPREPLY=($(compgen -W "${opts} $(_salt_get_keys acc)" -- ${cur})) return 0 ;; -t|--timeout) @@ -289,7 +318,7 @@ _saltcp(){ return 0 ;; -E|--pcre) - COMPREPLY=($(compgen -W "`salt-key -l acc --no-color`" -- ${cur})) + COMPREPLY=($(compgen -W "$(_salt_get_keys acc)" -- ${cur})) return 0 ;; -L|--list) @@ -297,7 +326,7 @@ _saltcp(){ prefpart="${cur%,*}," postpart=${cur##*,} filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$" - helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/")) + helper=($(_salt_get_keys acc | grep -v "${filt}" | sed "s/^/${prefpart}/")) COMPREPLY=($(compgen -W "${helper[*]}" -- ${cur})) return 0 diff --git a/salt.spec b/salt.spec index a459e04..a5cd8e5 100644 --- a/salt.spec +++ b/salt.spec @@ -29,7 +29,6 @@ %global __python2 %{_bindir}/python%{?pybasever} %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") -%global __os_install_post %{__python27_os_install_post} %endif %endif @@ -42,7 +41,7 @@ %define fish_dir %{_datadir}/fish/vendor_functions.d Name: salt -Version: 2017.7.2 +Version: 2017.7.3%{?__rc_ver} Release: 1%{?dist} Summary: A parallel remote execution system @@ -91,7 +90,6 @@ Requires: dnf-utils Requires: yum-utils %endif - %if ((0%{?rhel} >= 6 || 0%{?fedora} > 12) && 0%{?include_tests}) BuildRequires: python%{?__python_ver}-tornado >= 4.2.1 BuildRequires: python%{?__python_ver}-futures >= 2.0 @@ -108,7 +106,8 @@ BuildRequires: PyYAML %endif BuildRequires: python%{?__python_ver}-requests -BuildRequires: python%{?__python_ver}-unittest2 +## BuildRequires: python%{?__python_ver}-unittest2 + # this BR causes windows tests to happen # clearly, that's not desired # https://github.com/saltstack/salt/issues/3749 @@ -627,6 +626,9 @@ rm -rf %{buildroot} %endif %changelog +* Tue Jan 30 2018 SaltStack Packaging Team - 2017.7.3-1 +- Update to feature release 2017.7.3-1 + * Mon Sep 18 2017 SaltStack Packaging Team - 2017.7.2-1 - Update to feature release 2017.7.2 diff --git a/sources b/sources index 0e86edf..e75d6f2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (salt-2017.7.2.tar.gz) = 959cec404f0fa7c00f78427cba902b8b9c2c0d95016fc70925d8da6d0b97a0284fc034ac92a5c5c313763db4fdcbd1b0391318596b77fe8e0cd1c7e4b3fa928b +SHA512 (salt-2017.7.3.tar.gz) = 0452ad6cf2a9bcecd0056f0a6f4871e36bf2abe8c207c93f79e1e9ace608b7ba2158e958a71121f230969ff0b32ffd26f048e369003f844eaf3f4f9dd4b4a19a