[Pkg-salt-team] Bug#770174: Bug#770174: salt-common: service module doesn't work for init scripts

Joe Healy joehealy at gmail.com
Tue Nov 25 00:28:30 UTC 2014


Thanks Julien,

I'll apply this fix and upload tonight. I'll also look at the other fixes
made upstream on the 2014.1 branch.

Joe

On Wed, Nov 19, 2014 at 10:43 PM, Julien Cristau <julien.cristau at logilab.fr>
wrote:

> Package: salt-common
> Version: 2014.1.13+ds-1
> Severity: grave
> Tags: patch upstream fixed-upstream
> Justification: renders package unusable
>
> Hi,
>
> when booting with systemd, the service module is provided by
> salt/modules/systemd.py, which only considers native systemd units in
> its get_all function, not services provided by init scripts.  This
> breaks the service state.
>
> The fix is in upstream commits
> 90bece1faa1862465e97f7caf262c65cd84583ff and
> 968b26f45351d790a9fa2afd9bbd6c5bb31f13d5, so basically:
>
> diff --git a/salt/modules/systemd.py b/salt/modules/systemd.py
> --- a/salt/modules/systemd.py
> +++ b/salt/modules/systemd.py
> @@ -72,6 +74,28 @@ def _systemctl_cmd(action, name):
>      return 'systemctl {0} {1}'.format(action, _canonical_unit_name(name))
>
>
> +def _get_all_units():
> +    '''
> +    Get all units and their state. Units ending in .service
> +    are normalized so that they can be referenced without a type suffix.
> +    '''
> +    rexp = re.compile(r'(?m)^(?P<name>.+)\.(?P<type>' +
> +                      '|'.join(VALID_UNIT_TYPES) +
> +                      r')\s+loaded\s+(?P<active>[^\s]+)')
> +
> +    out = __salt__['cmd.run_stdout'](
> +        'systemctl --all --full --no-legend --no-pager list-units | col
> -b'
> +    )
> +
> +    ret = {}
> +    for match in rexp.finditer(out):
> +        name = match.group('name')
> +        if match.group('type') != 'service':
> +            name += '.' + match.group('type')
> +        ret[name] = match.group('active')
> +    return ret
> +
> +
>  def _get_all_unit_files():
>      '''
>      Get all unit files and their state. Unit files ending in .service
> @@ -173,7 +197,7 @@ def get_all():
>
>          salt '*' service.get_all
>      '''
> -    return sorted(_get_all_unit_files().keys())
> +    return sorted(set(_get_all_units().keys() +
> _get_all_unit_files().keys()))
>
>
>  def available(name):
>
>
> There are a few other fixes in that file that might be worth
> considering, but at least the above is I think necessary for salt to
> be in decent shape for jessie.
>
> Cheers,
> Julien
> --
> Julien Cristau          <julien.cristau at logilab.fr>
> Logilab                 http://www.logilab.fr/
> Informatique scientifique & gestion de connaissances
>
> _______________________________________________
> pkg-salt-team mailing list
> pkg-salt-team at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-salt-team
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-salt-team/attachments/20141125/d96a83a2/attachment.html>


More information about the pkg-salt-team mailing list