Open siegster opened 7 years ago
are you using virtualenv. Try setting ansible_python_interpreter
Looks like it’s not able to find python (where PyEZ might be installed)
You might need to explicitly define where is python Using the variable “ansible_python_interpreter” You can define it in the inventory file or any variable file
In the inventory, it will look like that
[all] qfx junos_host=127.0.0.1 junos_port=2222
[all:vars] ansible_ssh_username=xxxxx ansible_ssh_password=xxxx ansible_python_interpreter=/usr/local/bin/python
Hi,
Thanks for the quick reply. I am not using virtualenv and I have tried setting the ansible_python_interpreter, without any success. I have tried in the inventory, as mentioned above, as well as in the ansible.cfg file, but without any luck.
@dgarros Can you please help.
Hi @siegster Sorry for the late response,
Please can you check where is your python located with which python
.
If you need to define ansible_python_interpreter
, you can't do it in the inventory becaues it's dynamically generated by Vagrant and it's not supported to have it in the Ansible.cfg.
you need to add it in a variable file.
Also do you have this issue with all examples or with one specifically ?
Thanks Damien
Getting the same error with any environment that includes the jnpr.junos module. Error occurs when running the playbooks as well:
TASK [Deploy config to device ... please wait] ***** fatal: [vqfx1]: FAILED! => {"changed": false, "failed": true, "msg": "ImportError: No module named jnpr.junos"}
Set the python interpreter:
angstrom:light-2qfx halbritt$ which python /usr/local/bin/python angstrom:light-2qfx halbritt$ env | grep python ANSIBLE_PYTHON_INTERPRETER=/usr/local/bin/python angstrom:light-2qfx halbritt$`
is it working after you setup the python interpreter?
Apologies, my comment was unclear as a result of order. The interpreter had been set when I got the error. Just now testing I'm testing jnpr.junos with the hello.py and it seems to be able to import jnpr.junos just fine.
Running on Mac installed via pip:
angstrom:light-2qfx halbritt$ pip show junos-eznc | grep ^Version Version: 2.0.1 Python 2.7.12 ansible 2.1.1.0
Please try to define ansible_python_interpreter
in a variable file, for example in group_vars/all/python.yaml
Not sure if Env variables works with Vagrant
I'll test that later. This is definitely related to how ansible is interpreting pythonpath vs. system default. Could also be an issue with homebrew installed python.
setting ansible_python_interpreter didn't seem to help.
Vagrant wasn't the culprit at all. I'm sure it had something to do with having python installed twice. I had used homebrew to install pip, which installed it's own version of python. When I pip installed junos-eznc, it was installed with that version of python that was also in the path.
which python
was the homebrew installed version with junos-eznc installed. Ansible was using the system version regardless of which environment variable or shebang line I set.
Eventually, I fixed it by using homebrew to uninstall pip, ansible, and anything python related. Then I used easy_install to install pip against the system version. Then I pip installed junos-eznc and ansible. Following that process, I was able to get it to work.
The test case, well outside vagrant is just running the following:
angstrom:light-2qfx halbritt$ ansible-playbook pb.conf.all.commit.yaml
PLAY [Generate and Deploy Configuration] ***************************************
TASK [Build configuration] *****************************************************
ok: [vqfx2]
ok: [vqfx1]
TASK [Deploy config to device ... please wait] *********************************
changed: [vqfx1]
changed: [vqfx2]
PLAY RECAP *********************************************************************
Hi,
I am having an issue with the Ansible portion, where it complains about hte jnpr.junos module. However, when doing a test straight from Python, the module can be accessed properly:
The Juniper.junos module for Ansible is also currently installed:
This is on a Mac OS X installation, with the following versions installed:
Might just very well be configuration related, but the VMs come up properly, yet I just cannot use the Ansible modules as they are called from the Vagrant File/current roles. Any help would be appreciated.
Thanks!