Closed mi138 closed 4 years ago
I was not able to get that to work, so I'm trying to figure out the API and maybe start contributing to this. i made (stole code from other contributors here + did some learning) where i can use the clicommand and feed it the command to copy to tftp/sftp.
`ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' }
module: arubaoss_clicommand short_description: implements rest api to send single command line config version_added: "2.4" description:
EXAMPLES = '''
import json from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.arubaoss.arubaoss import run_commands from ansible.module_utils.network.arubaoss.arubaoss import arubaoss_argument_spec from ansible.module_utils.network.arubaoss.arubaoss import get_config
""" def clicommand(module):
params = module.params
data = {}
serverGrp = {}
data['cmd'] =params['cmd']
url = '/cli'
method = 'POST'
result = run_commands(module, url, data, method, check=url)
return result
""" def run_module(): module_args = dict( cmd=dict(type='str', required=True), )
module_args.update(arubaoss_argument_spec)
result = dict(changed=False,warnings='Not Supported')
module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True
)
if module.check_mode:
module.exit_json(**result)
try:
result = clicommand(module)
except Exception as err:
return module.fail_json(msg=err)
module.exit_json(**result)
def main(): run_module()
if name == 'main': main()`
Here's the module (probably buggy? who knows). And here is the playbook:
`---
I was also unable to get it work using arubaoss_config_bkup. Reading into it further it's starting to look like a copy from switch to sftp might not be possible using arubaoss_config_bkup as first thought (still new to this so hoping someone tells me otherwise), maybe there is something I have missed that does it. Thanks for the above, I think the copy command is not supported when using the CliCommand service .... I was hoping to use a similar module to arubaoss_config_bkup to get the backup (rather than CLI).
Have you tried the arubaoss_file_transfer module? I know it works using an HTTP url for upload/download but can you try it out with SFTP?
- name: running config download
arubaoss_file_transfer:
file_url: "sftp://192.168.1.2/switch_config.txt"
file_type: "FTT_CONFIG"
action: "FTA_DOWNLOAD"
Hi @tchiapuziowong Thanks for that suggestion. I tired using the arubaoss_file_transfer module over the weekend, but unfortunately it has not worked. When I try anything other then http or https in the file_url, I get a 400 bad request "The source specified is not a valid URL"... I have a 'copy to sftp' working using the arubaos_switch_ssh_cli, but wanted to try and utilize an api rather than CLI. Is there a different module I could try??
Hi @mi138 ! The AOS-Switch firmware doesn't support copying/transferring via SFTP through REST API - I've documented this limitation in the module_documentation : 7838b7f2d77036dc0236e3cc387ba4ddd10e65f3
If you're feeling creative the aruba cli module is one way to do sftp backups.
On Fri, Mar 20, 2020, 10:53 AM tchiapuziowong notifications@github.com wrote:
Hi @mi138 https://github.com/mi138 ! The AOS-Switch firmware doesn't support copying/transferring via SFTP through REST API - I've documented this limitation in the module_documentation : 7838b7f https://github.com/aruba/aruba-ansible-modules/commit/7838b7f2d77036dc0236e3cc387ba4ddd10e65f3
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aruba/aruba-ansible-modules/issues/79#issuecomment-601834356, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACIUXSPF2B5EPKGOE7JO2WTRIOURXANCNFSM4KSO2MFA .
Hi @mi138 + @Powersquids !
As an update, we just published modules with SSH/CLI command support for the AOS-Switch platform! So if you're able to use SSH though I would suggest using our SSH modules arubaoss_command and arubaoss_config. To install these latest modules follow these steps. If you want to use a combination of both using REST API modules and SSH, I suggest reading this blurb about using both REST API and SSH/CLI modules.
Hope this helps!
Hi there, Is there a way using the module 'arubaoss_config_bkup' to backup the running config to an SFTP(or TFTP) server?
So far I have been able to get it to 1) Create a backup of the config locally on the switch 2) Restore/overwrite the running config from an SFTP server to the switch.
What I am hoping for is to copy the config from the switch to the SFTP server. Is this possible using this module?
Thanks.