can somebody explaine me why service sis not starting
on mhost1:
[root@mhost1 ~]# ps -ef | grep -v grep | grep httpd
[root@mhost1 ~]#
can somebody explaine me why service sis not starting
on mhost1:
[root@mhost1 ~]# ps -ef | grep -v grep | grep httpd
[root@mhost1 ~]#
Hi,
change to
when: htop_is_running.stdout == ‘0’
It might be cleaner to use pgrep instead for process check. Then you can use something like this:
tasks:
- name: Process check
command: pgrep httpd
register: httpd_check
ignore_errors: true
- debug:
var: httpd_check.failed
- name: restart httpd if down
systemd:
name: httpd
state: restarted
when: httpd_check.failed
What's wrong with asserting that the service should be started?
- systemd:
name: httpd
state: started
Regards
Racke
What's wrong with asserting that the service should be started?
- systemd:
name: httpd
state: started
For the vast majority of cases that should work (the apache service in major
distros being such a case).
Sometimes you do get an edge case where the PID check in the unit file is not a
good enough check for the health of the service as a whole.
- Sandip
when: htop_is_running.stdout == ‘0’ did not work
command: pgrep httpd
My question is why the following not working
when: status_httpd.stdout_lines == 0
ok: [mhost1] => {
“status_httpd.stdout_lines”: [
“0”
]
}
Thanks
If the 'when' condition, you are effectively working in python land.
Here you are making probably two mistakes:
- 'stdout_lines' is an array. 'stdout' is a string.
- you are comparing strings to numbers
sorry. I take it back my words
the following change is working
when: htop_is_running.stdout == ‘0’
Thanks