Home / ansible play

My First Ansible Play!

DS
Donald Seder
February 17, 2026
8 min

"Here I go! On another adventure to learn another tool. Ive done python, terraform, powershell. Onto Ansible."

My goal with learning this was purely for networking equipment. Primarily Aruba networking gear. I have finally done it! I made my first Ansible play and even though this is small and a simple {show run} command. I think its important to see what you have done and to learn to be proud of your accomplishments.

After reading the Aruba documentation on Github, Ansible documentation, and some help from Claude AI. This is how i setup my first Ansible Play!

Building the Environment

I decided to build out a virtual machine at home running Ubuntu Server 24.04. I made sure to update the host by running the following:

apt update && apt full-upgrade -y

After that we need to get python installed and setup the virtual environment.

Verify python is install

python3

Exit the python terminal

CTRL + D

Install python-venv

apt install python3-venv -y

Create a python virtual environment

python3 -m venv ~/aoscx-venv

Activate the environment

source ~/aoscx-venv/bin/activate

Install Ansible Inside the Virtual Environment

pip install --upgrade pip setuptools wheel pip install ansible

You can verify that ansible is install correctly by running:

which ansible-playbook

Install the Aruba AOS‑CX Ansible Collection Inside the venv. Collections are a distribution format for Ansible content that can include playbooks, roles, modules, and plugins. For this run, it will be the modules we need to execute commands on the switch.

ansible-galaxy collection install arubanetworks.aoscx

If you are using AOS use this:

ansible-galaxy collection install arubanetworks.aos_switch

Now install SSH Transports for network_cli. Ansible’s network_cli plugin requires either Paramiko or ansible‑pylibssh to be installed.

pip install paramiko pip install ansible-pylibssh

Now is a good time to move forward with making sure your switch has ssh enabled.

I created an Ansible directory to keep things in. Such as my host file and playbooks

mkdir ansible-cx

cd ansible-cx

Create a hosts file in your ansible-cx repo. My favorite editor in linux is vi. So in this instance i would type vi hosts. DO NOT USE A FILE EXTENSION. Below is an example hosts file, I used something similar and left out my creds.

  • all:
    • hosts:
      • switch1:
        • ansible_host: 10.10.10.10
        • ansible_user: admin
        • ansible_password: your_password
        • ansible_connection: network_cli
        • ansible_network_os: arubanetworks.aoscx.aoscx
        • ansible_ssh_port: 22

#If you are using AOS change the network_os to: arubanetworks.aos_switch.arubaoss

all: Top-level default group — every host in the inventory belongs to this

hosts: Keyword that declares the list of hosts under this group

switch1: Inventory hostname — this is what Ansible calls the device internally

To see more modules in a Collection, run this:

ansible-doc arubanetworks.aos_switch -l ansible-doc arubanetworks.aoscx -l

Validate that your inventory is correct with the following:

ansible-inventory -i hosts --graph ansible-inventory --list -i hosts

Lets create our playbook now for the commands. Again I use vi so i would type vi play.yml

  • name: CX SSH Test
    hosts: all
    gather_facts: false
    collections:
    • arubanetworks.aoscx
      tasks:
    • name: Show running-config
      aoscx_command:
      commands:
      - show running-config

If you are using AOS collections is arubanetworks.aos_switch, and module is arubaoss_command

NOTE! Before you run this Play. Prevent Ansible from caring about the keys. Unless you import the SSH keys into known_hosts

export ANSIBLE_HOST_KEY_CHECKING=False

Run the Playbook

ansible-playbook -i hosts play.yml -vvv (-vvv just means very verbose!)

-v : Task results

-vv : Task results + task configuration

-vvv : + Connection details, SSH negotiation

-vvvv : + Connection plugin debug (very verbose)
Linux Developer Ansible Automation
DS

Donald Seder

IT Infrastructure Engineer

Infrastructure specialist passionate about automation, Linux, and building secure, scalable environments. Currently streamlining operations at a major regional amusement park.