mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
network_put and network_get modules (#39592)
* Initial commit * Socket Timeout and dest file handler * sftp handling * module name change as per review * multiple thread tmp file overwite problem * Integration test suite for network_put * add additional testcase for dest argument * fix pylint/pep8/modules warnings * add socket timeout for get_file * network_get module * pep8 issue on network_get * Review comments
This commit is contained in:
parent
05c4f5997e
commit
86c945a628
12 changed files with 543 additions and 5 deletions
0
lib/ansible/modules/network/files/__init__.py
Normal file
0
lib/ansible/modules/network/files/__init__.py
Normal file
70
lib/ansible/modules/network/files/network_get.py
Normal file
70
lib/ansible/modules/network/files/network_get.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2018, Ansible by Red Hat, inc
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'network'}
|
||||
|
||||
|
||||
DOCUMENTATION = """
|
||||
---
|
||||
module: network_get
|
||||
version_added: "2.6"
|
||||
author: "Deepak Agrawal (@dagrawal)"
|
||||
short_description: Copy files from a network device to Ansible Controller
|
||||
description:
|
||||
- This module provides functionlity to copy file from network device to
|
||||
ansible controller.
|
||||
options:
|
||||
src:
|
||||
description:
|
||||
- Specifies the source file. The path to the source file can either be
|
||||
the full path on the network device or a relative path as per path
|
||||
supported by destination network device.
|
||||
required: true
|
||||
protocol:
|
||||
description:
|
||||
- Protocol used to transfer file.
|
||||
default: scp
|
||||
choices: ['scp', 'sftp']
|
||||
dest:
|
||||
description:
|
||||
- Specifies the destination file. The path to the destination file can
|
||||
either be the full path on the Ansible control host or a relative
|
||||
path from the playbook or role root directory.
|
||||
default:
|
||||
- Same filename as specified in src. The path will be playbook root
|
||||
or role root directory if playbook is part of a role.
|
||||
|
||||
requirements:
|
||||
- "scp"
|
||||
|
||||
notes:
|
||||
- Some devices need specific configurations to be enabled before scp can work
|
||||
These configuration should be pre-configued before using this module
|
||||
e.g ios - C(ip scp server enable)
|
||||
- User privileage to do scp on network device should be pre-configured
|
||||
e.g. ios - need user privileage 15 by default for allowing scp
|
||||
- Default destination of source file
|
||||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
- name: copy file from the network device to ansible controller
|
||||
network_get:
|
||||
src: running_cfg_ios1.txt
|
||||
|
||||
- name: copy file from ios to common location at /tmp
|
||||
network_put:
|
||||
src: running_cfg_sw1.txt
|
||||
dest : /tmp/ios1.txt
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
"""
|
71
lib/ansible/modules/network/files/network_put.py
Normal file
71
lib/ansible/modules/network/files/network_put.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2018, Ansible by Red Hat, inc
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'network'}
|
||||
|
||||
|
||||
DOCUMENTATION = """
|
||||
---
|
||||
module: network_put
|
||||
version_added: "2.6"
|
||||
author: "Deepak Agrawal (@dagrawal)"
|
||||
short_description: Copy files from Ansibe controller to a network device
|
||||
description:
|
||||
- This module provides functionlity to copy file from Ansible controller to
|
||||
network devices.
|
||||
options:
|
||||
src:
|
||||
description:
|
||||
- Specifies the source file. The path to the source file can either be
|
||||
the full path on the Ansible control host or a relative path from the
|
||||
playbook or role root directory.
|
||||
required: true
|
||||
protocol:
|
||||
description:
|
||||
- Protocol used to transfer file.
|
||||
default: scp
|
||||
choices: ['scp', 'sftp']
|
||||
dest:
|
||||
description:
|
||||
- Specifies the destination file. The path to destination file can
|
||||
either be the full path or relative path as supported by network_os.
|
||||
default:
|
||||
- Filename from src and at default directory of user shell on
|
||||
network_os.
|
||||
required: no
|
||||
|
||||
requirements:
|
||||
- "scp"
|
||||
|
||||
notes:
|
||||
- Some devices need specific configurations to be enabled before scp can work
|
||||
These configuration should be pre-configued before using this module
|
||||
e.g ios - C(ip scp server enable).
|
||||
- User privileage to do scp on network device should be pre-configured
|
||||
e.g. ios - need user privileage 15 by default for allowing scp.
|
||||
- Default destination of source file.
|
||||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
- name: copy file from ansible controller to a network device
|
||||
network_put:
|
||||
src: running_cfg_ios1.txt
|
||||
|
||||
- name: copy file at root dir of flash in slot 3 of sw1(ios)
|
||||
network_put:
|
||||
src: running_cfg_sw1.txt
|
||||
protocol: sftp
|
||||
dest : flash3:/running_cfg_sw1.txt
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
"""
|
Loading…
Add table
Add a link
Reference in a new issue