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

Set -v (VerboseV) not working #152

Closed prakasa1904 closed 3 months ago

prakasa1904 commented 5 months ago

I try to enable -v arg, but it not work, the command always missing -v args. Below is the command output:

ansible-playbook  --extra-vars @/home/cloud.terpusat.com/my-variable.json --inventory /home/cloud.terpusat.com/my-inventory.json --tags golang  --connection ssh --private-key /cloud.terpusat.com/my-key --user root  --become-method sudo cloud.terpusat.com/my-playbook.yml

but when use Verbose, the output will always use -vvvv args, which is not what I want:

ansible-playbook  --extra-vars @/home/cloud.terpusat.com/my-variable.json --inventory /home/cloud.terpusat.com/my-inventory.json --tags golang  -vvvv --connection ssh --private-key /cloud.terpusat.com/my-key --user root  --become-method sudo cloud.terpusat.com/my-playbook.yml

any trick on this, how to use -v / -vv arg ?

apenella commented 4 months ago

Hi @prakasa1904 ! Thanks for opening this issue!

Indeed, the String method in AnsiblePlaybookOptions does not cover all verbosity levels, and I will fix this. In the meantime, when generating the command options, setting the VerboseV attribute should correctly include the -v flag.

I keep you updated! Thanks!

apenella commented 4 months ago

Hi @prakasa1904! Version v2.0.1 solves the issue with the String method, which returned the verbose flags incorrectly. However, as I mentioned, when go-ansible executes a command, it uses the GenerateCommandOptions method, instead, and the issue is not present there.

Will you need further help with this?

apenella commented 3 months ago

I will close this issue as no further assistance is required.