Comments (6)
Hi @gjansen42!
Thanks for opening that issue!
I have checked the extra-vars and seems that are being quoted.
I prepared the example ansibleplaybook-extravars that you can execute to validate it. That is my output:
go run ansibleplaybook-extravars.go
Command: ansible-playbook --extra-vars '{"extravar1":"value11","extravar2":"value12"}' --inventory 127.0.0.1, --connection local --user apenella site.yml
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]
TASK [show values] *************************************************************
ok: [127.0.0.1] =>
msg: |-
value11
value12
PLAY RECAP *********************************************************************
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Which version of go-ansible are you using? I executed the example using the v2.0.0-rc.2 but it should behave in the same way if you use v1.3.0.
I am using the same Ansible version as you:
$ ansible --version
ansible [core 2.16.4]
config file = -/.ansible.cfg
configured module search path = ['-/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /-/.local/lib/python3.10/site-packages/ansible
ansible collection location = -/.ansible/collections:/usr/share/ansible/collections
executable location = -/.local/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.3
libyaml = True
On the other hand, I have seen on your snippets that the output for quoted and unquoted extra-vars is the same. If that is the case, it makes me think that the cause should be another one.
fatal: [www.google.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host [www.google.com](http://www.google.com/) port 55522: Network is unreachable", "unreachable": true}
Can you reach your remote host?
from go-ansible.
from go-ansible.
from go-ansible.
Hi @gjansen42!
Thanks for the info.
Did you have the chance to execute the example ansibleplaybook-extravars?
I'll try to reproduce your scenario, changing the ansible_port
through an extra-var.
from go-ansible.
I already updated the ansibleplaybook-extravars example and I could set the ansible_port as an extra-var
/code/examples/ansibleplaybook-extravars # go run ansibleplaybook-extravars.go
Command: ansible-playbook --extra-vars '{"ansible_port":"22225","extravar1":"value11","extravar2":"value12"}' --inventory inventory.yml --ssh-common-args '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' site.yml
PLAY [server] ******************************************************************
TASK [Gathering Facts] *********************************************************
[WARNING]: Platform linux on host server is using the discovered Python
interpreter at /usr/local/bin/python3.12, but future installation of another
Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-
core/2.16/reference_appendices/interpreter_discovery.html for more information.
ok: [server]
TASK [show values] *************************************************************
ok: [server] => {
"msg": "value11\nvalue12\n"
}
PLAY RECAP *********************************************************************
server : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Could it be that you get confused because the command in the error's output is not properly formatted and lacks quotes?
from go-ansible.
The fix is available in https://github.com/apenella/go-ansible/releases/tag/v2.0.0
from go-ansible.
Related Issues (20)
- Extra vars issue in playbooks HOT 2
- Feature Request: GO:Embed HOT 12
- real time output HOT 5
- Generate vaulted extra-vars
- Change the Executor signature to 'Execute(ctx context.Context, command []string, options ...ExecuteOptions)' HOT 1
- Ansible Configuration Support HOT 6
- SSH StrictHostKeyChecking HOT 3
- [Question] Can we use alias for inventory? HOT 3
- execute.WithEnvVar is not working HOT 4
- Suggestion for a Feature to Execute Inventory-Related Commands HOT 3
- Implementing support for `go-embed-python` HOT 9
- Example for winrm connection configuration HOT 2
- Many ssh <defunct> then using library. HOT 5
- How to properly provide multiple ssh extra args HOT 3
- cannot use go get v2 HOT 3
- Can I embed playbook and inventory file to binary after build HOT 4
- Error decoding results stdout_lines HOT 3
- Unable to see prompt text HOT 3
- Inquiry about Referencing Executed Processes in DefaultExecute Object HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-ansible.