Giter VIP home page Giter VIP logo

Comments (6)

apenella avatar apenella commented on June 10, 2024

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.

gjansen42 avatar gjansen42 commented on June 10, 2024

from go-ansible.

gjansen42 avatar gjansen42 commented on June 10, 2024

from go-ansible.

apenella avatar apenella commented on June 10, 2024

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.

apenella avatar apenella commented on June 10, 2024

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.

apenella avatar apenella commented on June 10, 2024

The fix is available in https://github.com/apenella/go-ansible/releases/tag/v2.0.0

from go-ansible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.