apenella / go-ansible

Go-ansible is a Go package that enables the execution of ansible-playbook or ansible commands directly from Golang applications. It supports a wide range of options for each command, enabling smooth integration of Ansible functionality into your projects.
MIT License
905 stars 143 forks source link

Extra vars issue in playbooks #117

Closed BorisKoz closed 1 year ago

BorisKoz commented 1 year ago

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:

apenella commented 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!

BorisKoz commented 1 year ago

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.)