Developer

last person joined: 3 days ago 

Expand all | Collapse all

Using new aos_switch galaxy collection

Jump to Best Answer
  • 1.  Using new aos_switch galaxy collection

    Posted Sep 18, 2020 04:57 AM

    Hello everyone!

    Just this week i noticed aos_switch galaxy collection was released, and so i embarked on a journey to migrate from aruba-ansible-modules to collection, as it simplifies installation greatly both for new employees and AWX deployment

    I have installed collection by using requirements.yml file. Everything seems to be installed just fine, as ansible-doc can find module documentation without a problem.

    After adapting tasks (every module call needed to be prepended with arubanetworks.aos_switch) and host variables (from just "arubaoss" to "arubanetworks.aos_switch.arubaoss", i tried to run the play.

    It worked for both arubaoss_command  and arubaoss_config (i'm changing the ansible_connection in those tasks, as described in docu - the default is local), but it fails miserably on arubaoss_dns or arubaoss_syslog.

    The weirdest thing is, it looks like neither of ansible_user, ansible_password, ansible_hostname are propagated to REST API modules, as i'm getting this error:

    fatal: [proper FQDN here]: FAILED! => {
        "changed": false,
        "invocation": {
            "module_args": {
                "api_version": "None",
                "dns_config_mode": "DCM_MANUAL",
                "dns_domain_names": "",
                "dns_domain_names_2": "",
                "dns_domain_names_3": "",
                "dns_domain_names_4": "",
                "dns_domain_names_5": "",
                "host": null,
                "password": null,
                "port": null,
                "provider": null,
                "server_1": "proper DNS1 IP here",
                "server_2": "proper DNS2 IP here",
                "server_3": "proper DNS3 IP here",
                "server_4": "proper DNS4 IP here",
                "ssh_keyfile": null,
                "timeout": null,
                "use_ssl": null,
                "username": null,
                "validate_certs": false,
                "version_1": "IAV_IP_V4",
                "version_2": "IAV_IP_V4",
                "version_3": "IAV_IP_V4",
                "version_4": "IAV_IP_V4"
            }
        },
        "status": -1,
        "url": "http://None:80/rest/v6.0/login-sessions"
    }

    I don't know what i'm doing wrong here, it looks like only REST API calls have issues, but i have no idea how to debug it further. Is it possible there's a problem within the collection?



  • 2.  RE: Using new aos_switch galaxy collection

    Posted Sep 18, 2020 09:54 AM

    Hi,

     

    What firmware do you are using ?



  • 3.  RE: Using new aos_switch galaxy collection

    Posted Sep 18, 2020 10:57 AM

    The switch is on YA.16.09.0001.

    I'm baffled the most about:

    "url": "http://None:80/rest/v6.0/login-sessions"

    isn't it weird that the fqdn is set to "None"?



  • 4.  RE: Using new aos_switch galaxy collection

    Posted Sep 18, 2020 11:02 AM

    @Scorcerer wrote:

    The switch is on YA.16.09.0001.

    I'm baffled the most about:

    "url": "http://None:80/rest/v6.0/login-sessions"

    isn't it weird that the fqdn is set to "None"?


    What do you have on inventory file ?



  • 5.  RE: Using new aos_switch galaxy collection

    Posted Sep 21, 2020 03:32 AM

    The inventory seen by ansible looks like this:

     

     

    $ ansible-inventory --host switch_fqdn --vault-password-file test/fixtures/vault_password_file -i environments/company/env
    {
        "ansible_connection": "local",
        "ansible_network_os": "arubanetworks.aos_switch.arubaoss",
        "ansible_password": {
            "__ansible_vault": "$ANSIBLE_VAULT;
    	    vaulted_password_here"
        },
        "ansible_user": "manager",
        "dns_server": [
            "DNS1_IP",
            "DNS2_IP",
            "DNS3_IP",
            "DNS4_IP",
            "DNS5_IP"
        ],
        "ntp_server": [
            "NTP1_IP",
            "NTP2_IP"
        ],
        "syslog_port": 5514,
        "syslog_server": "syslog_IP"
    }

     

     

    Also, when i force the host by adding this to a specific module call:

     

    host: "{{ ansible_host }}"

     

    For example:

     

    - name: ArubaOS | Set DNS servers
      arubanetworks.aos_switch.arubaoss_dns:
        host: "{{ ansible_host }}"
        server_1: "{{ dns_server[0] }}"
        server_2: "{{ dns_server[1] }}"
        server_3: "{{ dns_server[2] }}"
        server_4: "{{ dns_server[3] }}"
      register: result

     

    I get this:

     

    TASK [switch.aos : ArubaOS | Set DNS servers] **********************************************
    [DEPRECATION WARNING]: Param 'host' is deprecated. See the module docs for more information. This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in 
    ansible.cfg.
    fatal: [proper_host_here]: FAILED! => {
        "body": "<HTML><TITLE>400 Bad Request</TITLE><H1>Bad Request</H1>Please login to access the resource.<P></HTML>",
        "changed": false,
        "connection": "close",
        "content-length": "102",
        "content-type": "text/html",
        "server": "eHTTP v2.0",
        "status": 400,
        "url": "http://proper_host_here:80/rest/v6.0/login-sessions"
    }
    
    MSG:
    
    HTTP Error 400: Bad Request

     

     

    I get the warning about deprecated host, but why didn't it login automatically? It worked like this with aruba-ansible-modules...



  • 6.  RE: Using new aos_switch galaxy collection

    Posted Sep 24, 2020 06:41 AM

    Foud the underlying cause, not sure how to fix it:

    If after installing the collection i additionally copy two files form aruba-ansible-modules, like this:

    $ mkdir /home/scor/git/ansible/ansible_venv/lib/python3.8/site-packages/ansible/module_utils/network/arubaoss/
    $ cp ../aruba-ansible-modules/aruba_module_installer/library/module_utils/network/arubaoss/arubaoss.py /home/scor/git/ansible/ansible_venv/lib/python3.8/site-packages/ansible/module_utils/network/arubaoss/arubaoss.py
    $ cp ../aruba-ansible-modules/aruba_module_installer/library/plugins/action/arubaoss.py /home/scor/git/ansible/ansible_venv/lib/python3.8/site-packages/ansible/plugins/action/arubaoss.py

    All jobs run without a problem.

    Without those files, no REST API module runs, as they don't have necessary variables.

    I'll create an issue in github about it as well.



  • 7.  RE: Using new aos_switch galaxy collection
    Best Answer

    Posted Sep 25, 2020 04:14 AM

    Turned out i had some missing things in the role file, you can check the solution on github: https://github.com/aruba/aos-switch-ansible-collection/issues/2