From 276ad4f8f5cfb2e0a86a93c0f47837a20fd3799e Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 1 Dec 2020 10:25:15 -0500 Subject: [PATCH] added more specific info about user scope (#72680) in ref of #72674 --- lib/ansible/modules/systemd.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/systemd.py b/lib/ansible/modules/systemd.py index 5446e523da7..1c75be55547 100644 --- a/lib/ansible/modules/systemd.py +++ b/lib/ansible/modules/systemd.py @@ -60,9 +60,11 @@ options: description: - 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. + - "For systemd to work with 'user', the executing user must have its own instance of dbus started and accessible (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." + - The user must have access, normally given via setting the ``XDG_RUNTIME_DIR`` variable, see example below. + type: str choices: [ system, user, global ] default: system @@ -124,6 +126,14 @@ EXAMPLES = ''' - name: Just force systemd to re-execute itself (2.8 and above) systemd: daemon_reexec: yes + +- name: run a user service when XDG_RUNTIME_DIR is not set on remote login. + systemd: + name: myservice + state: started + scope: user + environment: + XDG_RUNTIME_DIR: "/run/user/{{ myuid }}" ''' RETURN = '''