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

Failed systemd service task under root: Failed to connect to bus: Operation not permitted #125

Open
petRUShka opened this issue Oct 2, 2024 · 1 comment

Comments

@petRUShka
Copy link
Contributor

petRUShka commented Oct 2, 2024

The [gnupg : Enable gpg-agent.socket] task works well under sudo ansible-playbook -i localhost playbook.yml and fails if I run it under su (e.g. as root)

TASK [gnupg : Enable gpg-agent.socket] ***************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/systemctl --user", "msg": "Failed to connect to bus: Operation not permitted", "rc": 1, "stderr": "Failed t
o connect to bus: Operation not permitted\n", "stderr_lines": ["Failed to connect to bus: Operation not permitted"], "stdout": "", "stdout_lines": []}

Task code is:

- name: Enable gpg-agent.socket
  systemd:
    name: gpg-agent.socket
    scope: user
    enabled: yes
    state: started
  become: yes
  become_user: "{{ user.name }}"
  environment:
    XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
  when: gnupg.enable_agent == True
@pigmonkey
Copy link
Owner

Try changing the scope from user to global in the task (and the other user socket tasks in that file). That may work.

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

2 participants