On 15/10/2021 12:04, dulhaver via Ansible Project wrote:
On 10/15/2021 11:41 AM Stefan Hornburg (Racke) <ra...@linuxia.de> wrote:

On 15/10/2021 11:20, dulhaver via Ansible Project wrote:

I am trying to install postgresql via a playbook and want to make sure the service 
is not running prior installation on the target (rhel7/8 & debian10) machines.

However my task below

      - name: stop postgresql.service from systemd if running
        service:
          name: postgresql.service
          state: stopped
          # enabled: false
        become: yes

is failing ('Could not find the requested service postgresql.service: host')

so, I guess I have to build something that directs the target to ignore that 
and continues with the playbook. I just can't see anything

You can check the status of the postgresql service as follows:

   - service_facts:

   - debug:
       msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

TASK [service_facts] 
***************************************************************************************************************************************
ok: [papas]

TASK [debug] 
***********************************************************************************************************************************************
ok: [papas] => {
      "msg": {
          "name": "postgresql",
          "source": "sysv",
          "state": "running"
      }
}

are those arguments to the the "service" module? how exaclty would I weave 
those into my task? I tried

   - name: stop postgresql.service from systemd if running
     service:
       name: postgresql
         service_facts:
         debug:
           msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 
'absent'}) }}"
       state: stopped
       # enabled: false
     become: yes

but that did not work


No, use my tasks verbatim.

Regards
          Racke

--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/842bcdc0-9c09-458a-45d5-e873967940b4%40linuxia.de.

Attachment: OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to