Try to make systemd unit handling idempotent

This commit is contained in:
2024-04-26 12:20:43 +02:00
parent 49a7762e6c
commit 43b9dd3b08

View File

@@ -39,6 +39,10 @@
- "/home/{{ user.name }}/.config/systemd/" - "/home/{{ user.name }}/.config/systemd/"
- "/home/{{ user.name }}/.config/systemd/user/" - "/home/{{ user.name }}/.config/systemd/user/"
- name: disable undesired services
tags:
- undesired-services
block:
- set_fact: - set_fact:
undesired_user_services: undesired_user_services:
- gpg-agent.socket - gpg-agent.socket
@@ -52,9 +56,11 @@
# systemd needs a login session, machinectl handles that for us # systemd needs a login session, machinectl handles that for us
- name: stop and mask undesired services - name: stop and mask undesired services
command: command:
cmd: machinectl --uid {{ user.name }} shell -- .host /usr/bin/env systemctl --user mask --now "{{ item }}" cmd: machinectl --quiet --uid {{ user.name }} shell -- .host /usr/bin/env systemctl --user mask --now "{{ item }}"
become: true become: true
become_user: root become_user: root
register: undesired_service_cmd
changed_when: undesired_service_cmd.stderr != ""
loop: "{{ undesired_user_services }}" loop: "{{ undesired_user_services }}"
- name: create directory for getty autologin - name: create directory for getty autologin