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).
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
בתאריך יום א׳, 12 בינו׳ 2020 ב-21:21 מאת Mauricio Tavares <raubvogel@gmail.com>:
On Sun, Jan 12, 2020 at 2:26 PM רגב בתחן <batchenr@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.
On Sun, Jan 12, 2020 at 3:08 PM רגב בתחן <batchenr@gmail.com> wrote:
I can do it in a script, i was wondering if ansible had another way..
I think the only way to run all commands on the same task is to
it at the powershell level, which is what you were trying to do. I
know using the command module, if I want to do 3 commands in the same
task such that it will stop if one command fails is "commandA &&
commandB && commandC" which is bash, not ansible.
There is nothing stopping you from running a script as a one-liner in
powershell, i.e.
{CommandA -ea Stop} Catch {CommandB}
the third command I do not know how to add. I think ansible is running
your command as