I am still stuck with this:
theses 3 TASKS should take care of checking the status of postgresql.server and (if running) stop it
####################################################################################################
- 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
state: stopped
when: ansible_facts.services.postgresql.state == 'running'
become: yes
####################################################################################################
however I am getting an 'Unsupported parameters for (systemd) module: when Supported parameters include: daemon_reexec, daemon_reload, enabled, force, masked, name, no_block, scope, state, user' error upon that last TASK
as 'state' is mentioned as supported paramter I am wondering whether the wording 'running' / 'present' .... may be the root cause of my problem.
thec check for running services shows 'running', 'stopped', 'disabled' as far as I can see, where the state in the service task would be 'started' as far as I can tell.
can anybody advise on this?