No such file or directory: 'initial.conf'
nbctcp opened this issue · 8 comments
Hi,
I just trying napalm-ansible, but the playbook give error No such file or directory: 'initial.conf'
What steps I miss
tq
GOAL:
-change cisco router hostname from R1 to R11
# ansible-playbook playbooks/napalm.yml
PLAY [cisco1] ******************************************************************
TASK [Gathering Facts] *********************************************************
ok: [cisco1]
TASK [create a diff] ***********************************************************
fatal: [cisco1]: FAILED! => {"changed": false, "msg": "cannot load config: [Errno 2] No such file or directory: 'initial.conf'"}
PLAY RECAP *********************************************************************
cisco1 : ok=1 changed=0 unreachable=0 failed=1
# pip freeze | grep napalm
napalm==2.3.2
napalm-ansible==0.10.0
napalm-base==1.0.0
napalm-fortios==0.4.1
napalm-ios==0.8.1
napalm-junos==0.12.1
# cat playbooks/napalm.yml
---
- hosts: cisco1
connection: local
tasks:
- name: "create a diff"
napalm_install_config:
hostname: "{{ansible_host}}"
username: "{{ansible_user}}"
password: "{{ansible_ssh_pass}}"
optional_args: {'secret': '{{ansible_become_pass}}'}
dev_os: "{{ansible_network_os}}"
config_file: initial.conf
commit_changes: false
replace_config: false
diff_file: initial.diff
# cat playbooks/initial.conf
hostname R11
# cat group_vars/cisco.yml
---
ansible_connection: network_cli
ansible_network_os: ios
ansible_user: cisco
ansible_ssh_pass: cisco
ansbile_become: yes
ansible_become_method: enable
ansible_become_pass: cisco
The error you are getting looks pretty self-explanatory...have you looked into that file?
error said can't find initial.conf, but actually initial.conf in the same folder as napalm.yml
root@svr1:/home/admin2/playbooks# ls
backup forti.yml ios_command_2.yml library
cisco2.yml forti.yml.ok ios_config_2.retry napalm-ansible
cisco.yml initial.conf ios_config_2.yml napalm.yml
cisco.yml.ok ios_command_2.retry ios_facts.yml vmware.yml
root@svr1:/home/admin2/playbooks# cat initial.conf
hostname R11
Did you try './initial.conf' or a full path?
Work with full path but not with './initial.conf'
I still wonder why with just 'initial.conf' won't look for the same directory.
While most example on google just have 'initial.conf'
tq
cat playbooks/cisco.yml
- hosts: cisco3
connection: network_cli
tasks:- name: "create a diff"
napalm_install_config:
hostname: "{{ansible_host}}"
username: "{{ansible_user}}"
password: "{{ansible_ssh_pass}}"
optional_args:
inline_transfer: yes
secret: "{{ansible_become_pass}}"
dev_os: "{{ansible_network_os}}"
config_file: "{{ansible_playbook}}initial.conf"
commit_changes: yes
replace_config: false
diff_file: "{{ansible_playbook}}initial.diff"
- name: "create a diff"
That's just how ansible works. Relative paths are relative to the path where the code runs, which is not the same as your working directory. If you want relative paths to your playbook you should do something like {{ playbook_dir }}/initial.conf
.
Closing as this is related to ansible itself and not the plugins.
Note, I would use connection: local
for NAPALM; I am not sure what the effects of using connection: network_cli
are (i.e. that is an invalid configuration with respect to napalm-ansible).
both 'connection: local' or 'connection: network_cli' are working correctly
tried just now
cat playbooks/initial.conf
hostname 3750-48
access-list 10 permit 10.0.1.0 0.0.0.255
Yes...my point is network_cli
is not a valid setting for napalm-ansible so if anything doesn't work, my first response will be to change that.