ansible: Fix systemd user unit masking

This commit is contained in:
2021-09-25 19:08:16 +02:00
parent b924e780c3
commit 408595d7e1

View File

@@ -58,12 +58,24 @@
become: true become: true
become_user: root become_user: root
- name: create systemd directory
file:
state: directory
path: "{{ item }}"
owner: "{{ user.name }}"
group: "{{ user_group_name }}"
loop:
- "/home/{{ user.name }}/.config/"
- "/home/{{ user.name }}/.config/systemd/"
- "/home/{{ user.name }}/.config/systemd/user/"
# No way to use the `systemd` module here, as it needs a logind
# session. So we have to handle the symlinks for masking ourselves.
- name: disable and mask systemd user units - name: disable and mask systemd user units
systemd: file:
name: "{{ item }}" state: link
enabled: false dest: "/home/{{ user.name }}/.config/systemd/user/{{ item }}"
masked: true src: "/dev/null"
scope: user
with_items: with_items:
- gpg-agent.service - gpg-agent.service
- gpg-agent.socket - gpg-agent.socket