On Sun, 17 Oct 2021 17:27:23 +0200 (CEST)
dulhaver via Ansible Project <ansible-project@googlegroups.com> wrote:

>   - name: gather service facts
>     service_facts:
>     ...
>   - name: stop postgresql.service from systemd if running
>     service:
>       name: postgresql.service
>       state: stopped
>     become: yes
>     register: psql_result
>     failed_when: psql_result is failed and 'Could not find the requested 
> service postgresql..service' not in psql_result['msg']

Testing service existence should be simpler, I think

    - service_facts:
    - service:
        name: postgresql.service
        state: stopped
      become: true
      register: psql_result
      when: "'postgresql.service' in services"


-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20211017193421.15764a32%40gmail.com.

Attachment: pgp9H00whHOcA.pgp
Description: OpenPGP digital signature

Reply via email to