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 <[email protected]> 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
> [email protected] şunları yazdı:
>
>> 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.
>>
>>
>>
>> On 12/30/2021 9:16 AM Kerem Kalayci <[email protected]> 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
>>
>>
>> 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 [email protected].
>> 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>.
>>
>>
>> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/265e09e5-36fb-4c24-99e6-da133ef84b04n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/265e09e5-36fb-4c24-99e6-da133ef84b04n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
"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 , <
[email protected]>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAKuX69pyEy4x7XaTSgLBFsa_0oK_Kzwq2kgiayvNZA0V4x67aw%40mail.gmail.com.