Skip to content

Commit

Permalink
Prepend fabric name (#189)
Browse files Browse the repository at this point in the history
* prepend fabric name

* rearrange run_map tasks

* update run_map action plugins & reorder valdiate tasks
  • Loading branch information
mtarking authored Sep 18, 2024
1 parent 3c0c85f commit bb6d543
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ roles/dtc/deploy/files
roles/dtc/remove/files
roles/validate/files/schema.yaml
roles/validate/files/run_map.yml
roles/validate/files/*_run_map.yml
!roles/validate/files/rules/enhanced_rules
!roles/validate/files/rules/enhanced_rules/.gitkeep
!roles/validate/files/rules/required_rules/*
Expand Down
5 changes: 4 additions & 1 deletion plugins/action/common/read_run_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ def run(self, tmp=None, task_vars=None):
results = super(ActionModule, self).run(tmp, task_vars)
results['diff_run'] = True

model_data = task_vars['model_data']['data']
fabric_name = model_data["vxlan"]["global"]["name"]

if 'dtc' in task_vars['role_path']:
common_role_path = os.path.dirname(task_vars['role_path'])
common_role_path = os.path.dirname(common_role_path) + '/validate/files'
else:
common_role_path = os.path.dirname(task_vars['role_path']) + '/validate/files'

run_map_file_path = common_role_path + '/run_map.yml'
run_map_file_path = common_role_path + f'/{fabric_name}_run_map.yml'

if not os.path.exists(run_map_file_path):
# Return failure if run_map file does not exist
Expand Down
5 changes: 4 additions & 1 deletion plugins/action/common/run_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def run(self, tmp=None, task_vars=None):
results = super(ActionModule, self).run(tmp, task_vars)
results['failed'] = False

model_data = task_vars['model_data']['data']
stage = self._task.args['stage']
fabric_name = model_data["vxlan"]["global"]["name"]

if 'dtc' in task_vars['role_path']:
common_role_path = os.path.dirname(task_vars['role_path'])
Expand All @@ -52,7 +54,8 @@ def run(self, tmp=None, task_vars=None):
if not os.path.exists(common_role_path):
# Return failure if the common role path does not exist
results['failed'] = True
run_map_file_path = common_role_path + '/run_map.yml'

run_map_file_path = common_role_path + f'/{fabric_name}_run_map.yml'

if stage == 'starting_execution':
updated_run_map = {}
Expand Down
46 changes: 24 additions & 22 deletions roles/validate/tasks/sub_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@

- ansible.builtin.debug: msg="Inventory Directory - {{ inventory_dir }}"

- name: Read Run Map From Previous Run
cisco.nac_dc_vxlan.common.read_run_map:
register: run_map_read_result
delegate_to: localhost

- name: Debug Run Map Read Result
ansible.builtin.debug:
msg: "{{ run_map_read_result }}"
delegate_to: localhost

- name: Initialize Run Map
cisco.nac_dc_vxlan.common.run_map:
stage: starting_execution
register: run_map
delegate_to: localhost

- name: Validate NDFC Service Model Data
ansible.builtin.debug: msg="Calling Role Validate - nac_dc_vxlan.validate"

Expand All @@ -56,6 +40,12 @@
- ansible.builtin.debug: msg="Workflow is Direct to Controller (DTC)"
when: hostvars[inventory_hostname]['ansible_network_os'] == "cisco.dcnm.dcnm"

- name: Verify Connection to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_connectivity.yml

- name: Verify Authorization to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_authorization.yml

- name: Check for Schema Path Being Defined
ansible.builtin.set_fact:
schema_path: ''
Expand Down Expand Up @@ -89,12 +79,6 @@
when: enhanced_rules_path is defined and enhanced_rules_path
delegate_to: localhost

- name: Verify Connection to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_connectivity.yml

- name: Verify Authorization to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_authorization.yml

- name: Prepare Service Model
cisco.nac_dc_vxlan.common.prepare_service_model:
inventory_hostname: "{{ inventory_hostname }}"
Expand All @@ -119,6 +103,24 @@
register: check_roles
delegate_to: localhost

- name: Read Run Map From Previous Run
cisco.nac_dc_vxlan.common.read_run_map:
model_data: "{{ MD_Extended }}"
register: run_map_read_result
delegate_to: localhost

- name: Debug Run Map Read Result
ansible.builtin.debug:
msg: "{{ run_map_read_result }}"
delegate_to: localhost

- name: Initialize Run Map
cisco.nac_dc_vxlan.common.run_map:
model_data: "{{ MD_Extended }}"
stage: starting_execution
register: run_map
delegate_to: localhost

- name: Manage Previous Service Model Data Files
ansible.builtin.include_tasks: manage_model_files_previous.yml
when: check_roles['save_previous']
Expand Down

0 comments on commit bb6d543

Please sign in to comment.