Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:netascode/ansible-dc-vxlan into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
mtarking committed Nov 8, 2024
2 parents 7470588 + 56059eb commit f656c31
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 32 deletions.
2 changes: 1 addition & 1 deletion plugins/action/common/check_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run(self, tmp=None, task_vars=None):
results['save_previous'] = False

roles = self._task.args['role_list']
for role in ['cisco.nac_dc_vxlan.create', 'cisco.nac_dc_vxlan.remove']:
for role in ['cisco.nac_dc_vxlan.create', 'cisco.nac_dc_vxlan.deploy', 'cisco.nac_dc_vxlan.remove']:
if role in roles:
results['save_previous'] = True

Expand Down
62 changes: 57 additions & 5 deletions roles/common_global/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
nac_tags:
# All Create and Remove Tags
all:
- cc_connectivity_check
- cc_version
- cc_verify
# -------------------------
- cr_manage_fabric
- cr_manage_switches
Expand All @@ -47,8 +46,59 @@ nac_tags:
- role_remove
# All Connectivity Check Tags
connectivity_check:
- cc_connectivity_check
- cc_version
- cc_verify
- role_create
- role_deploy
- role_remove
- cr_manage_fabric
- cr_manage_switches
- cr_manage_vpc_peers
- cr_manage_interfaces
- cr_manage_vrfs_networks
- cr_manage_policy
- rr_manage_interfaces
- rr_manage_networks
- rr_manage_vrfs
- rr_manage_vpc_peers
- rr_manage_links
- rr_manage_switches
# We need the ability to pass tags to the common role but we don't need the following
# - validate, cc_verify
common_role:
- role_create
- role_deploy
- role_remove
- cr_manage_fabric
- cr_manage_switches
- cr_manage_vpc_peers
- cr_manage_interfaces
- cr_manage_vrfs_networks
- cr_manage_policy
- rr_manage_interfaces
- rr_manage_networks
- rr_manage_vrfs
- rr_manage_vpc_peers
- rr_manage_links
- rr_manage_switches
# We need the ability to pass tags to the validate role but we don't need the following
# - cc_verify
validate_role:
- role_validate
- role_create
- role_deploy
- role_remove
- cr_manage_fabric
- cr_manage_switches
- cr_manage_vpc_peers
- cr_manage_interfaces
- cr_manage_vrfs_networks
- cr_manage_policy
- rr_manage_interfaces
- rr_manage_networks
- rr_manage_vrfs
- rr_manage_vpc_peers
- rr_manage_links
- rr_manage_switches
# All Create Tags
create:
- cr_manage_fabric
Expand Down Expand Up @@ -89,5 +139,7 @@ nac_tags:
- rr_manage_links
remove_switches:
- rr_manage_switches

deploy:
- role_deploy


3 changes: 2 additions & 1 deletion roles/dtc/common/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ galaxy_info:
license: LICENSE
min_ansible_version: 2.14.15

dependencies: [cisco.nac_dc_vxlan.common_global]
dependencies:
- cisco.nac_dc_vxlan.common_global
2 changes: 1 addition & 1 deletion roles/dtc/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

- name: Import Role Tasks
ansible.builtin.import_tasks: sub_main.yml
tags: "{{ nac_tags.all }}" # Tags defined in roles/common_global/vars/main.yml
tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml
22 changes: 8 additions & 14 deletions roles/dtc/connectivity_check/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
---

- name: Verify Connection to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_connectivity.yml
tags:
- cc_connectivity_check
ansible.builtin.import_tasks: verify_ndfc_connectivity.yml
tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml

- name: Verify Authorization to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_authorization.yml
tags:
- cc_connectivity_check
ansible.builtin.import_tasks: verify_ndfc_authorization.yml
tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml

- name: Get Cisco ND Version
ansible.builtin.uri:
Expand All @@ -41,25 +39,21 @@
timeout: 30
register: nd_version_response
delegate_to: localhost
tags:
- cc_version
tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml

- name: Set Cisco ND Version Var
ansible.builtin.set_fact:
nd_version: "{{ nd_version_response.json.major }}.{{ nd_version_response.json.minor }}.{{ nd_version_response.json.maintenance }}{{ nd_version_response.json.patch }}"
tags:
- cc_version
tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml

- name: Get Cisco NDFC Version
cisco.dcnm.dcnm_rest:
method: GET
path: /appcenter/cisco/ndfc/api/about/version
register: ndfc_version
tags:
- cc_version
tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml

- name: Set Cisco NDFC Version Var
ansible.builtin.set_fact:
ndfc_version: "{{ ndfc_version.response.DATA.version }}"
tags:
- cc_version
tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
register: response
# no_log: true
delegate_to: localhost
tags:
- cc_connectivity_check

rescue:
- name: Fail Play If NDFC Authorization Test Failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@
state: started
msg: Timed out waiting to connect to NDFC at https://{{ ansible_host }}:{{ ansible_httpapi_port | default(443) }}. Check the NDFC is reachable from the Ansible Controller.
delegate_to: localhost
tags:
- cc_connectivity_check
3 changes: 1 addition & 2 deletions roles/dtc/create/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ galaxy_info:
min_ansible_version: 2.14.15

dependencies:
- cisco.nac_dc_vxlan.validate
- cisco.nac_dc_vxlan.common_global
- cisco.nac_dc_vxlan.dtc.connectivity_check
- cisco.nac_dc_vxlan.validate
- cisco.nac_dc_vxlan.dtc.common
2 changes: 1 addition & 1 deletion roles/dtc/deploy/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ galaxy_info:
min_ansible_version: 2.14.15

dependencies:
- cisco.nac_dc_vxlan.dtc.connectivity_check
- cisco.nac_dc_vxlan.validate
- cisco.nac_dc_vxlan.common_global
- cisco.nac_dc_vxlan.dtc.common
2 changes: 1 addition & 1 deletion roles/dtc/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

- name: Import Role Tasks
ansible.builtin.import_tasks: sub_main.yml
tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml
tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml
when: changes_detected_fabric or changes_detected_inventory or changes_detected_vpc_peering or changes_detected_interfaces or changes_detected_link_vpc_peering or changes_detected_vrfs or changes_detected_networks or changes_detected_policy

- name: Mark Stage Role Deploy Completed
Expand Down
2 changes: 1 addition & 1 deletion roles/dtc/remove/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ galaxy_info:
min_ansible_version: 2.14.15

dependencies:
- cisco.nac_dc_vxlan.dtc.connectivity_check
- cisco.nac_dc_vxlan.validate
- cisco.nac_dc_vxlan.common_global
- cisco.nac_dc_vxlan.dtc.common
2 changes: 1 addition & 1 deletion roles/validate/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

- name: Import Role Tasks
ansible.builtin.import_tasks: sub_main.yml
tags: "{{ nac_tags.all }}" # Tags defined in roles/common_global/vars/main.yml
tags: "{{ nac_tags.validate_role }}" # Tags defined in roles/common_global/vars/main.yml
# Problems with lower versions of python and ansible
# Python 3.9.16 and Ansible 7.3.0 (Ansible-Core 2.14.4)
# Could ignore errors and try again with tags specified as below as a work around ...
Expand Down

0 comments on commit f656c31

Please sign in to comment.