Service restart in Windows Operating system using playbooks

71 views
Skip to first unread message

Suma P

unread,
Dec 6, 2018, 2:43:29 AM12/6/18
to Ansible Project
Hi Team ,

I am trying to restart the spooler service in windows remotely by creating playbooks in RHEL Operating system .its trowing below error.kindly suggest me to resolve this issue.

playbook content :

---
- name: Restart a service
  win_service:
    name: spooler
    state: restarted

ERROR is :

[root@Amaster ansible]# ansible-playbook restart_spool_service.yml
ERROR! 'win_service' is not a valid attribute for a Play

The error appears to have been in '/etc/ansible/restart_spool_service.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: Restart a service
  ^ here


Thanks & Regards,
Suma



J Hawkesworth

unread,
Dec 8, 2018, 5:00:24 AM12/8/18
to Ansible Project
Hi,

You need to tell the playbook which hosts you want to run your tasks on, something like the following (not tested).

---

- hosts: windows
tasks:

- name: restart spooler


win_service:
name: spooler
state: restarted


Hope this helps,


Jon

Reply all
Reply to author
Forward
0 new messages