Ansible Quick Start Guide
上QQ阅读APP看书,第一时间看更新

Ad hoc versus playbook: the win_reboot module

The ad hoc command can be simply executed as shown in the following two examples:

ansible winservers -m win_reboot

ansible win servers -m win_reboot –args="msg='Reboot initiated by remote admin' pre_reboot_delay=5"

The resulting output of either command will look as follows:

This playbook file contains two ways of restarting hosts using the same module:

---
- name: Reboot Windows hosts
hosts: winservers
fast_gathering: false
tasks:
- name: restart Windows hosts with default settings
win_reboot

- name: restart Windows hosts with personalized
settings
win_reboot:
msg: "Reboot initiated by remote admin"
pre_reboot_delay: 5

The resulting playbook output will look as follows: