> On 10/15/2021 7:05 PM Brian Coca <bc...@redhat.com> wrote: > > > A simple solution is to 'alter' the failure condition: > > - 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'] > > Now it will only fail for reasons that are not 'the service is missing'
it took a bit of fiddeling with the indentation (not being transalted nicely to the website view of the mailing list) but finally this combination works (in terms of not producing any error on running the playbook). ########################################################################## - name: gather service facts service_facts: - name: return postgres running or not debug: msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) }}" - 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'] ########################################################################## I have not finish the entire installation, so I can not yet say whether in works on the entire context yet. nevertheless tx all of you for the suggestions -- 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/581749809.135689.1634484444004%40office.mailbox.org.