Thanks to visit codestin.com
Credit goes to github.com

Skip to content

service.enabled (and possibly others) can't find a service if ".service" is appended to service name #26358

@MoonSweep

Description

@MoonSweep

Hi,

In systemd, the true name for a service ends with ".service", the form without this suffix being merely a shortcut. SaltStack doesn't understand this:

enable-systemd-timesyncd:
  service.enabled:
    - name: systemd-timesyncd.service

...results in:

          ID: enable-systemd-timesyncd
    Function: service.enabled
        Name: systemd-timesyncd.service
      Result: False
     Comment: The named service systemd-timesyncd.service is not available
     Started: 15:33:45.193092
    Duration: 157.018 ms
     Changes:   

If I remove ".service", it works:

enable-systemd-timesyncd:
  service.enabled:
    - name: systemd-timesyncd

...results in:

          ID: enable-systemd-timesyncd
    Function: service.enabled
        Name: systemd-timesyncd
      Result: True
     Comment: Service systemd-timesyncd is already enabled, and is in the desired state
     Started: 15:31:11.620675
    Duration: 171.07 ms
     Changes:   

The form ending in ".service" being the true form, and the one without the suffix being a shortcut (emphasized by the bash completion for systemctl command), I think SaltStack should understand both and not give an error if ".service" is added to a service name.

Moreover, other suffices work as expected. For example, to have /tmp mounted in a ramdisk:

enable-ramtmp:
  service.enabled:
    - name: tmp.mount

...results in:

          ID: enable-ramtmp
    Function: service.enabled
        Name: tmp.mount
      Result: True
     Comment: Service tmp.mount is already enabled, and is in the desired state
     Started: 15:31:11.799996
    Duration: 170.061 ms
     Changes:   

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Execution-ModuleP2Priority 2PlatformRelates to OS, containers, platform-based utilities like FS, system based appsbugbroken, incorrect, or confusing behaviorhelp-wantedCommunity help is needed to resolve thisseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work aroundstale

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions