diff --git a/.gitignore b/.gitignore index 3738e14..3ba5330 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,4 @@ /salt-2018.3.2.tar.gz /salt-2018.3.3.tar.gz /salt-2019.2.0.tar.gz +/salt-2019.2.1rc0.tar.gz diff --git a/salt.bash b/salt.bash index 7b9f166..35fe069 100644 --- a/salt.bash +++ b/salt.bash @@ -13,17 +13,17 @@ _salt_get_grains(){ if [ "$1" = 'local' ] ; then - salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' + salt-call --log-level=error --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' else - salt '*' --timeout 2 --hide-timeout --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' + salt '*' --timeout 2 --hide-timeout --log-level=error --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' fi } _salt_get_grain_values(){ if [ "$1" = 'local' ] ; then - salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' + salt-call --log-level=error --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' else - salt '*' --timeout 2 --hide-timeout --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' + salt '*' --timeout 2 --hide-timeout --log-level=error --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' fi } @@ -34,8 +34,24 @@ _salt_get_keys(){ done } -_salt(){ - CACHE_DIR="$HOME/.cache/salt-comp-cache_functions" +_salt_list_functions(){ + # salt-call: get all functions on this minion + # 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 + if [ "$1" = 'local' ] ; then + salt-call --log-level=quiet --out=txt -- sys.list_functions \ + | sed "s/^.*\[//;s/[],']//g;s/ /\n/g" \ + | sort -u + else + salt '*' --timeout 2 --hide-timeout --log-level=quiet --out=txt -- sys.list_functions \ + | sed "s/^.*\[//;s/[],']//g;s/ /\n/g" \ + | sort -u + fi +} + +_salt_get_coms() { + CACHE_DIR="$HOME/.cache/salt-${1}-comp-cache_functions" local _salt_cache_functions=${SALT_COMP_CACHE_FUNCTIONS:=$CACHE_DIR} local _salt_cache_timeout=${SALT_COMP_CACHE_TIMEOUT:='last hour'} @@ -43,6 +59,17 @@ _salt(){ mkdir -p "$(dirname ${_salt_cache_functions})" fi + # Regenerate cache if timed out + if [[ "$(stat --format=%Z ${_salt_cache_functions} 2>/dev/null)" -lt "$(date --date="${_salt_cache_timeout}" +%s)" ]]; then + _salt_list_functions $1 > "${_salt_cache_functions}" + fi + + # filter results, to only print the part to next dot (or end of function) + sed 's/^\('${cur}'\(\.\|[^.]*\)\)\?.*/\1/' "${_salt_cache_functions}" | sort -u +} + +_salt(){ + local cur prev opts _salt_grains _salt_coms pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -129,22 +156,10 @@ _salt(){ ;; esac - # 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)" + _salt_coms=$(_salt_get_coms remote) # If there are still dots in the suggestion, do not append space - grep "^${cur}.*\." "${_salt_cache_functions}" &>/dev/null && compopt -o nospace + grep "^${cur}.*\." "${_salt_coms}" &>/dev/null && compopt -o nospace all="${opts} ${_salt_coms}" COMPREPLY=( $(compgen -W "${all}" -- ${cur}) ) @@ -276,7 +291,11 @@ _saltcall(){ ;; esac - _salt_coms="$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']" )" + _salt_coms=$(_salt_get_coms local) + + # If there are still dots in the suggestion, do not append space + grep "^${cur}.*\." "${_salt_coms}" &>/dev/null && compopt -o nospace + COMPREPLY=( $(compgen -W "${opts} ${_salt_coms}" -- ${cur} )) return 0 } diff --git a/salt.spec b/salt.spec index bcf7291..4b1666b 100644 --- a/salt.spec +++ b/salt.spec @@ -1,18 +1,19 @@ -%global pybasever 2.7 -%global __python2 %{_bindir}/python%{?pybasever} -%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} -%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} -%{!?pythonpath: %global pythonpath %(%{__python2} -c "import os, sys; print(os.pathsep.join(x for x in sys.path if x))")} +%bcond_with tests +%bcond_with docs +%{!?python3_pkgversion:%global python3_pkgversion 3} %global include_tests 0 +# Release Candidate +%define __rc_ver rc0 + %define fish_dir %{_datadir}/fish/vendor_functions.d -Name: salt -Version: 2019.2.0 -Release: 2%{?dist} +Name: salt +Version: 2019.2.1%{?__rc_ver} +Release: 1%{?dist} Summary: A parallel remote execution system License: ASL 2.0 @@ -54,55 +55,37 @@ Requires: which Requires: dnf-utils -%if ((0%{?fedora} >= 28) && 0%{?include_tests}) -BuildRequires: python2-tornado >= 4.2.1 -BuildRequires: python2-futures >= 2.0 -BuildRequires: python2-crypto >= 2.6.1 -BuildRequires: python2-jinja2 -BuildRequires: python2-msgpack >= 0.4 -BuildRequires: python2-pip -BuildRequires: python2-zmq >= 14.5 - -BuildRequires: python2-pyyaml - -BuildRequires: python2-requests -## BuildRequires: python2-unittest2 - -# this BR causes windows tests to happen -# clearly, that's not desired -# https://github.com/saltstack/salt/issues/3749 -BuildRequires: python2-mock -BuildRequires: git -BuildRequires: python2-libcloud -BuildRequires: python2-six - -%endif ## (0%%{?fedora} >= 28) && 0%%{?include_tests}) - -BuildRequires: python2-devel - -Requires: python2-jinja2 -Requires: python2-msgpack >= 0.4 -Requires: python2-crypto >= 2.6.1 -Requires: python2-pyyaml -Requires: python2-requests >= 1.0.0 -Requires: python2-zmq -Requires: python2-markupsafe -Requires: python2-tornado >= 4.2.1, python2-tornado < 6.0 -Requires: python2-futures >= 2.0 -Requires: python2-six -Requires: python2-psutil - - %if 0%{?systemd_preun:1} - Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units - %endif BuildRequires: systemd-units -Requires: systemd-python +Requires: python%{python3_pkgversion}-systemd + +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-requests +BuildRequires: python%{python3_pkgversion}-mock +BuildRequires: python%{python3_pkgversion}-libcloud +BuildRequires: python%{python3_pkgversion}-six +BuildRequires: python%{python3_pkgversion}-pyyaml +BuildRequires: git + +Requires: python%{python3_pkgversion}-jinja2 +Requires: python%{python3_pkgversion}-msgpack >= 0.4 + +## Requires: python%%{python3_pkgversion}-crypto >= 2.6.1 +Requires: python%{python3_pkgversion}-m2crypto >= 0.31.0 + +Requires: python%{python3_pkgversion}-requests +Requires: python%{python3_pkgversion}-zmq +Requires: python%{python3_pkgversion}-markupsafe +Requires: python%{python3_pkgversion}-tornado4 >= 4.2.1 +Requires: python%{python3_pkgversion}-six +Requires: python%{python3_pkgversion}-psutil +Requires: python%{python3_pkgversion}-pyyaml + %description @@ -113,55 +96,73 @@ malleable. Salt accomplishes this via its ability to handle larger loads of information, and not just dozens, but hundreds or even thousands of individual servers, handle them quickly and through a simple and manageable interface. -%package master -Summary: Management component for salt, a parallel remote execution system -Requires: %{name} = %{version}-%{release} -Requires: systemd-python +%package master +Summary: Management component for salt, a parallel remote execution system +Group: System Environment/Daemons +Requires: %{name} = %{version}-%{release} +Requires: python%{python3_pkgversion}-systemd %description master The Salt master is the central server to which all minions connect. +Supports Python 3. + -%package minion -Summary: Client component for Salt, a parallel remote execution system -Requires: %{name} = %{version}-%{release} +%package minion +Summary: Client component for Salt, a parallel remote execution system +Group: System Environment/Daemons +Requires: %{name} = %{version}-%{release} %description minion The Salt minion is the agent component of Salt. It listens for instructions from the master, runs jobs, and returns results back to the master. +Supports Python 3. -%package syndic -Summary: Master-of-master component for Salt, a parallel remote execution system -Requires: %{name}-master = %{version}-%{release} + +%package syndic +Summary: Master-of-master component for Salt, a parallel remote execution system +Group: System Environment/Daemons +Requires: %{name}-master = %{version}-%{release} %description syndic The Salt syndic is a master daemon which can receive instruction from a higher-level master, allowing for tiered organization of your Salt infrastructure. +Supports Python 3. + -%package api -Summary: REST API for Salt, a parallel remote execution system -Requires: %{name}-master = %{version}-%{release} -Requires: python2-cherrypy >= 3.2.2, python2-cherrypy < 18.0.0 +%package api +Summary: REST API for Salt, a parallel remote execution system +Group: Applications/System +Requires: %{name}-master = %{version}-%{release} +Requires: python%{python3_pkgversion}-cherrypy >= 3.2.2 %description api salt-api provides a REST interface to the Salt master. +Supports Python 3. + -%package cloud -Summary: Cloud provisioner for Salt, a parallel remote execution system -Requires: %{name}-master = %{version}-%{release} -Requires: python2-libcloud +%package cloud +Summary: Cloud provisioner for Salt, a parallel remote execution system +Group: Applications/System +Requires: %{name}-master = %{version}-%{release} +Requires: python%{python3_pkgversion}-libcloud %description cloud The salt-cloud tool provisions new cloud VMs, installs salt-minion on them, and adds them to the master's collection of controllable minions. +Supports Python 3. -%package ssh -Summary: Agentless SSH-based version of Salt, a parallel remote execution system -Requires: %{name} = %{version}-%{release} + +%package ssh +Summary: Agentless SSH-based version of Salt, a parallel remote execution system +Group: Applications/System +Requires: %{name} = %{version}-%{release} %description ssh The salt-ssh tool can run remote execution functions and states without the use of an agent (salt-minion) service. +Supports Python 3. + %prep %setup -q -c @@ -170,13 +171,24 @@ of an agent (salt-minion) service. cd %{name}-%{version} ## %%patch0 -p1 + +rm -rf %{py3dir} +cp -a . %{py3dir} + + %build +pushd %{py3dir} +%py3_build +popd %install rm -rf %{buildroot} cd $RPM_BUILD_DIR/%{name}-%{version}/%{name}-%{version} -%{__python2} setup.py install -O1 %{?__inst_layout } --root %{buildroot} + +## rm -rf %%{buildroot} +pushd %{py3dir} +%py3_install # Add some directories install -d -m 0755 %{buildroot}%{_var}/log/salt @@ -189,19 +201,19 @@ install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/minion.d install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/pki install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/pki/master install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/pki/minion -install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/cloud.conf.d -install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/cloud.deploy.d -install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/cloud.maps.d -install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/cloud.profiles.d -install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/cloud.providers.d +install -d -m 0700 %{buildroot}%{_sysconfdir}/salt/cloud.conf.d +install -d -m 0700 %{buildroot}%{_sysconfdir}/salt/cloud.deploy.d +install -d -m 0700 %{buildroot}%{_sysconfdir}/salt/cloud.maps.d +install -d -m 0700 %{buildroot}%{_sysconfdir}/salt/cloud.profiles.d +install -d -m 0700 %{buildroot}%{_sysconfdir}/salt/cloud.providers.d install -d -m 0755 %{buildroot}%{_sysconfdir}/salt/proxy.d # Add the config files install -p -m 0640 conf/minion %{buildroot}%{_sysconfdir}/salt/minion install -p -m 0640 conf/master %{buildroot}%{_sysconfdir}/salt/master -install -p -m 0640 conf/cloud %{buildroot}%{_sysconfdir}/salt/cloud +install -p -m 0600 conf/cloud %{buildroot}%{_sysconfdir}/salt/cloud install -p -m 0640 conf/roster %{buildroot}%{_sysconfdir}/salt/roster -install -p -m 0640 conf/proxy %{buildroot}%{_sysconfdir}/salt/proxy +install -p -m 0640 conf/proxy %{buildroot}%{_sysconfdir}/salt/proxy # Add the unit files mkdir -p %{buildroot}%{_unitdir} @@ -232,32 +244,35 @@ install -p -m 0644 %{SOURCE19} %{buildroot}%{fish_dir}/salt-minion.fish install -p -m 0644 %{SOURCE20} %{buildroot}%{fish_dir}/salt-run.fish install -p -m 0644 %{SOURCE21} %{buildroot}%{fish_dir}/salt-syndic.fish -%if ((0%{?fedora} >= 28) && 0%{?include_tests}) -%check -cd $RPM_BUILD_DIR/%{name}-%{version}/%{name}-%{version} -mkdir %{_tmppath}/salt-test-cache -PYTHONPATH=%{pythonpath} %{__python2} setup.py test --runtests-opts=-u -%endif +popd -%files -%doc $RPM_BUILD_DIR/%{name}-%{version}/%{name}-%{version}/LICENSE -%{python2_sitelib}/%{name}/* -#%%{python2_sitelib}/%%{name}-%%{version}-py?.?.egg-info -%{python2_sitelib}/%{name}-*-py?.?.egg-info +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%{python3_sitelib}/%{name}/* +%{python3_sitelib}/%{name}-*-py?.?.egg-info %{_sysconfdir}/logrotate.d/salt %{_sysconfdir}/bash_completion.d/salt.bash %{_var}/cache/salt %{_var}/log/salt -%doc $RPM_BUILD_DIR/%{name}-%{version}/%{name}-%{version}/README.fedora -%{_bindir}/spm + +## %%doc $RPM_BUILD_DIR/%%{name}-%%{version}/%%{name}-%%{version}/LICENSE +## %%doc $RPM_BUILD_DIR/%%{name}-%%{version}/%%{name}-%%{version}/README.fedora +%doc $RPM_BUILD_DIR/python3-%{name}-%{version}-%{release}/LICENSE +%doc $RPM_BUILD_DIR/python3-%{name}-%{version}-%{release}/README.fedora + +/%{_bindir}/spm %doc %{_mandir}/man1/spm.1* %config(noreplace) %{_sysconfdir}/salt/ %config(noreplace) %{_sysconfdir}/salt/pki %config(noreplace) %{fish_dir}/salt*.fish %files master +%defattr(-,root,root) %doc %{_mandir}/man7/salt.7* %doc %{_mandir}/man1/salt.1* %doc %{_mandir}/man1/salt-cp.1* @@ -277,6 +292,7 @@ PYTHONPATH=%{pythonpath} %{__python2} setup.py test --runtests-opts=-u %config(noreplace) %{_sysconfdir}/salt/pki/master %files minion +%defattr(-,root,root) %doc %{_mandir}/man1/salt-call.1* %doc %{_mandir}/man1/salt-minion.1* %doc %{_mandir}/man1/salt-proxy.1* @@ -296,6 +312,7 @@ PYTHONPATH=%{pythonpath} %{__python2} setup.py test --runtests-opts=-u %{_unitdir}/salt-syndic.service %files api +%defattr(-,root,root) %doc %{_mandir}/man1/salt-api.1* %{_bindir}/salt-api %{_unitdir}/salt-api.service @@ -438,6 +455,9 @@ PYTHONPATH=%{pythonpath} %{__python2} setup.py test --runtests-opts=-u %changelog +* Thu Aug 29 2019 Fedora Release Engineering - 2019.2.1rc0-1 +- Release Candidate 0 for feature release 2019.2.1 for Python 3 with Tornado v5.x support + * Fri Jul 26 2019 Fedora Release Engineering - 2019.2.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild diff --git a/salt_common.fish b/salt_common.fish index ad5b04d..80d5da7 100644 --- a/salt_common.fish +++ b/salt_common.fish @@ -75,7 +75,7 @@ set -l salt_programs_select salt salt-cp for program in $salt_programs_select complete -c $program -f -s G -l grain -d "Instead of using shell globs to evaluate the target use a grain value to identify targets, the syntax for the target is the grain key followed by a globexpression: \"os:Arch*\"" complete -c $program -f -l grain-pcre -d "Instead of using shell globs to evaluate the target use a grain value to identify targets, the syntax for the target is the grain key followed by a pcre regular expression: \"os:Arch.*\"" - complete -c $program -f -s L -l list -d "Instead of using shell globs to evaluate the target servers, take a comma or space delimited list of servers." + complete -c $program -f -s L -l list -d "Instead of using shell globs to evaluate the target servers, take a comma or whitespace delimited list of servers." complete -c $program -f -s N -l nodegroup -d "Instead of using shell globs to evaluate the target use one of the predefined nodegroups to identify a list of targets." complete -c $program -f -s E -l pcre -d "Instead of using shell globs to evaluate the target servers, use pcre regular expressions" complete -c $program -f -s R -l range -d "Instead of using shell globs to evaluate the target use a range expression to identify targets. Range expressions look like %cluster" diff --git a/sources b/sources index e041f6d..8f7674b 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (salt-2019.2.0.tar.gz) = de5a976213d011c230e423a172952effddb87168367958b8657eaaaf8fd2a8bec8471f547b6ff9e896a17064a13d387dbc12e12c605c8a241062e3238bd19eca +SHA512 (salt-2019.2.1rc0.tar.gz) = 541071683d4878b86ac61a912396732cb24d8886e98e66c980e4a06af4262df68a5822f6f6a766e309bd43de6e824a2952a57198cf97a9c9818b08fca97a6072