- name: Shutdown remote servers hosts: all # 或者指定特定的主机组 become: yes # 提升权限为root用户 tasks: - name: Shutdown the server command: /sbin/shutdown -h now async: 1 poll: 0 ignore_errors: true # 忽略错误以防止连接中断后任务失败