Add your new test role to test/integration/test_winrm.yml with a matching tag, then run:
TEST_FLAGS="-t test_powershell_filter" make test_winrm It may be worthwhile to add to the test_win_script role to make sure your filter works for passing parameters to a PowerShell script. Also, from your test playbook, there is no echo module - maybe you meant to use command instead? On Mon, Feb 23, 2015 at 12:39 PM, Michael Perzel <[email protected]> wrote: > This isn't directly related to this thread but it was discussed earlier so > it was the best place for it. > > I created a filter that converts a yaml dict to a powershell hash. I'm > trying to write some tests for it but I'm not sure how to run just my > specific test. The file playbook and vars are > at ansible/test/integration/roles/test_powershell_filter/ and the filter is > at ansible/lib/ansible/runner/filter_plugins. > > Test playbook: > https://gist.github.com/perzizzle/8fb875895b218772eede > Test variables > https://gist.github.com/perzizzle/dc73025a2232f2da9b88 > Filter > https://gist.github.com/perzizzle/117a6b139e2a97194d5f > > When I run "make tests" a whole bunch of them succeed but one fails > related to postgres. Is it possible to run just my one test I've created? > > Thanks, > > On Wednesday, February 4, 2015 at 1:44:00 AM UTC-6, Chris Church wrote: >> >> Hi Michael, >> >> I had submitted a PR (https://github.com/ansible/ansible/pull/9602) -- >> I'll see if I can get that merged soon. >> >> >> On Mon, Jan 26, 2015 at 2:47 PM, Michael Perzel <[email protected]> >> wrote: >> >>> I ended up creating a new filter that could transform >>> >>> >>> installArguments: >>> >>> key: value >>> >>> key2: value2 >>> >>> and return “@{'key2'='value2';'key'='value';}” I can share if anyone is >>> interested. >>> >>> I just upgraded to ansible 1.8 and made your fix to powershell.py and >>> winrm.py manually again. Is there any target version to get this into the >>> main branch? I poked around in github but couldn't find way to see if you >>> had submitted a pull request for this. >>> >>> >>> On Thursday, November 6, 2014 at 5:26:49 PM UTC-6, Chris Church wrote: >>>> >>>> Absolutely, just haven't had a chance to get back to Windows-related >>>> things this week. >>>> >>>> On Thu, Nov 6, 2014 at 4:37 PM, Michael Perzel <[email protected]> >>>> wrote: >>>> >>>>> Are you going to submit a pull request for this into devel? It >>>>> definitely solved my issue. >>>>> >>>>> On Saturday, October 25, 2014 2:23:55 PM UTC-5, Chris Church wrote: >>>>>> >>>>>> Could you create a gist (https://gist.github.com/) with the relevant >>>>>> lines from your inventory variables, playbook and script (removing any >>>>>> sensitive information)? I'm not quite able to piece together a full >>>>>> example of what you're running from the email thread. >>>>>> >>>>>> My branch is based on devel; I just created another branch based on >>>>>> 1.7.2 with the splatting changes applied: https://github.com/cc >>>>>> hurch/ansible/tree/powershell_splatting_v172 >>>>>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcchurch%2Fansible%2Ftree%2Fpowershell_splatting_v172&sa=D&sntz=1&usg=AFQjCNELYa0RJWKIxEmXb2bqZVp5y1NogA> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Oct 24, 2014 at 6:12 PM, Michael Perzel <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> I tried taking your changes but it failed with: >>>>>>> <Objs Version="1.1.0.1" xmlns="http://schemas.microsof >>>>>>> t.com/powershell/2004/04"><S S="Error">C:\Users\ansible\App >>>>>>> Data\Local\Temp\ansible-tmp-1414187414.25-97343749557638\de_x000D__x000A_</S><S >>>>>>> S="Error">ployLauncher.ps1 : A positional parameter cannot be found that >>>>>>> accepts _x000D__x000A_</S><S S="Error">argument >>>>>>> 'False'._x000D__x000A_</S><S S="Error">At line:1 >>>>>>> char:1_x000D__x000A_</S><S >>>>>>> S="Error">+ & _x000D__x000A_</S><S S="Error">C:\Users\ansible\ >>>>>>> AppData\Local\Temp\ansible-tmp-1414187414.25-97343749557638\\ >>>>>>> _x000D__x000A_</S><S S="Error">..._x000D__x000A_</S><S S="Error">+ >>>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>>>>> ~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error">~~~_x000D__x000A_</S><S >>>>>>> S="Error"> + CategoryInfo : InvalidArgument: (:) [deployLauncher.ps1], >>>>>>> Param _x000D__x000A_</S><S S="Error"> >>>>>>> eterBindingException_x000D__x000A_</S><S >>>>>>> S="Error"> + FullyQualifiedErrorId : PositionalParameterNotFound,de >>>>>>> ployLauncher.ps1_x000D__x000A_</S><S S="Error"> >>>>>>> _x000D__x000A_</S></Objs> >>>>>>> >>>>>>> Looking at the diff between your code and mine there's a few other >>>>>>> differences. I'm running 1.7.2, I assume your branched off something >>>>>>> newer.I'll see if I can sort through the issue. >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> On Friday, October 24, 2014 3:52:39 PM UTC-5, Michael Perzel wrote: >>>>>>>> >>>>>>>> Your idea with jinja filter is what I originally tried to get >>>>>>>> working. I never managed it but I think its the ideal solution >>>>>>>> (converting >>>>>>>> yaml hash to a powershell one). >>>>>>>> >>>>>>>> If I follow your patch you added a parameter that controls whether >>>>>>>> or not arguments get quoted (and set it to false for powershell >>>>>>>> scripts)? >>>>>>>> I'm not particularly worried about nefarious activity within our >>>>>>>> system so >>>>>>>> this could work for us. >>>>>>>> >>>>>>>> On Friday, October 24, 2014 12:52:52 AM UTC-5, Chris Church wrote: >>>>>>>>> >>>>>>>>> That method of passing arguments is apparently called "splatting" ( >>>>>>>>> http://technet.microsoft.com/en-us/magazine/gg675931.aspx). >>>>>>>>> >>>>>>>>> I have a branch where I've been able to get it working: >>>>>>>>> >>>>>>>>> https://github.com/cchurch/ansible/tree/powershell_splatting >>>>>>>>> >>>>>>>>> >>>>>>>>> I've also added integration tests to show examples of it in use: >>>>>>>>> >>>>>>>>> https://github.com/cchurch/ansible/blob/powershell_splatting >>>>>>>>> /test/integration/roles/test_win_script/tasks/main.yml#L50 >>>>>>>>> >>>>>>>>> >>>>>>>>> I also considered the idea of a Jinja2 filter to convert a >>>>>>>>> YAML/JSON data structure to this format to allow for defining your >>>>>>>>> arguments as you would any other variables: >>>>>>>>> >>>>>>>>> build_args: >>>>>>>>> >>>>>>>>> key1: value1 >>>>>>>>> >>>>>>>>> key2: value2 >>>>>>>>> >>>>>>>>> >>>>>>>>> You could then run your task as: >>>>>>>>> >>>>>>>>> script: dostuff.ps1 {{ build_args|splattify }} >>>>>>>>> >>>>>>>>> >>>>>>>>> Would you (or any other Windows users) be interested in this >>>>>>>>> approach? >>>>>>>>> >>>>>>>>> >>>>>>>>> On Wed, Oct 22, 2014 at 10:28 AM, Michael Perzel < >>>>>>>>> [email protected]> wrote: >>>>>>>>> >>>>>>>>>> I'll look into this. My work around thus far is using a template >>>>>>>>>> for my deploy script. Instead of passing the deploy script >>>>>>>>>> arguments, I >>>>>>>>>> just assign them at the top: >>>>>>>>>> >>>>>>>>>> $build = {{ build }} >>>>>>>>>> $pass = {{ password }} >>>>>>>>>> $arguments = @{ {{ arguments }} } >>>>>>>>>> >>>>>>>>>> This then becomes: >>>>>>>>>> >>>>>>>>>> $build = 42 >>>>>>>>>> $pass = password >>>>>>>>>> $arguments = @{ key1=value1; key2= value2 } >>>>>>>>>> >>>>>>>>>> Using the template has given me complete control over the syntax. >>>>>>>>>> In our paradigm we have an entirely generic "deploy" powershell >>>>>>>>>> script that >>>>>>>>>> stages files, unzips them and similar things. It then calls an >>>>>>>>>> "install" >>>>>>>>>> script that handles all the app specific items. The install scripts >>>>>>>>>> are >>>>>>>>>> bundled with the specific app. >>>>>>>>>> >>>>>>>>>> On Wednesday, October 22, 2014 8:38:11 AM UTC-5, J Hawkesworth >>>>>>>>>> wrote: >>>>>>>>>>> >>>>>>>>>>> I don't have a direct answer for this - rightly or wrongly the >>>>>>>>>>>> ps1 scripts I have so far don't take any arguments - I consider >>>>>>>>>>>> them to be >>>>>>>>>>>> specific to my roles and at the moment they embed some details >>>>>>>>>>>> that it >>>>>>>>>>>> would probably be best to have as parameters. However, it looks >>>>>>>>>>>> to me like >>>>>>>>>>>> your deployLauncher.ps1 really wants to be a very general purpose >>>>>>>>>>>> deployment tool and maybe it would be better off as an ansible >>>>>>>>>>>> module. >>>>>>>>>>>> That way you could perhaps take advantage of ansible's existing >>>>>>>>>>>> syntax for >>>>>>>>>>>> specifying module arguments. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> As an aside I believe @Trond Hindenes has a win_package module >>>>>>>>>>> in the works which might do some of what you want. >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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/388179f6-4 >>>>>>>>>> 48e-44e7-967f-94e400dc4514%40googlegroups.com >>>>>>>>>> <https://groups.google.com/d/msgid/ansible-project/388179f6-448e-44e7-967f-94e400dc4514%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>>>> . >>>>>>>>>> >>>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>> 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/ba6b122a-1 >>>>>>> fa5-48c6-9b1d-a8a2f67083ef%40googlegroups.com >>>>>>> <https://groups.google.com/d/msgid/ansible-project/ba6b122a-1fa5-48c6-9b1d-a8a2f67083ef%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >>>>> 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/118759f9-df6f-4805-886d-00a250457019% >>>>> 40googlegroups.com >>>>> <https://groups.google.com/d/msgid/ansible-project/118759f9-df6f-4805-886d-00a250457019%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> 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/35495c72-0da0-42f9-b854- >>> 4ab8f049ccdd%40googlegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/35495c72-0da0-42f9-b854-4ab8f049ccdd%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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/db5bd592-8018-4bf7-971d-6f8652fd9737%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/db5bd592-8018-4bf7-971d-6f8652fd9737%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CAH%2BKTJ7%2B_CpJd7akpqH42VSNmT82eKaOFystwtk0E73G%3DZD3Cg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
