A good practice is to setup a configuration file for Ansible. This file is called ansible.cfg
.
Some of the important configuration items for the ansible.cfg
file is the definition of callbacks that allow to expand the playbook output which is very useful when
troubleshooting.
cat << EOF > /home/pod04/ltrdcn-3225/ansible/playbooks/aci/ansible.cfg
[defaults]
callback_whitelist=ansible.posix.timer,ansible.posix.profile_tasks,ansible.posix.profile_roles
callbacks_enabled=ansible.posix.timer,ansible.posix.profile_tasks,ansible.posix.profile_roles
stdout_callback = community.general.yaml
EOF
To execute an Ansible playbook you simply just use ansible-playbook
. You are going to use our own
host file, so you must specify -i hosts.yml
, where -i
is for inventory and
hosts
is the inventory file name. Lastly, you must specify the playbook file,
site.yml
.
In the terminal window in the ansible directory you should run the following command:
cd ~/ltrdcn-3225/ansible/playbooks/aci
ansible-playbook -i hosts.yml site.yml
This command should produce the following output:
PLAY [APIC Tenant Configuration playbook] ************************************************************************************************************************************************************************ TASK [apic : CREATE ACI TENANT VRF1] ***************************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:39 -0400 (0:00:00.072) 0:00:00.072 ********** Tuesday 04 June 2024 18:54:39 -0400 (0:00:00.071) 0:00:00.071 ********** changed: [apic] TASK [apic : CREATE ACI TENANT VRF2] ***************************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:40 -0400 (0:00:00.988) 0:00:01.060 ********** Tuesday 04 June 2024 18:54:40 -0400 (0:00:00.988) 0:00:01.059 ********** changed: [apic] TASK [apic : CREATE BRIDGE DOMAIN FOR WEB] *********************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:41 -0400 (0:00:00.650) 0:00:01.710 ********** Tuesday 04 June 2024 18:54:41 -0400 (0:00:00.650) 0:00:01.709 ********** changed: [apic] TASK [apic : CREATE SUBNET FOR DB WEB] *************************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:42 -0400 (0:00:00.902) 0:00:02.613 ********** Tuesday 04 June 2024 18:54:42 -0400 (0:00:00.902) 0:00:02.612 ********** changed: [apic] TASK [apic : CREATE BRIDGE DOMAIN FOR DB] ************************************************************************************************************************************************************************ Tuesday 04 June 2024 18:54:43 -0400 (0:00:00.864) 0:00:03.477 ********** Tuesday 04 June 2024 18:54:43 -0400 (0:00:00.864) 0:00:03.476 ********** changed: [apic] TASK [apic : CREATE SUBNET FOR DB BRIDGE DOMAIN] ***************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:43 -0400 (0:00:00.646) 0:00:04.124 ********** Tuesday 04 June 2024 18:54:43 -0400 (0:00:00.646) 0:00:04.123 ********** changed: [apic] TASK [apic : CREATE ACI TENANT APPLICATION PROFILE] ************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:44 -0400 (0:00:00.614) 0:00:04.738 ********** Tuesday 04 June 2024 18:54:44 -0400 (0:00:00.614) 0:00:04.737 ********** changed: [apic] TASK [apic : CREATE DATABASE EPG] ******************************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:46 -0400 (0:00:01.857) 0:00:06.595 ********** Tuesday 04 June 2024 18:54:46 -0400 (0:00:01.857) 0:00:06.594 ********** changed: [apic] TASK [apic : CREATE DATABASE EPG] ******************************************************************************************************************************************************************************** Tuesday 04 June 2024 18:54:47 -0400 (0:00:00.867) 0:00:07.463 ********** Tuesday 04 June 2024 18:54:47 -0400 (0:00:00.867) 0:00:07.462 ********** changed: [10.0.226.41] PLAY RECAP ******************************************************************************************************************************************************************************************************* apic : ok=9 changed=9 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 Playbook run took 0 days, 0 hours, 0 minutes, 8 seconds Tuesday 04 June 2024 18:54:47 -0400 (0:00:00.657) 0:00:08.121 ********** =============================================================================== apic : CREATE ACI TENANT APPLICATION PROFILE -------------------------------------------------------------------------------------------------------------------------------------------------------------- 1.86s apic : CREATE ACI TENANT VRF1 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.99s apic : CREATE BRIDGE DOMAIN FOR WEB ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.90s apic : CREATE DATABASE EPG -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.87s apic : CREATE SUBNET FOR DB WEB --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.86s apic : CREATE DATABASE EPG -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.66s apic : CREATE ACI TENANT VRF2 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.65s apic : CREATE BRIDGE DOMAIN FOR DB ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 0.65s apic : CREATE SUBNET FOR DB BRIDGE DOMAIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.61s Tuesday 04 June 2024 18:54:47 -0400 (0:00:00.657) 0:00:08.120 ********** =============================================================================== apic -------------------------------------------------------------------- 8.05s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ total ------------------------------------------------------------------- 8.05s
And the ACI fabric is now configured. If you run the command again, you will notice that Ansible indicates
that the setting is ok:
. Which means that the configuration is already
at the intended state that you set.
You can re-run the scripts as many times as you wish and Ansible will validate that the configuration is setup this way. If you modify the script in any way, like changing the subnet IP or the mask you will notice that it will indicate changed as it modifies that configuration.
You can also run the playbook in verbose mode by adding the -v
option. This will provide
more information about the execution of the playbook.
ansible-playbook -i hosts.yml site.yml -v
In the case of ACI this even includes the datastructures that are being sent to the APIC. Since we are using the YAML callback, the data is presented in YAML format.
[TRIM] TASK [apic : CREATE DATABASE EPG] ************************************************************************************************************************************************************************************** Tuesday 04 June 2024 18:56:52 -0400 (0:00:00.841) 0:00:06.067 ********** Tuesday 04 June 2024 18:56:52 -0400 (0:00:00.841) 0:00:06.066 ********** ok: [apic] => changed=false current: - fvAEPg: attributes: annotation: orchestrator:ansible descr: POD04 Database EPG dn: uni/tn-aciproglab04/ap-POD04_APP/epg-database exceptionTag: '' floodOnEncap: disabled fwdCtrl: '' hasMcastSource: 'no' isAttrBasedEPg: 'no' matchT: AtleastOne name: database nameAlias: '' pcEnfPref: unenforced prefGrMemb: exclude prio: unspecified shutdown: 'no' userdom: ':all:common:aciproglab04:' [TRIM]
Click on the following link to connect to the APIC. The credentials for your login are:
You may need to close the Meet Cisco APIC x.x(x) by clicking the Let's Go! button, then the Get Started button
Once you logged to the APIC, you will be placed in the System Health page.
Follow these steps to get to your Tenant aciproglab04 :
The first thing you should notice is the nice message that ACI is providing to the user to highlight how this object was created via Ansible. Then you can verify under the summary page the objects created via the Ansible Playbook which includes Application EPGs, VRFfs, Bridge Domains.
You should notice from the summary page the numbers of Application EPGs, VRFfs, Bridge Domains created via Ansible. You can expand the application profiles and networking menus on the left to further see this configuration if desired.