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 <[email protected]>
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 [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/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 [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/CA%2BnsWgz7AW%2BFO-%3DcJy3BaFdWm0z%2BHqYK5ehX%2BkU%3DrequGZtSog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to