Authored by chunhua.zhang

add

... ... @@ -16,12 +16,14 @@
register: service_runtime
changed_when: False
# 获取服务器当前系统时间(ts)
- name: system current time
shell: date +%s
register: current_time
changed_when: False
# 对比服务启动时间与当前时间
- name: Compare service uptime & current time
debug:
... ... @@ -30,8 +32,9 @@
- "Current system time is: {{ lookup('pipe','date -d @'+current_time.stdout) }}"
- "interval is: {{ current_time.stdout|int - service_runtime.stdout|int }}"
# 服务启动时间与系统时间间隔超过120秒则标记为重启失败
- name: check restart status
fail:
msg: "服务启动时间与系统时间间隔超过 120 秒, interval: {{ current_time.stdout|int - service_runtime.stdout|int }} !"
when: current_time.stdout|int - service_runtime.stdout|int > 120
when: start == 'no' and current_time.stdout|int - service_runtime.stdout|int > 120
... ...