ntc_file_copy¶
Synopsis¶
Added in version 1.9.2
Copy a file to the flash (or bootflash) remote network device on supported platforms over SCP. Supported platforms include Cisco Nexus switches with NX-API, Cisco IOS switches or routers, Arista switches with eAPI.
Options¶
| parameter | required | default | choices | comments |
|---|---|---|---|---|
| host | yes |
Hostame or IP address of switch. |
||
| local_file | yes |
Path to local file. Local directory must exist. |
||
| ntc_conf_file | no |
The path to a local NTC configuration file. If omitted, and ntc_host is specified, the system will look for a file given by the path in the environment variable PYNTC_CONF, and then in the users home directory for a file called .ntc.conf. |
||
| ntc_host | no |
The name of a host as specified in an NTC configuration file. |
||
| password | yes |
Password used to login to the target device |
||
| platform | yes |
|
Switch platform |
|
| port | no |
TCP/UDP port to connect to target device. If omitted standard port numbers will be used. 80 for HTTP; 443 for HTTPS; 22 for SSH. |
||
| remote_file | no |
Remote file path to be copied to flash. Remote directories must exist. If omitted, the name of the local file will be used. |
||
| secret | no |
Enable secret for devices connecting over SSH. |
||
| transport | no |
|
Transport protocol for API-based devices. Not used for actual file transfer. |
|
| username | yes |
Username used to login to the target device |
Important
Requires pyntc
Examples¶
- ntc_file_copy:
platform: cisco_nxos_nxapi
local_file: /path/to/file
host: "{{ inventory_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
transport: http
- ntc_file_copy:
ntc_host: n9k1
ntc_conf_file: .ntc.conf
local_file: /path/to/file
- ntc_file_copy:
ntc_host: eos_leaf
local_file: /path/to/file
- ntc_file_copy:
platform: arista_eos_eapi
local_file: /path/to/file
remote_file: /path/to/remote_file
host: "{{ inventory_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
- ntc_file_copy:
platform: cisco_ios
local_file: "{{ local_file_1 }}"
host: "{{ inventory_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
secret: "{{ secret }}"
Return Values¶
Common return values are documented here common_return_values, the following are the fields unique to this module:
| name | despcription | returned | type | sample |
|---|---|---|---|---|
| local_file | The path of the local file. | success | string | /path/to/local/file |
| remote_file | The path of the remote file. | success | string | /path/to/remote/file |
| transfer_status | Whether a file was transfered. "No Transfer" or "Sent". | success | string | Sent |
Note
On NXOS, the feature must be enabled with feature scp-server.
Note
On IOS and Arista EOS, the user must be at privelege 15.
Note
If the file is already present (md5 sums match), no transfer will take place.
Note
Check mode will tell you if the file would be copied.
Note
The same user credentials are used on the API/SSH channel and the SCP file transfer channel.