By the way, this is useful if you are looking for ways to convert linux 'toolbox' commands to powershell equivalents:
https://www.gitbook.com/book/devopscollective/a-unix-person-s-guide-to-powershell/details Jon On Wednesday, September 14, 2016 at 8:22:13 AM UTC+1, J Hawkesworth wrote: > > Hi, > > Windows doesn't have the same kind of shells as linux, so right now, your > best choise is to write powershell and execute it from ansible using the > raw or script modules. Powershell is a little different from bash or ksh. > The main big difference is that you pipe objects not text. > > Here's a intro for someone coming from a linux background > https://developer.rackspace.com/blog/powershell-101-from-a-linux-guy/ > > I like to use ad-hoc ansible to work out commands. > > ansible win10 -m raw -a "gci c:\\" > > There are lot of aliases for command names that roughly approximate to > linux equivalents, but because you are dealing with objects, the (default) > output formats are very different from what you are used to. There's a > bunch of built in formatting commands which can help and you can pick out > just the attributes from objects that you are interested in. > > ansible 10t -m raw -a "gci c:\\|format-list" > > ansible win10 -m raw -a "gci c:\\|convertto-csv" > > ansible 10t -m raw -a "gci c:\\|select Name, CreationTime |convertto-json" > > Hope this gives you an idea of what is possible. > > Jon > > On Tuesday, September 13, 2016 at 8:53:43 AM UTC+1, fanvalt wrote: >> >> Hello, >> >> I did write an Ansible playbook to run on Linux, and now I would like to >> port it to run on Windows. >> >> I would like to list the subdirectories to save it but because I don't >> know the full name, on Linux did write this play: >> - name: Lister l installation existante >> shell: chdir=/{{ Directoryname }} ls -d SHR_4YOU-{{product}}-* >> register: shr4you_inst >> ignore_errors: True >> when: repertoire.stat.isdir is defined and repertoire.stat.isdir >> >> How can I port this line on Windows ? shell: chdir=/{{ Directoryname }} >> ls -d SHR_4YOU-{{product}}-* >> >> Thanks for your help. >> Regards, >> > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1a6b1b06-da4d-4821-a7bb-31162ec17364%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
