diff --git a/playbooks/systemd.yml b/playbooks/systemd.yml index d97b2f7..7d609eb 100644 --- a/playbooks/systemd.yml +++ b/playbooks/systemd.yml @@ -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 }}"