2

I'm trying to set up some user services using Ansible and systemd.

On Ubuntu and RHEL 7 I'm getting

# systemctl --user status
Failed to get D-Bus connection: Connection refused

For Ubuntu I clarified the error, it's because of this:

https://docs.ansible.com/ansible/latest/modules/systemd_module.html

run systemctl within a given service manager scope, either as the default system scope (system), the current user's scope (user), or the scope of all users (global). For systemd to work with 'user', the executing user must have its own instance of dbus started (systemd requirement). The user dbus process is normally started during normal login, but not during the run of Ansible tasks. Otherwise you will probably get a 'Failed to connect to bus: no such file or directory' error.

Basically DBus needs to be started before systemd --user can work. I'm not sure how to do that either, but I can work around it in other ways, I think.

However, the main blocker right now is: how do I check, generically, for the availability of the functionality?

I tried systemctl show and there's no explicit "user" feature. Is the flag the "+PAM" from the Features line? I know that systemd uses PAM at least partially to implement it, I don't know if it's needed for other features.

How can I check that "my" systemd supports --user in a reliable manner? Is there a file I could check? A command? Something else? DBus voodoo?

oblio
  • 121
  • 2

0 Answers0