napalm-automation / napalm-ansible

Apache License 2.0
246 stars 103 forks source link

install config change failed #26

Closed davehs30 closed 8 years ago

davehs30 commented 8 years ago

I have attached the playbook and the config file that is trying to be updated.
fortigate.config-update.yml.txt

new.conf.txt

This is the output that I am getting from the playbook:

ansible-tst:~/fortigate# ansible-playbook fortigate.config-update.yml

PLAY [firewall] ***

GATHERING FACTS *** ok: [homefw]

TASK: [update config] ***** failed: [homefw] => {"failed": true} msg: cannot install config:

FATAL: all hosts have already failed -- aborting

PLAY RECAP **** to retry, use: --limit @/root/fortigate.config-update.retry

homefw : ok=1 changed=0 unreachable=0 failed=1


Many Thanks!

dbarrosop commented 8 years ago

Can you make sure you have the latest code for napalm_install_config.py? It's not going to fix anything but it gives a nicer error message that might help us.

davehs30 commented 8 years ago

Confirmed version 2.1 in the napalm_install_config.py, down loaded the 'raw' file and ran diff just to confirm nothing was changed.

dbarrosop commented 8 years ago

Can you try running with -vvvv? On Tue 3 May 2016 at 14:42, davehs30 notifications@github.com wrote:

Confirmed version 2.1 in the napalm_install_config.py, down loaded the 'raw' file and ran diff just to confirm nothing was changed.

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/napalm-automation/napalm-ansible/issues/26#issuecomment-216673708

davehs30 commented 8 years ago

Sure;

ansible-tst:~/fortigate# ansible-playbook -vvvv fortigate.config-update.yml

PLAY [firewall] ***

GATHERING FACTS ***

REMOTE_MODULE setup EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1462317778.87-210030826951668 && echo $HOME/.ansible/tmp/ansible-tmp-1462317778.87-210030826951668'] PUT /tmp/tmpfichws TO /root/.ansible/tmp/ansible-tmp-1462317778.87-210030826951668/setup EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1462317778.87-210030826951668/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1462317778.87-210030826951668/ >/dev/null 2>&1'] ok: [homefw] TASK: [update config] ********************************************************\* REMOTE_MODULE napalm_install_config hostname=homefw username=admin dev_os=fortios password=VALUE_HIDDEN optional_args="fortios_vdom=global" config_file=/root/fortigate/compiled/homefw/new.conf commit_changes=true replace_config=false get_diffs=true diff_file=/root/fortigate/compiled/homefw/diff.conf EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1462317778.97-44118767300883 && echo $HOME/.ansible/tmp/ansible-tmp-1462317778.97-44118767300883'] PUT /tmp/tmpaUQNDT TO /root/.ansible/tmp/ansible-tmp-1462317778.97-44118767300883/napalm_install_config EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1462317778.97-44118767300883/napalm_install_config; rm -rf /root/.ansible/tmp/ansible-tmp-1462317778.97-44118767300883/ >/dev/null 2>&1'] failed: [homefw] => {"failed": true} msg: cannot install config: FATAL: all hosts have already failed -- aborting PLAY RECAP *******************************************************************\* to retry, use: --limit @/root/fortigate.config-update.retry homefw : ok=1 changed=0 unreachable=0 failed=1 > On May 3, 2016, at 5:57 PM, David Barroso notifications@github.com wrote: > > Can you try running with -vvvv? > On Tue 3 May 2016 at 14:42, davehs30 notifications@github.com wrote: > > > Confirmed version 2.1 in the napalm_install_config.py, down loaded the > > 'raw' file and ran diff just to confirm nothing was changed. > > > > — > > You are receiving this because you commented. > > > > Reply to this email directly or view it on GitHub > > https://github.com/napalm-automation/napalm-ansible/issues/26#issuecomment-216673708 > > > > — > > You are receiving this because you authored the thread. > > Reply to this email directly or view it on GitHub https://github.com/napalm-automation/napalm-ansible/issues/26#issuecomment-216689887
mbuschmann28 commented 8 years ago

What version of python are you using? (python -V). I've seen something similar with <2.7 version. If you suspect that might be the case, you can try setting the interpreter version manually in your command as a test:

ansible-playbook fortigate.config-update.yml --extra-vars "ansible_python_interpreter=/" -vvvv

-mike

mbuschmann28 commented 8 years ago

Sorry, looks like git omitted my example path (you would replace with your actual path to 2.7): 'ansible-playbook fortigate.config-update.yml --extra-vars "ansible_python_interpreter=/bin/python2.7" -vvvv

davehs30 commented 8 years ago

output looks the same to me.

