community.network.ce_file_copy – Copy a file to a remote cloudengine device over SCP on HUAWEI CloudEngine switches.

Note

This plugin is part of the community.network collection (version 3.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.network.

To use it in a playbook, specify: community.network.ce_file_copy.

Synopsis

  • Copy a file to a remote cloudengine device over SCP on HUAWEI CloudEngine switches.

Requirements

The below requirements are needed on the host that executes this module.

  • paramiko

Parameters

Parameter

Comments

file_system

string

The remote file system of the device. If omitted, devices that support a file_system parameter will use their default values. File system indicates the storage medium and can be set to as follows, 1) flash is root directory of the flash memory on the master MPU. 2) slave#flash is root directory of the flash memory on the slave MPU. If no slave MPU exists, this drive is unavailable. 3) chassis ID/slot number#flash is root directory of the flash memory on a device in a stack. For example, 1/5#flash indicates the flash memory whose chassis ID is 1 and slot number is 5.

Default: “flash:”

local_file

string / required

Path to local file. Local directory must exist. The maximum length of local_file is 4096.

remote_file

string

Remote file path of the copy. Remote directories must exist. If omitted, the name of the local file will be used. The maximum length of remote_file is 4096.

Notes

Note

  • The feature must be enabled with feature scp-server.

  • If the file is already present, no transfer will take place.

  • This module requires the netconf system service be enabled on the remote device being managed.

  • Recommended connection is netconf.

  • This module also works with local connections for legacy playbooks.

Examples

- name: File copy test
  hosts: cloudengine
  connection: local
  gather_facts: no
  vars:
    cli:
      host: "{{ inventory_hostname }}"
      port: "{{ ansible_ssh_port }}"
      username: "{{ username }}"
      password: "{{ password }}"
      transport: cli

  tasks:

  - name: "Copy a local file to remote device"
    community.network.ce_file_copy:
      local_file: /usr/vrpcfg.cfg
      remote_file: /vrpcfg.cfg
      file_system: 'flash:'
      provider: "{{ cli }}"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

changed

boolean

check to see if a change was made on the device

Returned: always

Sample: true

local_file

string

The path of the local file.

Returned: always

Sample: “/usr/work/vrpcfg.zip”

remote_file

string

The path of the remote file.

Returned: always

Sample: “/vrpcfg.zip”

transfer_result

string

information about transfer result.

Returned: always

Sample: “The local file has been successfully transferred to the device.”

Authors

  • Zhou Zhijin (@QijunPan)