This PR introduces a set of Ansible tags to give users control over which roles in the collection get executed and limited support for which parts of a role get executed. This provides a more flexible framework and performance improvement if users don't need to run all of the stages. For example, if they add a VRF or Network and all of the other state is current, there is no reason to run all of the stages. This allows them to run only VRF and Network stages.
NOTE 1: The tests under the tests/integration folder have been updated to support the tags
NOTE 2: The validate and common roles always run regardless of which tag is specified
The following Ansible tags are enabled:
Tags within the roles:
cr stands for create_role
The following tags can be used to selectively execute stages within the cisco.nac_dc_vxlan.create role
cr_manage_fabric
cr_manage_switches
cr_manage_vpc_peers
cr_manage_interfaces
cr_manage_vrfs_networks
# Selectively run stage to add VRFs and Networks and skip all other stages
ansible-playbook -i test_inventory.yml test_vxlan_large.yml --tags cr_manage_vrfs_networks
rr stands for remove_role
The following tags can be used to selectively execute stages within the cisco.nac_dc_vxlan.create role
rr_manage_interfaces
rr_manage_networks
rr_manage_vrfs
rr_manage_vpc_peers
rr_manage_links
rr_manage_switches
# Selectively run stage to remove networks and vrfs and skip all other stages
ansible-playbook -i test_inventory.yml test_vxlan_large.yml --tags "rr_manage_networks, rr_manage_vrfs"
Role Level Tags:
role_validate - Select and run cisco.nac_dc_vxlan.validate role
role_create - Select and run cisco.nac_dc_vxlan.create role
role_deploy - Select and run cisco.nac_dc_vxlan.deploy role
role_remove - Select and run cisco.nac_dc_vxlan.remove role
The validate role will automatically run if tags role_create, role_deploy, role_remove are specified.
Note: The roles must be tagged in the top level playbook for these capabilities to work so we will need to update our example_repo to indicate this.
# This is the main entry point playbook for calling the various
# roles in this collection.
- hosts: nac-ndfc1
any_errors_fatal: true
gather_facts: no
roles:
# Prepare service model for all subsequent roles
#
- role: cisco.nac_dc_vxlan.validate
tags: 'role_validate'
# -----------------------
# DataCenter Roles
# Role: cisco.netascode_dc_vxlan.dtc manages direct to controller NDFC workflows
#
- role: cisco.nac_dc_vxlan.dtc.create
tags: 'role_create'
- role: cisco.nac_dc_vxlan.dtc.deploy
tags: 'role_deploy'
- role: cisco.nac_dc_vxlan.dtc.remove
tags: 'role_remove'
Example: Selectively Run cisco.nac_dc_vxlan.create role alone
Summary:
This PR introduces a set of Ansible tags to give users control over which roles in the collection get executed and limited support for which parts of a role get executed. This provides a more flexible framework and performance improvement if users don't need to run all of the stages. For example, if they add a VRF or Network and all of the other state is current, there is no reason to run all of the stages. This allows them to run only VRF and Network stages.
NOTE 1: The tests under the
tests/integration
folder have been updated to support the tags NOTE 2: The validate and common roles always run regardless of which tag is specifiedThe following Ansible tags are enabled:
Tags within the roles:
cr
stands forcreate_role
The following tags can be used to selectively execute stages within the
cisco.nac_dc_vxlan.create
rolerr
stands forremove_role
The following tags can be used to selectively execute stages within the
cisco.nac_dc_vxlan.create
roleRole Level Tags:
cisco.nac_dc_vxlan.validate
rolecisco.nac_dc_vxlan.create
rolecisco.nac_dc_vxlan.deploy
rolecisco.nac_dc_vxlan.remove
roleThe validate role will automatically run if tags
role_create, role_deploy, role_remove
are specified.Note: The roles must be tagged in the top level playbook for these capabilities to work so we will need to update our example_repo to indicate this.
Example: Selectively Run
cisco.nac_dc_vxlan.create
role aloneThis update provides the following help at runtime if an invalid tag is specified