Restart Windows services on 2 hosts 1 min apart

27 views
Skip to first unread message

Amit Kulkarni

unread,
Jun 5, 2023, 9:45:49 AM6/5/23
to Ansible Project
Hello All,

I wanted to restart 1 windows service on 2 hosts 1 min apart, is there any way we can achieve this.
Here is the my playbook Let me know in case of anything

---
  - name: restart the fedex service
    hosts: Windows1
    tasks:
      - win_service:
          name: fedex
          state: restarted

Atul Nasir

unread,
Jun 13, 2023, 9:12:49 PM6/13/23
to Ansible Project

---
- name: Restart the FedEx service
  hosts: Windows1
  tasks:
    - name: Restart the service

      win_service:
        name: fedex
        state: restarted

    - name: Pause for 1 minute
      pause:
        minutes: 1
      when: inventory_hostname != groups['Windows1'][-1]
Reply all
Reply to author
Forward
0 new messages