Skip to content

Better handling of systemd parametrised and other special units not listed by list-unit-files. #11921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2014

Conversation

mtorromeo
Copy link
Contributor

This allows to query status, start, stop, restart and list units that are not actually provided by unit files. Such units cannot be enabled/disabled and that's why those actions still prefer the "list-unit-files" output over "list-units".

Units that couldn't be handled otherwise include for example mount units and sysvinit compatibility units such as those present on debian systems.

The output of a "service.running ssh" state on a debian wheezy target is:

      ID: ssh
Function: service.running
  Result: False
 Comment: The named service ssh is not available
 Changes:

after this patch:

      ID: ssh
Function: service.running
  Result: True
 Comment: The service ssh is already running
 Changes:

This allows to query status, start, stop, restart and list units that
are not actually provided by unit files. Such units cannot be
enabled/disabled and that's why those actions still prefer the
"list-unit-files" output over "list-units".

Units that couldn't be handled otherwise include for example mount
units and sysvinit compatibility units such as those present on
debian systems.

The output of a "service.running ssh" state on a debian wheezy target
is:

          ID: ssh
    Function: service.running
      Result: False
     Comment: The named service ssh is not available
     Changes:

after this patch:

          ID: ssh
    Function: service.running
      Result: True
     Comment: The service ssh is already running
     Changes:
@ghost
Copy link

ghost commented Apr 11, 2014

Test Failed.

If the failures are unrelated to your code, don't stress, a core developer will know these apart.
In the future, if possible, please branch off a passing commit to avoid false positives.
Refer to this link for build results: http://jenkins.saltstack.com/job/salt-pr-build/3248/

@cachedout
Copy link
Contributor

This may have some bearing on #8444 too. Nice work.

@mtorromeo
Copy link
Contributor Author

Yes, this will partially fix #8444, meaning that a service like openvpn@example can be started by salt but still cannot be enabled.

Enabling such services will require special handling of service names containg @ but I think I may try and implement it in a separate pull request, while this one can be merged on its own.

@cachedout
Copy link
Contributor

@mtorromeo Sounds great. Thanks again for your work here. Looking forward to your additional PRs to improve systemd support!

This makes the systemd.get_all function return the combined output of
list-units and list-unit-files and the systemd.available function will
also check for the base unit name stripped of the user parameter
(e.g. dhcpcd@eth0 will be considered available if [email protected] exists)
@mtorromeo
Copy link
Contributor Author

I decided to go ahead and implement here the missing pieces to handle parametrised units in the systemd state.

With this a state such as the following will work as expected:

dhcpcd@eth0:
service.running:
  enable: True
  reload: True

@mtorromeo mtorromeo changed the title Allow systemd units not provided by unit files to be handled. Better handling of systemd parametrised and other special units not listed by list-unit-files. Apr 14, 2014
@ghost
Copy link

ghost commented Apr 14, 2014

Test Failed.

If the failures are unrelated to your code, don't stress, a core developer will know these apart.
In the future, if possible, please branch off a passing commit to avoid false positives.
Refer to this link for build results: http://jenkins.saltstack.com/job/salt-pr-build/3363/

@mtorromeo
Copy link
Contributor Author

Looking at the systemd related bug reports, this should fix #10309 #8444 #11900

thatch45 added a commit that referenced this pull request Apr 14, 2014
Better handling of systemd parametrised and other special units not listed by list-unit-files.
@thatch45 thatch45 merged commit 2d7da41 into saltstack:develop Apr 14, 2014
@mtorromeo mtorromeo deleted the systemd-units branch April 17, 2014 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants