Developer

 View Only
last person joined: 2 days ago 

Expand all | Collapse all

Create local admin user via ansible

This thread has been viewed 24 times
  • 1.  Create local admin user via ansible

    Posted Aug 13, 2024 03:05 AM

    I just wonder if there is an ansible module for arubaos-cx to create local admin users via ansible, similar to cisco.nxos.nxos_user.

    Thank you.

    I tried to post the message last night, but I could not find it anywhere, so I post it again.



  • 2.  RE: Create local admin user via ansible

    Posted Aug 14, 2024 01:40 PM

    Hi @zwluxx



    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 3.  RE: Create local admin user via ansible

    Posted Aug 28, 2024 12:30 PM

    Thank you Ti.

    I finally got some time to test the aoscx_command ( show version and show run) via ssh.  While I was able to run the simple playbook via user/password. I failed to run the playbook via ssh public key.  

    I can login into the switch with my public key, but failed with simple playbook.  I also noticed that the command line option of -u, does not seem to work, it didn't overwrite the user defined in the inventory.

    Is there anything I need to do for ssh-public-key authentication to work on ansible aoscx

    sample_playbook.yml

    • hosts: all
        collections:
          - arubanetworks.aoscx
        gather_facts: False
        tasks:
          - name: show version
            aoscx_command:
              commands:
                - 'show version'
                - 'show run'
              output_file: /tmp/show-test.txt
              output_file_format: plain-text

    sample_inventory.yml

    all:
      hosts:
        testaruba:
          ansible_host: 10.1.1.1
          ansible_user: test
          ansible_ssh_private_key_file: ~/.ssh/id_ed25519
          ansible_connection: network_cli
          ansible_network_os: arubanetworks.aoscx.aoscx




  • 4.  RE: Create local admin user via ansible

    Posted Aug 28, 2024 01:38 PM

    I think that I figured out the issue. I need to start a "ssh-agent", even though, the test user private-key is passphraseless.  After I added the key into ssh-agent, I was able to run the playbook with ssh key authentication.




  • 5.  RE: Create local admin user via ansible

    Posted Aug 28, 2024 02:53 PM

    I create a local admin account with aoscx_config, but I failed to run the "no user xyz" with aoscx_config,  it is expecting to type "y/n", how would I do that with aoscx_config?

    Thank you.




  • 6.  RE: Create local admin user via ansible

    Posted Aug 28, 2024 03:08 PM

    You're going to want to use the "prompt:" and "answer:" parameters in the aoscx_command module you can see an example here: https://github.com/aruba/aoscx-ansible-workflows/blob/main/copy_config_using_cli_prompt.yml

    An example could look like so:

        - name: Enter config mode and remove User
          aoscx_command:
            commands:
              - command: config
              - command: no user test
                check_all: True
                prompt:
                  - '.*\(y\/n\)\?.*'
                answer:
                  - y



    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 7.  RE: Create local admin user via ansible

    Posted Aug 29, 2024 02:27 PM

    Thank you, Ti.

    The ansible script worked good!