use shell to determine if service exists
This commit is contained in:
@@ -15,12 +15,12 @@
|
||||
private: no
|
||||
tasks:
|
||||
- name: Check if service exists
|
||||
stat: path=/usr/lib/systemd/system/{{ service }}
|
||||
shell: systemctl list-units --type=service --all | grep -o "{{ service }}"
|
||||
register: status
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
- name: Change state of service
|
||||
systemd:
|
||||
name: "{{ service }}"
|
||||
enabled: "{{ enable }}"
|
||||
state: "{{ state }}"
|
||||
when: status.stat.exists
|
||||
when: status.stdout == "{{ service }}"
|
||||
|
||||
Reference in New Issue
Block a user