Sorry, I think I mispoke here.

"script" is one of those that works on both platforms.

What you have above is more of a quoting question with what arguments you
are passing to the script, not the contents, so that won't help...

We can investigate, but perhaps others might know the answer to this one?


On Tue, Oct 21, 2014 at 2:03 PM, Michael Perzel <michaelper...@gmail.com>
wrote:

> Can you provide a link to the win_script module? I don't see it in the
> ansible documentation.
>
> I'm using ansible 1.7.2. I've confirmed the issue is caused by my variable
> including an equal sign. I need to quote my variable {{ "var" }} in the
> playbook, but when this variable is used in the script module the quotes
> are included. For example,
>
> var: @{key=value}
>
> script: powershell.ps1 {{ "var" }}
>
> The call to the windows box is:
> powershell.ps1 "@{key=value}"
>
> instead of:
> powershell.ps1 @{key=value}
>
> On Monday, October 20, 2014 3:56:40 PM UTC-5, Michael DeHaan wrote:
>>
>> Possibly easier to use the win_script module maybe?
>>
>> Ansible shouldn't be adding any extra spaces here though, particularly
>> not in recent versions.
>>
>>
>>
>> On Mon, Oct 20, 2014 at 12:21 PM, Michael Perzel <michae...@gmail.com>
>> wrote:
>>
>>> I am having trouble getting ansible to parse my variable values
>>> correctly.
>>>
>>> I have defined a variable:
>>> installArguments: "appPoolName='UiService'; dbPassword='password';
>>> dbUserId='user'"
>>>
>>> I then have a playbook that makes the following call:
>>>
>>> - name: Deploy Launcher
>>> script: deployLauncher.ps1 -env {{ env }} -appName {{ appName }}
>>> -artifacts {{ artifacts }} -installArguments @{ '{{ installArguments }}' }
>>> -deployNumber {{ deployNumber }} {{ switch }}
>>>
>>> If I don't include the single quotes around {{installArguments}} I get a
>>> complaint about the equal sign being unquoted.
>>>
>>> deployLauncher.ps1 is meant to simply echo back the variables at this
>>> point.
>>>
>>> param(
>>>     [Parameter(Mandatory=$true,Position=0)][string] $env,
>>>     [Parameter(Mandatory=$true,Position=1)][string] $server,
>>>     [Parameter(Mandatory=$true,Position=2)][string] $appName,
>>>     [Parameter(Mandatory=$true,Position=3)][string[]] $artifacts,
>>> #first contains install script
>>>     [Parameter(Mandatory=$false,Position=4)][hashtable]
>>> $installArguments = @{},
>>>     [Parameter(Mandatory=$true,Position=5)][string] $deployNumber,
>>>     [Parameter(Mandatory=$false,Position=6)][switch] $switch
>>> )
>>>
>>> #./testLauncher  -env Local -server serverName -appName Name -artifacts
>>> artifacts.zip -installArguments @{key='value'} -deployNumber 123 -switch
>>> Write-Output "Env: $env Server: $server AppName: $appName Artifacts:
>>> $artifacts InstallArguments: $installArguments DeployNumber: $deployNumber
>>> Switch: $switch"
>>>
>>> When I run the playbook I get the following powershell error.
>>>
>>> TASK: [common | debug var=deployLauncher] 
>>> *************************************
>>> ok: [mdm-wsrv98] => { "deployLauncher": { "changed": true, "invocation":
>>> { "module_args": "deployLauncher.ps1 -env LOCAL -appName UiService.Event
>>> -artifacts UiService.Event.zip -installArguments @{
>>> 'appPoolName='UiService'; dbPassword='password'; dbUserId='user'' }
>>> -deployNumber 456 -switch", "module_name": "script" }, "rc": 0, "stderr":
>>> "C:\\Users\\ansible\\AppData\\Local\\Temp\\ansible-tmp-
>>> 1413821995.23-24997058650291\\de\r\nployLauncher.ps1 : Cannot process
>>> argument transformation on parameter \r\n'installArguments'. Cannot convert
>>> the \"@{\" value of type \"System.String\" to \r\ntype 
>>> \"System.Collections.Hashtable\".\r\n
>>> + CategoryInfo : InvalidData: (:) [deployLauncher.ps1], ParentCon \r\n
>>> tainsErrorRecordException\r\n + FullyQualifiedErrorId :
>>> ParameterArgumentTransformationError,deployLaunc \r\n her.ps1\r\n
>>> \r\n", "stdout": "", "stdout_lines": [] } }
>>>
>>> I think that my issue is that ansible is inserting a single quote after
>>> @{ and again after 'user' which isn't valid powershell array syntax. Is
>>> there a better way to quote this so that these don't get included?
>>>
>>> Thanks!
>>>
>>>
>>>  --
>>> 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-proje...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/ansible-project/11db0119-bd96-40e1-aaf0-
>>> 63afbc5f468e%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/11db0119-bd96-40e1-aaf0-63afbc5f468e%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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a2293dfc-2f3b-4c16-88de-ea8f675a91ca%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a2293dfc-2f3b-4c16-88de-ea8f675a91ca%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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxhjTNRvbYh0zpxeaG%3Dq54mGyCixGDDsJWSvNfL%3DOcf7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to