how can i get around this error?

773 views
Skip to first unread message

Kerem Kalayci

unread,
Dec 30, 2021, 3:16:28 AM12/30/21
to Ansible Project
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



Stefan Hornburg (Racke)

unread,
Dec 30, 2021, 3:25:47 AM12/30/21
to ansible...@googlegroups.com
On 30/12/2021 09:16, Kerem Kalayci wrote:
> 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

>
> 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
>
>
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/365641a3-53a5-4012-b9c2-254ebf2c433an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/365641a3-53a5-4012-b9c2-254ebf2c433an%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


OpenPGP_signature

dulh...@mailbox.org

unread,
Dec 30, 2021, 3:41:04 AM12/30/21
to ansible...@googlegroups.com
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.



--
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/365641a3-53a5-4012-b9c2-254ebf2c433an%40googlegroups.com.
Message has been deleted

Luca 'remix_tj' Lorenzetto

unread,
Dec 30, 2021, 4:53:39 AM12/30/21
to ansible...@googlegroups.com
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

On Thu, Dec 30, 2021 at 10:05 AM Kerem Kalayci <krmk...@gmail.com> wrote:
Thanks for reply,   I am already using the link you sent, but the error persists.


- gather_facts: False
  name: asdf
  hosts: localhost



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


ERROR! 'win_powershell' is not a valid attribute for a Play
The error appears to be in '/tmp/awx_13503_b56qjzih/project/5-create-iso.yml': line 2, column 3, but may

be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- gather_facts: False
  ^ here


I have a yml that works on hpe ilo as follows. this code works fine. I get an same error when I edit the above yml file to run on windows according to this code

- gather_facts: False
  name: storage operations
  hosts: localhost
  vars:
    odata_ids: "[*].\"@odata.id\""
    physical_disk_links: []
    physical_disks: []
  tasks:

- name: get physical drive outputs of array controllers
      uri:
        url: https://{{ilo_ip}}{{item}}/DiskDrives
        validate_certs: no
        method: GET
        return_content: yes
        user: '{{ lookup("env", "ANSIBLE_NET_USERNAME" ) }}'
        password: '{{ lookup("env", "ANSIBLE_NET_PASSWORD" ) }}'
        force_basic_auth: yes
        headers:
                Content-Type: application/json
                Accept: application/json
    loop: "{{arraycontroller_links}}"
      register: arraycontrollers_pd_output





30 Aralık 2021 Perşembe tarihinde saat 11:41:04 UTC+3 itibarıyla dulh...@mailbox.org şunları yazdı:


--
"E' assurdo impiegare gli uomini di intelligenza eccellente per fare
calcoli che potrebbero essere affidati a chiunque se si usassero delle
macchine"
Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716)

"Internet è la più grande biblioteca del mondo.
Ma il problema è che i libri sono tutti sparsi sul pavimento"
John Allen Paulos, Matematico (1945-vivente)
 
Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , <lorenze...@gmail.com>

Kerem Kalayci

unread,
Dec 30, 2021, 7:09:45 AM12/30/21
to Ansible Project
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?


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ı:

Luca 'remix_tj' Lorenzetto

unread,
Dec 30, 2021, 7:15:34 AM12/30/21
to ansible...@googlegroups.com
Hello,

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


Reply all
Reply to author
Forward
0 new messages