Properly fix daemon reload

This commit is contained in:
Wojciech Kozlowski 2023-01-04 07:52:21 +01:00
parent abdc0fff9c
commit 0119db15e8
3 changed files with 9 additions and 8 deletions

View File

@ -3,6 +3,6 @@ argument_specs:
daemon_reload: daemon_reload:
options: options:
services_host_services: services_host_services:
type: "list" type: "dict"
elem: "dict" elem: "dict"
required: true required: true

View File

@ -1,6 +1,6 @@
--- ---
- name: "daemon_reload : loop over services" - name: "daemon_reload : loop over services"
ansible.builtin.include_tasks: "daemon_reload/main.yml" ansible.builtin.include_tasks: "daemon_reload/main.yml"
loop: "{{ services_host_services | dict2items | selectattr('key') }}" loop: "{{ services_host_services | dict2items | map(attribute='key') }}"
loop_control: loop_control:
loop_var: "services_service_name" loop_var: "services_service_name"

View File

@ -1,11 +1,12 @@
--- ---
- name: "daemon_reload : {{ services_service_name }} : set variables" - name: "daemon_reload : {{ services_service_name }} : set variables"
ansible.builtin.import_tasks: "../vars.yml" ansible.builtin.include_vars: "user.yml"
- name: "daemon_reload : {{ services_service_name }} : check if home exists" - name: "daemon_reload : {{ services_service_name }} : check if user exists"
ansible.builtin.stat: ansible.builtin.getent:
path: "{{ services_service_user_home }}" database: "passwd"
register: services_include_daemon_reload_user_home key: "{{ services_service_user_name }}"
fail_key: false
- name: "daemon_reload : {{ services_service_name }} : systemd daemon reload" - name: "daemon_reload : {{ services_service_name }} : systemd daemon reload"
become_user: "{{ services_service_user_name }}" become_user: "{{ services_service_user_name }}"
@ -13,4 +14,4 @@
daemon_reload: true daemon_reload: true
scope: "user" scope: "user"
when: when:
services_include_daemon_reload_user_home.stat.exists ansible_facts.getent_passwd[services_service_user_name]