ansible-tst:~/fortigate# ansible-playbook fortigate.config-update.yml --extra-vars "ansible_python_interpreter=/usr/bin/python2.7" -vvvv

PLAY [firewall] ***

GATHERING FACTS ***

REMOTE_MODULE setup EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1462324029.86-258530902571369 && echo $HOME/.ansible/tmp/ansible-tmp-1462324029.86-258530902571369'] PUT /tmp/tmpb6gjK0 TO /root/.ansible/tmp/ansible-tmp-1462324029.86-258530902571369/setup EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python2.7 /root/.ansible/tmp/ansible-tmp-1462324029.86-258530902571369/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1462324029.86-258530902571369/ >/dev/null 2>&1'] ok: [homefw] TASK: [update config] ********************************************************\* REMOTE_MODULE napalm_install_config hostname=homefw username=admin dev_os=fortios password=VALUE_HIDDEN optional_args="fortios_vdom=global" config_file=/root/fortigate/compiled/homefw/new.conf commit_changes=true replace_config=false get_diffs=true diff_file=/root/fortigate/compiled/homefw/diff.conf EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1462324029.98-38038107993480 && echo $HOME/.ansible/tmp/ansible-tmp-1462324029.98-38038107993480'] PUT /tmp/tmpvLpSqj TO /root/.ansible/tmp/ansible-tmp-1462324029.98-38038107993480/napalm_install_config EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python2.7 /root/.ansible/tmp/ansible-tmp-1462324029.98-38038107993480/napalm_install_config; rm -rf /root/.ansible/tmp/ansible-tmp-1462324029.98-38038107993480/ >/dev/null 2>&1'] failed: [homefw] => {"failed": true} msg: cannot install config: FATAL: all hosts have already failed -- aborting PLAY RECAP *******************************************************************\* to retry, use: --limit @/root/fortigate.config-update.retry homefw : ok=1 changed=0 unreachable=0 failed=1 > On May 3, 2016, at 7:01 PM, mbuschmann28 notifications@github.com wrote: > > Sorry, looks like git omitted my example path (you would replace with your actual path to 2.7): 'ansible-playbook fortigate.config-update.yml --extra-vars "ansible_python_interpreter=/bin/python2.7" -vvvv > > — > You are receiving this because you authored the thread. > Reply to this email directly or view it on GitHub https://github.com/napalm-automation/napalm-ansible/issues/26#issuecomment-216703090
mbuschmann28 commented 8 years ago

So if you have confirmed that you're using an updated version of python and its still not working, then my best guess is that you have something defined in your configuration template that napalm_install_config is not happy with, maybe a special character or something? I would try reducing your template config down to something very simple to a point where it works, and then working in the reset to debug what might be the cause..

-mike

dbarrosop commented 8 years ago

It would be interesting if you could try with ansible directly without ansible. It might give some more information.

davehs30 commented 8 years ago

Looks like I have a problem with Python and Napalm. I am also getting errors when I go to upgrade python modules. Will build a new test system.

ansible-tst:~/fortigate# cl_napalm_configure --user admin --password \ --vendor fortios --strategy merge --optional_arges 'fortios_vdom=global' compiled/homefw/new.conf homefw Traceback (most recent call last): File "/usr/bin/cl_napalm_configure", line 9, in load_entry_point('napalm-base==0.13.0', 'console_scripts', 'cl_napalm_configure')() File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 542, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2569, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2229, in load return self.resolve() File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2235, in resolve module = import(self.module_name, fromlist=['name**'], level=0) ImportError: No module named clitools.cl_napalm_configure

On May 4, 2016, at 3:27 PM, David Barroso notifications@github.com wrote:

It would be interesting if you could try with ansible directly without ansible. It might give some more information.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/napalm-automation/napalm-ansible/issues/26#issuecomment-216992483

dbarrosop commented 8 years ago

I recommend you to use virtualenv and pip.

mbuschmann28 commented 8 years ago

JFYI - I've actually had issues getting Ansible (ver 1.9.4) to use the correct python version even when using virtualenv.. Setting it manually via the 'ansible_python_interpreter' var is the only thing that has worked for me. I would recommend a new environment using vagrant.

ktbyers commented 8 years ago

This is normal with Ansible...you pretty much always want to set the ansible_python_interpreter (especially with a virtualenv).

dbarrosop commented 8 years ago

As @ktbyers setting ansible_python_interpreter: "/usr/bin/env python" as a global var on your playbook should work fine. If it doesn't in your particular use case for some reason, please, report it to the ansible community, I am sure they would like to know.

ktbyers commented 8 years ago

Nothing else to do on this issue...so closing.