ansible systemd module does not work correctly with global scope in newer systemd versions
Author: dadukeCreated Aug 21, 2025Updated Sep 17, 2026
Labelsmodulebughas_prP3needs_verifiedaffects_2.18
Summary
Dear all,
systemd 253 (release in early 2023) changed behavior when using the --global scope attribute. Certain systemctl verbs do not allow --global any more, resulting in --global is not supported for this operation.. Examples are show and cat, among others.
The ansible systemd module does not make this distinction and appends --global to all systemctl invocations if scope: global is specified. Exhibit A:
https://github.com/ansible/ansible/blob/0467e1eaa930dbe885192579d829d38f2d9d2f2c/lib/ansible/modules/systemd_service.py#L420
This results in an error message e.g. on Debian Trixie targets (systemd 257).
thanks, -Christian
Issue Type
Bug Report
Component Name
systemd
Ansible Version
$ ansible --version
ansible [core 2.18.0]
config file = /home/daduke/git/ansible-isg-phys/ansible.cfg
configured module search path = ['/home/daduke/git/ansible-isg-phys/.library']
ansible python module location = /opt/software/pyenv/202406/versions/3.12.4/lib/python3.12/site-packages/ansible
ansible collection location = /home/daduke/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/software/pyenv/202406/versions/3.12.4/bin/ansible
python version = 3.12.4 (main, Jun 16 2024, 09:36:31) [GCC 12.2.0] (/opt/software/pyenv/202406/versions/3.12.4/bin/python3.12)
jinja version = 3.1.4
libyaml = True
Configuration
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
ANSIBLE_NOCOWS(/home/daduke/git/ansible-isg-phys/ansible.cfg) = True
CONFIG_FILE() = /home/daduke/git/ansible-isg-phys/ansible.cfg
DEFAULT_CALLBACK_PLUGIN_PATH(/home/daduke/git/ansible-isg-phys/ansible.cfg) = ['/home/daduke/git/ansible-isg-phys/>
DEFAULT_FILTER_PLUGIN_PATH(/home/daduke/git/ansible-isg-phys/ansible.cfg) = ['/home/daduke/git/ansible-isg-phys/.p>
DEFAULT_FORKS(/home/daduke/git/ansible-isg-phys/ansible.cfg) = 30
DEFAULT_GATHERING(/home/daduke/git/ansible-isg-phys/ansible.cfg) = smart
DEFAULT_MODULE_PATH(/home/daduke/git/ansible-isg-phys/ansible.cfg) = ['/home/daduke/git/ansible-isg-phys/.library']
DEFAULT_NO_TARGET_SYSLOG(/home/daduke/git/ansible-isg-phys/ansible.cfg) = True
DEFAULT_REMOTE_USER(/home/daduke/git/ansible-isg-phys/ansible.cfg) = root
DEFAULT_ROLES_PATH(/home/daduke/git/ansible-isg-phys/ansible.cfg) = ['/home/daduke/git/ansible-isg-phys/roles-shar>
DEFAULT_STRATEGY(env: ANSIBLE_STRATEGY) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(env: ANSIBLE_STRATEGY_PLUGINS) = ['/opt/software/pyenv/202406/versions/3.12.4/lib/pyt>
DEFAULT_TIMEOUT(/home/daduke/git/ansible-isg-phys/ansible.cfg) = 5
DEFAULT_VAULT_IDENTITY_LIST(/home/daduke/git/ansible-isg-phys/ansible.cfg) = ['[email protected]/production',>
DEFAULT_VAULT_ID_MATCH(/home/daduke/git/ansible-isg-phys/ansible.cfg) = True
EDITOR(env: EDITOR) = vim
INTERPRETER_PYTHON(/home/daduke/git/ansible-isg-phys/ansible.cfg) = /usr/bin/python3
MAX_FILE_SIZE_FOR_DIFF(/home/daduke/git/ansible-isg-phys/ansible.cfg) = 300000
RETRY_FILES_ENABLED(/home/daduke/git/ansible-isg-phys/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/home/daduke/git/ansible-isg-phys/ansible.cfg) = ignore
GALAXY_SERVERS:
CONNECTION:
==========
paramiko_ssh:
____________
remote_user(/home/daduke/git/ansible-isg-phys/ansible.cfg) = root
timeout(/home/daduke/git/ansible-isg-phys/ansible.cfg) = 5
ssh:
___
pipelining(/home/daduke/git/ansible-isg-phys/ansible.cfg) = True
remote_user(/home/daduke/git/ansible-isg-phys/ansible.cfg) = root
ssh_args(/home/daduke/git/ansible-isg-phys/ansible.cfg) = -o ControlMaster=auto -o PreferredAuthentications=public>
timeout(/home/daduke/git/ansible-isg-phys/ansible.cfg) = 5
OS / Environment
Debian Bookworm
Steps to Reproduce
- name: force enable (reenable) systemd user services to update symlinks
systemd:
name: '{{ item }}'
scope: global
enabled: True
force: True
daemon_reload: True
loop: '{{ desktop_packages_service_wanted_by_graphical_pre_target }}'
Expected Results
ansible enables the user service on Trixie as it did on Bookworm
Actual Results
ansible errors out with
failed: [funkadelic] (item=tracker-extract-3.service) => {"ansible_loop_var": "item", "changed": false, "cmd": "/usr/bin/systemctl --global", "item": "tracker-extract-3.service", "msg": "--global is not supported for this operation.", "rc": 1, "stderr": "--global is not supported for this operation.\n", "stderr_lines": ["--global is not supported for this operation."], "stdout": "", "stdout_lines": []}
Code of Conduct
- I agree to follow the Ansible Code of Conduct
Source: ansible/ansible