Skip to content

Commit

Permalink
Always become user we are managing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhjacks committed Dec 9, 2024
1 parent fd9cdc7 commit bc46818
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions tasks/get_systemd_units_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
systemd_units:
user: "{{ __systemd_units_info.key }}"
user_facts: "{{ ansible_facts['systemd_units_user'] | d({}) }}"
become: "{{ __systemd_units_info.key != 'root' }}"
become_user: "{{ __systemd_units_info.key if __systemd_units_info.key != 'root'
else omit }}"
become: true
become_user: "{{ __systemd_units_info.key }}"
environment:
XDG_RUNTIME_DIR: "{{ __systemd_units_info.value['xdg_dir'] }}"
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
daemon_reload: true
scope: "{{ 'system' if item == 'root' else 'user' }}"
loop: "{{ __users_with_changes }}"
become: "{{ item != 'root' }}"
become_user: "{{ item if item != 'root' else omit }}"
become: true
become_user: "{{ item }}"
environment:
XDG_RUNTIME_DIR: "{{ __systemd_user_info[item]['xdg_dir'] }}"
vars:
Expand Down
4 changes: 2 additions & 2 deletions tasks/manage_units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
masked: "{{ __systemd_masked | bool if __systemd_masked | length > 0 else omit }}"
scope: "{{ 'system' if item.user == 'root' else 'user' }}"
loop: "{{ __systemd_dict_list }}"
become: "{{ item.user != 'root' }}"
become_user: "{{ item.user if item.user != 'root' else omit }}"
become: true
become_user: "{{ item.user }}"
environment:
XDG_RUNTIME_DIR: "{{ item.xdg_dir }}"

0 comments on commit bc46818

Please sign in to comment.