how can i get around this error?

Hi everyone, i’m newbie at ansible yml.
I am trying to run a command like below. But I am getting an error as below. where am i doing wrong?

  • gather_facts: False
    name: LINGO’da komut
    hosts: xxx
    remote_user: xxx

tasks:

  • name: Run basic PowerShell script
    win_powershell:
    script: |
    C:\Users\emperior\Desktop\run_command.ps1

ERROR! conflicting action statements: win_powershell, script
The error appears to be in ‘/tmp/awx_13485_rbw826y0/project/5-create-iso.yml’: line 10, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:

  • name: Run basic PowerShell script
    ^ here

Hi everyone, i'm newbie at ansible yml.
I am trying to run a command like below. But I am getting an error as below. where am i doing wrong?

- gather_facts: False
name: LINGO'da komut
hosts: xxx
remote_user: xxx

tasks:
- name: Run basic PowerShell script
win_powershell:
script: |
C:\Users\emperior\Desktop\run_command.ps1

Looks like wrong indentation, please try this:

   tasks:
     - name: Run basic PowerShell script
       win_powershell:
         script: |
           C:\Users\emperior\Desktop\run_command.ps1

Regards
         Racke

on first sight I would try to change the indentation of the task like:

tasks:

  • name: Run basic PowerShell script
    win_powershell: |
    your script here

not 100% sure about the postition-indentation of the script line though. That said … it’s always a good idea to look at the examples from the documentation of the module you are trying to use https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_powershell_module.html#ansible-collections-ansible-windows-win-powershell-module

In this case it looks like the script parameter expects the actual script and not a link to a file.

Hello Kerem,

you’re using a bad indentation.

win_powershell: has to be aligned with the n of name: (the previous row)

and script as to be aligned with the n of win_powershell.

So your playbook will result written this way:

  • gather_facts: False
    name: asdf
    hosts: localhost
    tasks:
  • name: Run basic PowerShell script
    win_powershell:
    script: |
    C:\Users\emperior\Desktop\run_command.ps1

Luca

Hi Luca,

Thank you for your interest and reply. When I tried in the order you sent, I got an error like below.
I think I’m having a problem with the module version. What is your opinion?

https://stackoverflow.com/questions/47159193/why-does-ansible-show-error-no-action-detected-in-task-error

ERROR! couldn’t resolve module/action ‘win_powershell’. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in ‘/tmp/awx_13558_5zugncc6/project/5-create-iso.yml’: line 5, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Run basic PowerShell script
^ here

30 Aralık 2021 Perşembe tarihinde saat 12:53:39 UTC+3 itibarıyla lorenze...@gmail.com şunları yazdı:

Hello,

check docs of this module. On top of the page there are some clarifications on steps you need to do:

https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_powershell_module.html