【发布时间】:2015-06-26 22:08:58
【问题描述】:
我有以下剧本, 我进行了测试,所有任务都运行良好,除非 ansible 试图停止主机中无响应的服务。它一直等待很长时间,并且从未得到服务器的响应(没有超时,没有失败,没有任何东西)。
在这种情况下,异步和轮询或“触发并忘记”方法对我没有用,我尝试先停止,然后再执行 kill -9。
- hosts: '{{ hostname }}'
become: yes
vars_prompt:
hostname: "Enter hostname"
tasks:
- name: Stop
service: name=some_service state=stopped pattern=some_pattern
register: stop_disabled_services
ignore_errors: yes
- name: Stop output
debug: msg="{{ stop_disabled_services }}"
- name: Killing process
shell: kill -9 $(cat /opt/day/cq5/publish/crx-quickstart/conf/cq.pid)
register: output
when: "stop_disabled_services | failed"
- name: Killing output
debug: msg="{{ output.stdout }}"
when: "output | failed"
- name: start
service: name=some_service state=started
register: start_disabled_services
- name: Result
debug: msg="WARNING Escalated this incident "
when: "start_disabled_services | failed"
- name: Result
debug: msg="Start up complete successfully"
when: "start_disabled_services | success"
你知道我该如何解决它吗? 提前致谢。
【问题讨论】:
标签: asynchronous service state ansible ansible-playbook