improve support for disabling units

This commit is contained in:
Pig Monkey 2019-05-19 12:13:03 -07:00
parent bb7c07961f
commit ac407bf2fc

View file

@ -5,18 +5,11 @@
state: started
when: run_on == "all" and user_unit is not defined
- name: Remove {{ unit }} from trusted unit list
lineinfile:
dest: /etc/nmtrust/trusted_units
state: absent
line: "{{ unit }}"
when: run_on == "all" and user_unit is not defined
- name: Disable {{ unit }}
systemd:
name: "{{ unit }}"
enabled: no
when: run_on == "trusted" and user_unit is not defined
when: run_on != "all" and user_unit is not defined
- name: Add {{ unit }} to trusted unit list
lineinfile:
@ -25,6 +18,13 @@
line: "{{ unit }}"
when: run_on == "trusted" and user_unit is not defined
- name: Remove {{ unit }} from trusted unit list
lineinfile:
dest: /etc/nmtrust/trusted_units
state: absent
line: "{{ unit }}"
when: run_on != "trusted" and user_unit is not defined
- name: Enable and start {{ unit }} for user
systemd:
name: "{{ unit }}"
@ -37,13 +37,6 @@
XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
when: run_on == "all" and user_unit is defined and user_unit == true
- name: Remove {{ unit }} for user from trusted unit list
lineinfile:
dest: /etc/nmtrust/trusted_units
state: absent
line: "{{ unit }},user:{{ user.name }}"
when: run_on == "all" and user_unit is defined and user_unit == true
- name: Disable user {{ unit }} for user
systemd:
name: "{{ unit }}"
@ -53,7 +46,7 @@
become_user: "{{ user.name }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
when: run_on == "trusted" and user_unit is defined and user_unit == true
when: run_on != "all" and user_unit is defined and user_unit == true
- name: Add {{ unit }} for user to trusted unit list
lineinfile:
@ -61,3 +54,10 @@
state: present
line: "{{ unit }},user:{{ user.name }}"
when: run_on == "trusted" and user_unit is defined and user_unit == true
- name: Remove {{ unit }} for user from trusted unit list
lineinfile:
dest: /etc/nmtrust/trusted_units
state: absent
line: "{{ unit }},user:{{ user.name }}"
when: run_on != "trusted" and user_unit is defined and user_unit == true