Skip to content
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

Static units cannot be enabled #180

Closed
TwizzyDizzy opened this issue Feb 27, 2021 · 1 comment
Closed

Static units cannot be enabled #180

TwizzyDizzy opened this issue Feb 27, 2021 · 1 comment

Comments

@TwizzyDizzy
Copy link

TwizzyDizzy commented Feb 27, 2021

Description

systemd version: 219
module version: 2.12.0

definition of worker.target

root@tst-api01 ~ # systemctl cat worker.target
# /etc/systemd/system/worker.target
[Unit]
Description=Queue Workers
Wants=rabbitmq-server.service [email protected] api-default-queue

[Install]
WantedBy=multi-user.target

Definition of api-default-queue.service (instantiated from template) in hiera:

systemd::manage::unit_file:
  [email protected]:
    content: |
      [Unit]
      Description=default-queue-%i
      BindsTo=worker.target

      [Service]
      Type=simple
      ExecStart=FOO
      SyslogIdentifier=default-queue-%i
      Group=FOO
      User=FOO
      Restart=on-failure
      RestartSec=10
      TimeoutStartSec=10
  [email protected]:
    enable: true
    active: true

Expected behaviour:

Puppet tries to enables that unit but realizes that it's a static unit and does nothing.

Actual behaviour

Puppet restarts the unit

Debug: Executing: '/bin/systemctl is-enabled -- [email protected]'
Debug: Executing: '/bin/systemctl unmask -- [email protected]'
Debug: Executing: '/bin/systemctl enable -- [email protected]'
Debug: Executing: '/bin/systemctl is-enabled -- [email protected]'
Debug: Unable to enable or disable static service [email protected]
Notice: /Stage[main]/Systemd::Manage/Systemd::Unit_file[[email protected]]/Service[[email protected]]/enable: enable changed 'false' to 'true'

leads to

Feb 20 19:18:28 prd-api01 systemd[1]: Stopped api-default-queue-1.
Feb 20 19:18:28 prd-api01 systemd[1]: Started api-default-queue-1.

Suggested behaviour:

It's eventually a clash of responsibilites between systemd and puppet. Meaning: "who is, in the end, reponsible for managing the state of that unit". With harder dependencies, it seems to rather be within system`s jurisdiction, on the other hand though, when there are no hard bindings between units, it makes sense for puppet to manage that unit.

Since it obviously does not make sense for the module to try to understand the interdependency between defined units (in order to not allow enable: true for static units), I'd suggest that this module accepts "static" as a valid return-value (instead of only "enable" now, probably - not verified) for systemctl is-enabled $UNIT.

@TwizzyDizzy
Copy link
Author

Turns out I have misused the module. I tried to manage instantiated units via systemd::manage::unit_file while I should have been managing those with systemd::manage::services.

Sorry for the irritation.

Cheers
Thomas

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

No branches or pull requests

1 participant