‪On Sun, Jan 12, 2020 at 2:26 PM ‫רגב בתחן‬‎ <batch...@gmail.com> wrote:‬
>
> I need all commands to run one by one, i tried loop with items it didnt work, 
> all of this commands creating windows user in win vm, the first one do the 
> Password var, the second creates rhe user with the Password var and the last 
> is adding it to a group, with loop it loops all playbook, i need it to open 
> powershell only once.
>
> If i run this command manually on powershell it works but i cannot find a way 
> to do 3 commands sequence, thanks
>
      What if you write a powershell script to run the 3 commands,
taking as arguments whatever info it needs (paths, usenrames,
whatever) and then run the 3 commands inside it? Then copy file to
target box, run it there as the local user you need it to run as, get
results (so you know if it worked or went boink), and delete file.

> בתאריך יום א׳, 12 בינו׳ 2020 ב-21:21 מאת Mauricio Tavares 
> <raubvo...@gmail.com>:
>>
>> ‪On Sun, Jan 12, 2020 at 11:57 AM ‫רגב בתחן‬‎ <batch...@gmail.com> wrote:‬
>> >
>> > Im using Ansible 2.9.2, I need to run 3 powershell command one after the 
>> > other. My playbook :
>> >
>> >   tasks:
>> >     - name: "User Create"
>> >       local_action:
>> >         module: vmware_vm_shell
>> >         cluster: "{{ cluster }}"
>> >         datacenter: "{{ datacenter }}"
>> >         hostname: "{{ vcenter_server }}"
>> >         username: "{{ vcenter_user  }}"
>> >         password: "{{ vcenter_pass }}"
>> >         vm_id: "{{ name }}"
>> >         vm_username: "{{ vm_username }}"
>> >         vm_password: "{{ vm_password }}"
>> >         vm_shell: 
>> > 'c:\Windows\System32\WindowsPowershell\v1.0\powershell.exe'
>> >         vm_shell_args: '$Password= ConvertTo-SecureString {{ Password }} 
>> > -AsPlainText -Force ; New-LocalUser {{ Username}} -Password {{ Password }} 
>> > ; Add-LocalGroupMember -Group {{ Group }} -Member {{ Username }}'
>> >         wait_for_process: yes
>> >         validate_certs: no
>> >
>> > If i run the first command like :
>> >
>> > vm_shell_args: '$Password= ConvertTo-SecureString {{ Password }} 
>> > -AsPlainText -Force
>> >
>> > It works. How can i run multiple vm_shell commands ?
>> >
>> > I tried separate then with ';' or '|' but none of it works. Thanks
>> >
>>       I think you can create a loop (lookup "with_items" or "loop" or
>> something like that) and pass the {{ item }}. Thing is I do not know
>> what you are looping around, but I have weaseled out by having the
>> loop task calling/including another task (file) that does the deed.
>>
>> Now if one task depends on the output of the previous one, you could
>> use set a variable and use when to tell the next task the previous one
>> was successful (in case ansible does not catch the error message).
>>
>>
>> > --
>> > 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-project+unsubscr...@googlegroups.com.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/ansible-project/0910a7cb-8859-4fdc-8fe5-bd297886bc09%40googlegroups.com.
>>
>> --
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/ansible-project/bNG29ml5kb0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CAHEKYV6r%2BZCi_xz%3DPFaLWiBNQokmpgfnKaEKWPPE5vGm5AeoBA%40mail.gmail.com.
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/CAFSunMyKJEPOVcns3xkpChz6vkKm7Y56CkSGT8savzNB-09WTg%40mail.gmail.com.

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAHEKYV5f4uQEzeF%3DXJCj%3D8H8%3DnMCAmTV4Co7S_0bTQBNdjm6og%40mail.gmail.com.

Reply via email to