Closed BorisKoz closed 1 year ago
Hi @BorisKoz! Thank you for opening that issue!
Issue #107 was closed because there was a misunderstanding between the purpose of methods Command and String.
Could you tell me if you are trying to print the output of the method Command?
In that case, you will see that quotes are missing because the []string
returned by the Command method is ready to be executed, and does not provide those quotes. If you justt want to print the output of the command, use the method String instead.
Thanks!
An honest mistake in my part. My json preparation was a bit off, and as the .Run() was using .Command(), which failed, but the .String() ran fine when masted into cmd, so I looked for the differences, which seemed to only be the '
eliminators. Thank you for replying, after checking out again, my json builder was a little bit off.
Sorry.)
This is a duplicate (almost) of a previously closed issue 107 noted here.
The issue was closed, but yet it remains unresolved. The problem remains (in playbooks at least) as follows:
--extra-vars
is https://github.com/apenella/go-ansible/blob/71c1cdfab120ab7bcb439775433a514888fc9ea1/pkg/playbook/ansiblePlaybook.go#L467 and does not encapsulate with'
--extra-vars
with https://github.com/apenella/go-ansible/blob/71c1cdfab120ab7bcb439775433a514888fc9ea1/pkg/playbook/ansiblePlaybook.go#L527 whereextraVars
is generated byo.generateExtraVarsCommand()
so it does encapsulate the json string with'
afterwards--extra-vars
string with'
. So the runtime will fail, as the JSON string will not be detectable from the command line.The fix seems pretty obvious - add the missing
'
, maybe withcmd = append(cmd, fmt.Sprintf("'%s'", extraVars))
inhttps://github.com/apenella/go-ansible/blob/71c1cdfab120ab7bcb439775433a514888fc9ea1/pkg/playbook/ansiblePlaybook.go#L345