�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
m Z d d
l m Z y: d d l m Z d d l m Z d d l m Z e Z Wn e k
r� e Z n Xd � Z d � Z d � Z e d k r
e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust networkt supported_bys
---
module: junos_scp
version_added: "2.5"
author: "Christian Giese (@GIC-de)"
short_description: Transfer files from or to remote devices running Junos
description:
- This module transfers files via SCP from or to remote devices
running Junos.
extends_documentation_fragment: junos
options:
src:
description:
- The C(src) argument takes a single path, or a list of paths to be
transferred. The argument C(recursive) must be C(true) to transfer
directories.
required: true
dest:
description:
- The C(dest) argument specifies the path in which to receive the files.
default: '.'
recursive:
description:
- The C(recursive) argument enables recursive transfer of files and
directories.
type: bool
default: 'no'
remote_src:
description:
- The C(remote_src) argument enables the download of files (I(scp get)) from
the remote device. The default behavior is to upload files (I(scp put))
to the remote device.
type: bool
default: 'no'
requirements:
- junos-eznc
- ncclient (>=v0.5.2)
notes:
- This module requires the netconf system service be enabled on
the remote device being managed.
- Tested against vMX JUNOS version 17.3R1.10.
- Works with C(local) connections only.
s�
# the required set of connection arguments have been purposely left off
# the examples for brevity
- name: upload local file to home directory on remote device
junos_scp:
src: test.tgz
- name: upload local file to tmp directory on remote device
junos_scp:
src: test.tgz
dest: /tmp/
- name: download file from remote device
junos_scp:
src: test.tgz
remote_src: true
sE
changed:
description: always true
returned: always
type: bool
( t
AnsibleModule( t junos_argument_spect get_param( t to_native( t Device( t SCP( t ConnectErrorc C` s� t | d � } i t | d � p$ d d 6t | d � d 6} t | d � r` t | d � | d <n t | d � r� t | d � | d <n t | d
<y5 t | | � } | j � t | d � p� d | _ Wn0 t k
r� } | j d
| t | � f � n X| S( Nt hostt porti> t usernamet usert passwordt passwdt ssh_keyfilet ssh_private_key_filet gather_factst timeouti
s unable to connect to %s: %s( R
t FalseR t openR R t fail_jsonR ( t moduleR t kwargst devicet exc( ( sK /usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_scp.pyt connecta s
!c C` s� | j d } | j d } t | � �m } xc | j d D]T } | j d rl | j | j � d | d | �q7 | j | j � d | d | �q7 WWd QXd S( Nt destt recursivet srct
remote_srct
local_patht remote_path( t paramsR
t gett stript put( R R R! R"