aruba / aos-switch-ansible-collection

Ansible collection for AOS-Switch switches
66 stars 16 forks source link

arubaoss_config_bkup - unable to load response from device #72

Open adparis99 opened 1 year ago

adparis99 commented 1 year ago

Hey there, I'm trying to use the arubaoss_config_bkup module to backup device configurations for some of our Aruba equipment, but I haven't gotten it to work so far.

Here is my playbook:

- name: Get Config For HP Switches
  hosts: host
  collections:
    - arubanetworks.aos_switch
  gather_facts: no
  vars:
    ansible_network_os: arubanetworks.aos_switch.arubaoss
    ansible_user:  username
    ansible_password: password
    ansible_connection: local

  tasks:
    - name: Backup HP Switch Configuration
      arubaoss_config_bkup: 
        file_name: /path/to/backup.txt
        config_type: CT_RUNNING_CONFIG

Here is the output of the task:

    "changed": false,
    "data": "",
    "invocation": {
        "module_args": {
            "api_version": "v8.0",
            "config_type": "CT_RUNNING_CONFIG",
            "file_name": "/path/to/backup.txt",
            "forced_reboot": null,
            "host": "ip_address_here",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 80,
            "provider": {
                "api_version": null,
                "host": "ip_address_here",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": 80,
                "ssh_keyfile": null,
                "timeout": 30,
                "transport": "aossapi",
                "use_proxy": false,
                "use_ssl": false,
                "username": "username",
                "validate_certs": false
            },
            "recovery_mode": null,
            "server_ip": null,
            "server_name": null,
            "server_passwd": null,
            "server_type": null,
            "sftp_port": 22,
            "ssh_keyfile": null,
            "state": "create",
            "timeout": 30,
            "use_ssl": false,
            "user_name": null,
            "username": "username",
            "validate_certs": false,
            "wait_for_apply": true
        }
    },
    "msg": "unable to load response from device"

ansible_host is defined in hostvars, and I'm explicitly defining the needed environment variable at runtime. Any thoughts on why I might be getting this error?

alagoutte commented 1 year ago

Hi,

Do you have check the switch config ? (you are using HTTP ? not HTTPS ?)

tchiapuziowong commented 1 year ago

Hi @adparis99 I don't believe this is the correct module for what you're trying to accomplish- it seems you're trying to backup the configuration of the switch to a local file? If so you would want to use the arubaoss_config module which uses SSH to connect to the switch and retrieve the running configuration. Remember when using this module you'll want to ensure you have the ansible_connection: network_cli variable set, for further instructions see here.

Here's the entire playbook, please let me know if you run into additional errors with this:

- hosts: all
  collections:
    - arubanetworks.aos_switch
  gather_facts: False
  vars:
    ansible_connection: network_cli
  tasks:
    - name: Backup config to local file
      arubaoss_config:
        backup: True
        backup_options:
          filename: backup.txt
          dir_path: /path/to
adparis99 commented 1 year ago

Ah, gotcha! I was looking here and here, which seemed to imply I could use arubaoss_config_bkup to get it via the API. In any case, I'll give this a try. Thanks for the help!

Flamme-2 commented 1 year ago

Hello,

I have the same issue when I try to configure ntp server. My task in playbook :

  - name: Set NTP server
    arubaoss_ntp:
      command: "config_ntp_ipv4addr"
      ntp_ip4addr: "192.168.10.3"
      mode: "burst"
      api_version: "{{ ansible_api_version }}"
      use_ssl: "{{ ansible_use_ssl }}"
      port: "{{ ansible_port }}"
      host: "{{ ansible_host }}"
      username: "{{ ansible_user }}"
      password: "{{ ansible_password }}"
    delegate_to: "{{ passthrough }}"
    remote_user: "{{ hostvars[passthrough].ansible_user }}"
    vars:
      ansible_ssh_private_key_file: "{{ hostvars[passthrough].ansible_ssh_private_key_file }}"
    tags:
      - system
      - ntp

Error occured :

FAILED! => { "changed": false, "data": "", "invocation": { "module_args": { "api_version": "v8.0", "association_value": 8, "authenticationMode": "md5", "command": "config_ntp_ipv4addr", "config": "create", "host": "192.168.18.20", "include_credentials_in_response": "ICS_ENABLED", "keyId": 0, "keyValue": "", "maxpoll_value": 10, "minpoll_value": 6, "mode": "burst", "ntp_ip4addr": "192.168.10.3", "operate": "broadcast", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 443, "provider": null, "ssh_keyfile": null, "timeout": null, "timesyncType": "timep-or-sntp", "trap_value": null, "trusted": true, "use_oobm": false, "use_ssl": true, "username": "admin", "validate_certs": false } }, "msg": "unable to load response from device" }

BUT if the configuration in the switch is already set, no error is reported (I juste IP is changed).

OK => { "changed": false, "invocation": { "module_args": { "api_version": "v8.0", "association_value": 8, "authenticationMode": "md5", "command": "config_ntp_ipv4addr", "config": "create", "host": "192.168.18.20", "include_credentials_in_response": "ICS_ENABLED", "keyId": 0, "keyValue": "", "maxpoll_value": 10, "minpoll_value": 6, "mode": "burst", "ntp_ip4addr": "192.168.10.2", "operate": "broadcast", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 443, "provider": null, "ssh_keyfile": null, "timeout": null, "timesyncType": "timep-or-sntp", "trap_value": null, "trusted": true, "use_oobm": false, "use_ssl": true, "username": "admin", "validate_certs": false } }, "ip4addr": { "ip4addr_reference": { "burst": true, "max-poll": { "max-poll_value": 10 }, "min-poll": { "min-poll_value": 6 } }, "ip4addr_value": "192.168.10.2" }, "uri": "/config/ntp/server/ip4addr/192.168.10.2" }

Conf of switch :

timesync ntp ntp server 192.168.10.2 burst ntp enable

PS :

chr00ted commented 3 weeks ago

SO it looks like 2930F's are aoscx so for giggles, I tried updating inventory to this (only changed 1): all: hosts: SW01: ansible_host: 192.168.104.50 ansible_network_os: arubanetworks.aoscx.aoscx ansible_connection: arubanetworks.aoscx.aoscx # REST API connection method ansible_httpapi_validate_certs: False ansible_httpapi_use_ssl: True ansible_acx_no_proxy: True

Switch-02: ansible_host: 192.168.104.51 ansible_connection: local # REST API connection method ansible_network_os: arubanetworks.aos_switch.arubaoss # Do not change

Retested and nogo