Issue with ansible playbook for windows

229 views
Skip to first unread message

Jayan Anirudhan

unread,
Nov 5, 2019, 9:53:42 AM11/5/19
to Ansible Project

Hi All,

I have created a playbook to execute a VBScript on windows server and its showing error while performing the syntax check. Kindly have a look and  please help me in this regard.


---
- name: Copy PsExec
  win_copy:src:/home/testuser/jaytest/g-prediscover.vbe
    dest:C:\temp\
    force:no

   - name:Run powershell as a specific domain user
    win_command:C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable:C:\temp\g-prediscover.vbe
    elevated:yes
    nobanner:yes
    interactive:yes
...


=========================


[root@Y1972-206 jaywin]# ansible-playbook -i inventory --syntax-check win3.yml
ERROR! Syntax Error while loading YAML.
  could not find expected ':'

The error appears to be in '/opt/jaywin/win3.yml': line 13, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    interactive:yes
...
^ here

[root@Y1972-206 jaywin]#


=================================


Ansible version  = ansible 2.8.4

Dick Visser

unread,
Nov 5, 2019, 10:25:17 AM11/5/19
to ansible...@googlegroups.com
Your spacing is all messed up. Try this (I have not used these modules so there may be additional issues):


---
- name: Copy PsExec
  win_copy:
    src: /home/testuser/jaytest/g-prediscover.vbe
    dest: C:\temp\
    force: no

- name: Run powershell as a specific domain user
  win_command: C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
    elevated: yes
    nobanner: yes
    interactive: yes



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/229263b1-f69d-42da-857a-ec6c19c4060b%40googlegroups.com.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Jayan Anirudhan

unread,
Nov 5, 2019, 11:39:17 AM11/5/19
to ansible...@googlegroups.com
Hi Dick,

Thanks for your mail.

As per your mail I have tried the same and found the issue persist. Kindly find the details mentioned below.

[root@Y1972-206 jaywin]# cat win5.yml

---
- name: Copy PsExec
  win_copy:
    src: /home/testuser/jaytest/g-prediscover.vbe
    dest: C:\temp\
    force: no

- name: Run powershell as a specific domain user
  win_command: C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
    elevated: yes
    nobanner: yes
    interactive: yes
[root@Y1972-206 jaywin]# ansible-playbook -i inventory --syntax-check win5.yml

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to be in '/opt/jaywin/win5.yml': line 10, column 15, but may

be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  win_command: C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
              ^ here

[root@Y1972-206 jaywin]#

Regards,
Jayan



--
Regards,

Jayan Anirudhan
Mob:09885994156

Dick Visser

unread,
Nov 5, 2019, 11:52:33 AM11/5/19
to ansible...@googlegroups.com
On Tue, 5 Nov 2019 at 17:39, Jayan Anirudhan <jaya...@gmail.com> wrote:
Hi Dick,

Thanks for your mail.

As per your mail I have tried the same and found the issue persist. Kindly find the details mentioned below.

Actually the original error is fixed, but now a new one arised.
 

[root@Y1972-206 jaywin]# cat win5.yml
---
- name: Copy PsExec
  win_copy:
    src: /home/testuser/jaytest/g-prediscover.vbe
    dest: C:\temp\
    force: no

- name: Run powershell as a specific domain user
  win_command: C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
    elevated: yes
    nobanner: yes
    interactive: yes
[root@Y1972-206 jaywin]# ansible-playbook -i inventory --syntax-check win5.yml
ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to be in '/opt/jaywin/win5.yml': line 10, column 15, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  win_command: C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
              ^ here


Again, I have no experience whatsoever with the windows modules, but from the docs alone one can see that the win_command module does not have any of the parameters that you use:


Browsing through the windows module list, I think you mixed things up and want to use the win_psexec module?
Because that does have all the parameters you use:


I noticed that this needs a 'command' parameters.
Adding the bits of the puzzle:

---
- name: Copy PsExec
  win_copy:
    src: /home/testuser/jaytest/g-prediscover.vbe
    dest: C:\temp\
    force: no

- name: Run powershell as a specific domain user
  win_psexec:
    command C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2

    executable: C:\temp\g-prediscover.vbe
    elevated: yes
    nobanner: yes
    interactive: yes

Jayan Anirudhan

unread,
Nov 5, 2019, 1:23:03 PM11/5/19
to ansible...@googlegroups.com
Hi Dick,

No luck so far

[root@Y1972-206 jaywin]# cat win6.yml

---
- name: Copy PsExec
  win_copy:
    src: /home/testuser/jaytest/g-prediscover.vbe
    dest: C:\temp\
    force: no

- name: Run powershell as a specific domain user
  win_psexec:
    command C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
    elevated: yes
    nobanner: yes
    interactive: yes
[root@Y1972-206 jaywin]# ansible-playbook -i inventory --syntax-check win6.yml

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to be in '/opt/jaywin/win6.yml': line 11, column 15, but may

be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    command C:\Windows\SysWOW64\cscript.exe g-prediscover.vbe -n 2 +2
    executable: C:\temp\g-prediscover.vbe
              ^ here

[root@Y1972-206 jaywin]#


Regards,
Jayan

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages