I am unable to copy file from ansible server to juniper switch, I am pasting my playbook, hosts file & group_vars file below and the error which I am getting. Please have a look into this & help to resolve the issue.
Thanks in Advance.
G24Joshi
My Playbook:-
hosts: juniperswitch
gather_facts: no
vars:
ansible_command_timeout: 1800
connection: local
tasks:
name: copy file from Ansible to Switch
junipernetworks.junos.junos_scp:
src: testing6.txt
dest: /var/tmp/
Error:
The full traceback is:
File â/root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.pyâ, line 224, in main
device = get_device(module)
File â/root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/module_utils/network/junos/junos.pyâ, line 155, in get_device
device = Device(host, **kwargs)
File â/usr/local/lib/python3.8/site-packages/jnpr/junos/device.pyâ, line 1263, in init
raise ValueError(âYou must provide either âhostâ or âsock_fdâ valueâ)
fatal: [59.4.42.44]: FAILED! => {
âchangedâ: false,
âinvocationâ: {
âmodule_argsâ: {
âdestâ: â/var/tmp/â,
âproviderâ: {},
ârecursiveâ: false,
âremote_srcâ: false,
âsrcâ: [
âtesting6.txtâ
],
âssh_configâ: null,
âssh_private_key_fileâ: null
}
}, âmsgâ: âYou must provide either âhostâ or âsock_fdâ valueâ
}
Not sure about this, but it seems to me you are using ansible_connection: netconf, whereas module doc is stating:
Works with local connections only.
Since this module uses junos-eznc to establish connection with junos device the netconf configuration parameters needs to be passed using module options for example ssh_config unlike other junos modules that uses netconf connection type.
Method2. I am trying to use ansible module âjunipernetworks.junos.junos_scpâ to copy file from ansible to switch but this is giving me error âYou must provide either âhostâ or âsock_fdâ valueâ.
Playbook:
hosts: juniperswitch
gather_facts: no
connection: local
tasks:
name: run show version on remote devices
junipernetworks.junos.junos_scp:
src: /tmp/abc9.txt
dest: /var/tmp/
remote_src: true
find below error.
The full traceback is:
File â/root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.pyâ, line 224, in main
device = get_device(module)
File â/root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/module_utils/network/junos/junos.pyâ, line 155, in get_device
device = Device(host, **kwargs)
File â/usr/local/lib/python3.8/site-packages/jnpr/junos/device.pyâ, line 1263, in init
raise ValueError(âYou must provide either âhostâ or âsock_fdâ valueâ)
fatal: [67.4.42.33]: FAILED! => {
âchangedâ: false,
âinvocationâ: {
âmodule_argsâ: {
âdestâ: â/var/tmp/â,
âproviderâ: {},
ârecursiveâ: false,
âremote_srcâ: true,
âsrcâ: [
â/tmp/abc9.txtâ
],
âssh_configâ: null,
âssh_private_key_fileâ: null
}
},
âmsgâ: âYou must provide either âhostâ or âsock_fdâ valueâ
}
I was reviewing some older unresolved posts on the network-automation tag and came across this one from a few weeks ago. Are you still in need of help with this one? Iâm not sure if you did see the latest answersâŚ
Also, it would be awesome if you applied the proper formatting to the code snippets you attach on your posts, this will improve readability a lot Thanks a lot in advance! You can do this just by selecting the related text and clicking onto the âpreformatted textâ </> icon on the editor, by the way (you will find it inside the gear icon if youâre using your smartphone).