본문 바로가기

Automation Tools/Ansible

Windows Ansible | [Playbook] shutdown, reboot, service

반응형

winrm 설치는 여기 참조

 

 

윈도우 전원 shutdown

---
- hosts: all
  gather_facts: no
  ignore_unreachable: yes
  tasks:
  - name: Run an executable and send data to the stdin for the executable
    win_command: powershell.exe Stop-Computer -Force

 

 

윈도우 전원 reboot

---
- hosts: all
  gather_facts: no
  ignore_unreachable: yes
  tasks:
    - name: Reboot the machine with all defaults
      win_reboot:

 

윈도우 서비스 모듈

  • start_mode : auto | delayed | disabled | manual
  • state : absent | paused | started | stopped | restarted
---
- hosts: all
  gather_facts: no
  ignore_unreachable: yes
  tasks:
    - name: Ensure WinRM starts when the system has settled and is ready to work reliably
      win_service:
        name: DNS
        start_mode: manual
        state: stopped
반응형