Question: Failed to start poweroff.target: Connection timed out
執行 Playbook 內容為「systemctl poweroff」,但是結果卻是失敗並顯示下列錯誤訊息?Failed to start poweroff.target: Connection timed out
Answer:
簡單來說,針對 CentOS 7 主機,無論是 Reboot 或 Poweroff 在 Playbook 中都必須搭配「async 和 poll」,否則便會出現上述錯誤訊息。請參考下列相關文章內容即可知原因:- 10.4. Shutting Down, Suspending, and Hibernating the System Red Hat Enterprise Linux 7 | Red Hat Customer Portal
- How do I Reboot a Host Remotely using an Ansible Playbook? - Red Hat Customer Portal
- Asynchronous Actions and Polling — Ansible Documentation
將 Playbook 內容改為如下即可順利執行: