Cisco ACI is a software-defined networking (SDN) solution that enables network administrators to centrally manage network policies and apply them to a group of devices, rather than individually configuring each device. Ansible is a powerful configuration management tool that can be used to manage Cisco ACI devices. In this article, we will show how to use Ansible to configure a Cisco ACI device.
Ansible is a powerful configuration management tool that can be used to manage Cisco ACI devices. Ansible playbooks are written in YAML, which is a human-readable data format. Ansible playbooks can be used to configure a Cisco ACI device by creating, updating, or deleting objects on the device. Objects can be created, updated, or deleted using the Ansible “aci_rest” module.
The “aci_rest” module can be used to send REST requests to a Cisco ACI device. The “aci_rest” module supports the following methods:
- GET: Used to retrieve data from a Cisco ACI device
- POST: Used to create or update data on a Cisco ACI device
- DELETE: Used to delete data from a Cisco ACI device
In this article, we will use the “aci_rest” module to create a new object on a Cisco ACI device. To do this, we will first create a file called “aci_config.yml” that contains the following YAML:
name: Configure Cisco ACI hosts: all connection: local gather_facts: no
tasks:
- name: Create a new object on the device aci_rest: url: “{{ aci_url }}/{{ aci_object_type }}” method: POST data: “{{ aci_object_data }}” validate_certs: no
In the “aci_config.yml” file, we have defined a task that will use the “aci_rest” module to send a POST request to the Cisco ACI device. The URL for the POST request is specified in the “url” parameter, and the data for the POST request is specified in the “data” parameter. The “validate_certs” parameter is set to “no” to disable SSL certificate verification.
We will also need to create a file called “aci_object_data.yml” that contains the data for the new object that we want to create on the Cisco ACI device. The data for the new object is specified in JSON format. In this example, we will create a new object with the following data:
{ “fvTenant”: { “attributes”: { “descr”: “My tenant”, “name”: “mytenant” } } }
The data in the “aci_object_data.yml” file will be used to create a new object on the Cisco ACI device. The object will be created with the name “mytenant” and the description “My tenant”.
To run the “aci_config.yml” playbook, we will use the following command:
ansible-playbook aci_config.yml -e “aci_url=https://{{ aci_ip_address }}/api/mo/uni.json” -e “aci_object_type=fvTenant”
In the command, we have specified the URL for the Cisco ACI device and the type of object that we want to create. We have also specified the data for the new object in the “aci_object_data.yml” file.
After running the playbook, we can verify that the new object has been created on the Cisco ACI device by running the following command:
curl -k -u {{ aci_username }}:{{ aci_password }} https://{{ aci_ip_address }}/api/mo/uni.json | jq ‘.imdata[].fvTenant’
The output of the command should show the new object that we have created on the Cisco ACI device.
In this article, we have shown how to use Ansible to configure a Cisco AC
Related content
Cisco Aci and Sda Integration Guide
Read about Cisco aci and sda integration guide and learn more!
Cisco Aci Integration With Cisco Ave
Read about Cisco aci integration with cisco ave and learn more!
Cisco Aci and Apic
Read about Cisco aci and apic and learn more!
Cisco Aci and Vmware Integration
Read about Cisco aci and vmware integration and learn more!