Skip to content

Commit

Permalink
task name consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
allenrobel committed May 3, 2022
1 parent a1bfdda commit adc5300
Show file tree
Hide file tree
Showing 40 changed files with 85 additions and 93 deletions.
6 changes: 4 additions & 2 deletions roles/ndfc_config_deploy_all_rest/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# ndfc_config_deploy_all_rest/tasks/main.yml
---
- cisco.dcnm.dcnm_rest:
- name: main REST POST config-save FABRIC {{ fabric_name }}
cisco.dcnm.dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_name }}/config-save"
json_data: "{{ vars_dict | to_json }}"
vars:
vars_dict:
forceShowRun: "{{ forceShowRun }}"
inclAllMSDSwitches: "{{ inclAllMSDSwitches }}"
- cisco.dcnm.dcnm_rest:
- name: main REST POST config-deploy FABRIC {{ fabric_name }}
cisco.dcnm.dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_name }}/config-deploy"
json_data: "{{ vars_dict | to_json }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_device_deleted/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_device_deleted/tasks/main.yml
---
- name: ndfc_device_deleted
- name: main deleted FABRIC {{ fabric_name }} DEVICE {{ device_name }}
include_tasks: worker.yml
loop: "{{ r1 }}"
vars:
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_device_deleted/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# ndfc_device_deleted/tasks/worker.yml
- name: "query {{ item.ip }}"
- name: worker query FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ fabric_name }}"
state: query
config:
- seed_ip: "{{ item.ip }}"
register: result

- name: set_fact serial
- name: worker set_fact serial
set_fact:
serial: "{{ result.response | json_query(q2) }}"
vars:
q2: "[0].serialNumber"

- name: deleted {{ item.fabric }} {{ item.role }} {{ item.name }} {{ item.ip}} serial ({{ serial }})
- name: worker deleted FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip}} SERIAL ({{ serial }})
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: deleted
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_device_deleted_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_device_deleted_all/tasks/main.yml
- name: Delete all devices in fabric fabric_name
- name: main deleted FABRIC {{ fabric_name }} all devices
cisco.dcnm.dcnm_inventory:
fabric: "{{ fabric_name }}"
state: deleted
6 changes: 3 additions & 3 deletions roles/ndfc_device_list_by_fabric_rest/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# Return JSON object 'info' which will be a list of switch dictionaries
# if the GET request is successful, or an empty list if the GET request fails
---
- name: Retrieve list of devices in fabric {{ fabric_name }}
- name: main REST GET FABRIC {{ fabric_name }} switchesByFabric
cisco.dcnm.dcnm_rest:
method: GET
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_name }}/inventory/switchesByFabric"
register: result
ignore_errors: true
- name: set_fact info on success
- name: main set_fact info SUCCESS
set_fact:
info: "{{ result.response.DATA }}"
when:
result is succeeded
- name: set_fact info on failed
- name: main set_fact info FAILED
set_fact:
info: "{{ [] | to_json }}"
when:
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_device_merged/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_device_merged/tasks/main.yml
---
- name: ndfc_device_merged
- name: main merged FABRIC {{ fabric_name }} DEVICE {{ device_name }}
include_tasks: worker.yml
loop: "{{ r1 }}"
vars:
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_device_merged/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_device_merged/tasks/worker.yml
- name: "query {{ item.fabric }} {{ item.name }} {{ item.ip }}"
- name: worker query FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: query
Expand All @@ -9,13 +9,13 @@

# serial is used below to skip device creation if the
# device already exists
- name: set_fact device serial number
- name: worker set_fact device serial number
set_fact:
serial: "{{ result.response | json_query(q2) }}"
vars:
q2: "[0].serialNumber"

- name: "merged {{ fabric_name }} {{ item.name }} serial ({{ serial }})"
- name: worker merged FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip }} SERIAL ({{ serial }})
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: merged
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_device_merged_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# ndfc_device_merged_all/tasks/main.yml
---
- name: Update / Add Leafs
- name: main merged leaf FABRIC {{ fabric_name }}
include_tasks: worker.yml
loop: "{{ leafs | json_query(query) }}"
vars:
query: "[?fabric == '{{ fabric_name }}']"
- name: Update / Add Spines
- name: main merged spine FABRIC {{ fabric_name }}
include_tasks: worker.yml
loop: "{{ spines | json_query(query) }}"
vars:
query: "[?fabric == '{{ fabric_name }}']"
- name: Update / Add Border Gateways
- name: main merged border_gateway FABRIC {{ fabric_name }}
include_tasks: worker.yml
loop: "{{ border_gateways | json_query(query) }}"
vars:
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_device_merged_all/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_device_merged_all/tasks/worker.yml
- name: "query {{ item.fabric }} {{ item.name }} {{ item.ip }}"
- name: worker query FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: query
Expand All @@ -8,13 +8,13 @@
register: result

# Use serialNumber to determine if device already exists
- name: set_fact device serial number
- name: worker set_fact device serial number
set_fact:
serial: "{{ result.response | json_query(q2) }}"
vars:
q2: "[0].serialNumber"

- name: "merged {{ fabric_name }} {{ item.name }} serial ({{ serial }})"
- name: worker merged FABRIC {{ item.fabric }} NAME {{ item.name }} SERIAL {{ serial }} IP {{ item.ip }} MAX_HOPS {{ max_hops }} AUTH_PROTO {{ auth_proto }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: merged
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_device_query/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_device_query/tasks/main.yml
---
- name: "query {{ fabric_name }} {{ device_name }}"
- name: main query FABRIC {{ fabric_name }} DEVICE {{ device_name }}
include_tasks: worker.yml
loop: "{{ r1 }}"
vars:
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_device_query/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_device_query/tasks/worker.yml
- name: "{{ item.fabric }} {{ item.name }} {{ item.ip }}"
- name: worker query FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: query
Expand All @@ -8,14 +8,14 @@
register: result

# playbooks can cull information from device_info
- name: set_fact device_info
- name: worker set_fact device_info
set_fact:
device_info: "{{ result.response | json_query(q2) }}"
vars:
q2: "[0]"

# used in playbooks to skip the query if serial is not defined
- name: set_fact serial
- name: worker set_fact serial
set_fact:
serial: "{{ result.response | json_query(q3) }}"
vars:
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_device_query_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_device_query_all/tasks/main.yml
---
- name: "query {{ fabric_name }}"
- name: main query FABRIC {{ fabric_name }}
include_tasks: worker.yml
loop: "{{ r1 }}"
vars:
Expand Down
4 changes: 2 additions & 2 deletions roles/ndfc_device_query_all/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# ndfc_device_query_all/tasks/worker.yml
- name: "{{ item.fabric }} {{ item.name }} {{ item.ip }}"
- name: worker query FABRIC {{ item.fabric }} NAME {{ item.name }} IP {{ item.ip }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: query
config:
- seed_ip: "{{ item.ip }}"
register: result

- name: set_fact serial
- name: worker set_fact serial
set_fact:
serial: "{{ result.response | json_query(q2) }}"
vars:
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_device_rediscover_rest/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_device_rediscover_rest/tasks/main.yml
---
- name: "query {{ fabric_name }} {{ device_name }}"
- name: main query FABRIC {{ fabric_name }} DEVICE {{ device_name }}
include_tasks: worker.yml
loop: "{{ r1 }}"
vars:
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_device_rediscover_rest/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# ndfc_device_rediscover_rest/tasks/worker.yml
- name: "query {{ item.fabric }} {{ item.role }} {{ item.name }} {{ item.ip }}"
- name: worker query FABRIC {{ item.fabric }} ROLE {{ item.role }} NAME {{ item.name }} IP {{ item.ip }}
cisco.dcnm.dcnm_inventory:
fabric: "{{ item.fabric }}"
state: query
config:
- seed_ip: "{{ item.ip }}"
register: result

- name: "set_fact device_id - {{ item.fabric }} {{ item.role }} {{ item.name }} {{ item.ip }}"
- name: worker set_fact device_id FABRIC {{ item.fabric }} ROLE {{ item.role }} NAME {{ item.name }} IP {{ item.ip }}
set_fact:
device_id: "{{ result.response | json_query(q2) | to_json }}"
vars:
q2: "[0].switchDbID"

- name: "Rediscover Device {{ item.fabric }} {{ item.role }} {{ item.name }} {{ item.ip }} {{ device_id }}"
- name: worker REST POST rediscoverSwitch FABRIC {{ item.fabric }} ROLE {{ item.role }} NAME {{ item.name }} IP {{ item.ip }} DEVICE_ID {{ device_id }}
cisco.dcnm.dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-discovery/rediscoverSwitch"
Expand Down
8 changes: 4 additions & 4 deletions roles/ndfc_fabric_create_rest/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# ndfc_fabric_create_rest/tasks/main.yml
---
- name: Retrieve list of fabrics
- name: main REST GET fabrics
cisco.dcnm.dcnm_rest:
method: GET
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics"
register: result
- name: set_fact active_fabrics
- name: main set_fact active_fabrics
set_fact:
active_fabrics: "{{ result.response.DATA | json_query(query) | to_json }}"
vars:
query: "[*].{FabricName: fabricName}"
- name: set_fact for fabric
- name: main set_fact FABRIC {{ fabric_name }}
set_fact:
BGP_AS: "{{ fabrics | json_query(q1) }}"
ANYCAST_RP_IP_RANGE: "{{ fabrics | json_query(q2) }}"
Expand All @@ -28,7 +28,7 @@
q6: "[?name == '{{ fabric_name }}'].FABRIC_MTU | [0]"
q7: "[?name == '{{ fabric_name }}'].REPLICATION_MODE | [0]"

- name: Easy_Fabric {{ fabric_name }} BGP_AS {{ BGP_AS }} ACTIVE_FABRICS {{ active_fabrics }}
- name: main REST POST Easy_Fabric FABRIC {{ fabric_name }} BGP_AS {{ BGP_AS }} ACTIVE_FABRICS {{ active_fabrics }}
cisco.dcnm.dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_name }}/Easy_Fabric"
Expand Down
8 changes: 4 additions & 4 deletions roles/ndfc_fabric_delete_rest/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# ndfc_fabric_delete_rest/tasks/main.yml
---
- name: Retrieve list of fabrics
- name: main REST GET fabrics
cisco.dcnm.dcnm_rest:
method: GET
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics"
register: result
- name: set_fact active_fabrics
- name: main set_fact active_fabrics
set_fact:
active_fabrics: "{{ result.response.DATA | json_query(query) | to_json }}"
vars:
query: "[*].{FabricName: fabricName}"
- name: set_fact asn
- name: main set_fact asn
set_fact:
asn: "{{ fabrics | json_query(query) }}"
vars:
query: "[?name == '{{ fabric_name }}'].asn | [0]"

- name: Fabric DELETE {{ fabric_name }} from ACTIVE_FABRICS {{ active_fabrics }}
- name: main REST DELETE FABRIC {{ fabric_name }} from ACTIVE_FABRICS {{ active_fabrics }}
cisco.dcnm.dcnm_rest:
method: DELETE
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_name }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_network_deleted_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_network_deleted_all/tasks/main.yml
---
- name: delete all networks in fabric {{ fabric_name }}
- name: main deleted FABRIC {{ fabric_name }} networks
include_tasks: worker.yml
loop: "{{ networks | json_query(q1) }}"
vars:
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_network_deleted_all/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_network_deleted_all/tasks/worker.yml
- name: "deleted FABRIC {{ fabric_name }} NETWORK {{ item.net_name }} VRF {{ item.vrf_name }} VLAN {{ item.vlan_id }} SUBNET {{ item.gw_ip_subnet }}"
- name: worker deleted FABRIC {{ fabric_name }} NETWORK {{ item.net_name }} VRF {{ item.vrf_name }} VLAN {{ item.vlan_id }} SUBNET {{ item.gw_ip_subnet }}
cisco.dcnm.dcnm_network:
fabric: "{{ fabric_name }}"
state: deleted
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_network_replaced_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndfc_network_replaced_all/tasks/main.yml
---
- name: Update Network (replaced)
- name: main replaced Network FABRIC {{ fabric_name }}
include_tasks: worker.yml
loop: "{{ networks | json_query(q1) }}"
vars:
Expand Down
2 changes: 1 addition & 1 deletion roles/ndfc_network_replaced_all/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_network_replaced_all/tasks/worker.yml
- name: "{{ state }} FABRIC {{ fabric_name }} NETWORK {{ item.net_name }} VRF {{ item.vrf_name }} VLAN {{ item.vlan_id }} SUBNET {{ item.gw_ip_subnet }}"
- name: worker replaced FABRIC {{ fabric_name }} NETWORK {{ item.net_name }} VRF {{ item.vrf_name }} VLAN {{ item.vlan_id }} SUBNET {{ item.gw_ip_subnet }}"
cisco.dcnm.dcnm_network:
fabric: "{{ fabric_name }}"
state: replaced
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_policy_query_generated_config_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# ndfc_policy_query_generated_config_all/main.yml
---
- name: Query Leaf Generated Configs
- name: main query FABRIC {{ fabric_name }} Generated Configs leaf
include_tasks: worker.yml
loop: "{{ leafs | json_query(q1) }}"
vars:
q1: "[?fabric == '{{ fabric_name }}']"
- name: Query Spine Generated Configs
- name: main query FABRIC {{ fabric_name }} Generated Configs spine
include_tasks: worker.yml
loop: "{{ spines | json_query(q1) }}"
vars:
q1: "[?fabric == '{{ fabric_name }}']"
- name: Query Border Gateway Generated Configs
- name: main query FABRIC {{ fabric_name }} Generated Configs border_gateway
include_tasks: worker.yml
loop: "{{ border_gateways | json_query(q1) }}"
vars:
Expand Down
4 changes: 2 additions & 2 deletions roles/ndfc_policy_query_generated_config_all/tasks/worker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ndfc_policy_query_generated_config_all/worker.yml
- name: "dcnm_policy query generated_config {{ item.name }} {{ item.ip }}"
- name: worker query FABRIC {{ fabric_name }} DEVICE {{ item.name }} IP {{ item.ip }} generated_config
cisco.dcnm.dcnm_policy:
fabric: "{{ fabric_name }}"
state: query
Expand All @@ -8,7 +8,7 @@
- ip: "{{ item.ip }}"
register: result

- name: set_fact {{ item.name }} {{ item.ip }}
- name: worker set_fact DEVICE {{ item.name }} IP {{ item.ip }}
set_fact:
generated_configs: "{{ result.response | json_query(q2) }}"
vars:
Expand Down
6 changes: 3 additions & 3 deletions roles/ndfc_policy_query_interface_all/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# ndfc_policy_query_interface/tasks/main.yml
---
- name: Query Leaf Interface Policies
- name: main query FABRIC {{ fabric_name }} Interface Policies leaf
include_tasks: worker.yml
loop: "{{ leafs | json_query(qm1) }}"
vars:
qm1: "[?fabric == '{{ fabric_name }}']"

- name: Query Spine Interface Policies
- name: main query FABRIC {{ fabric_name }} Interface Policies spine
include_tasks: worker.yml
loop: "{{ spines | json_query(qm2) }}"
vars:
qm2: "[?fabric == '{{ fabric_name }}']"

- name: Query Border Gateway Interface Policies
- name: main query FABRIC {{ fabric_name }} Interface Policies border_gateway
include_tasks: worker.yml
loop: "{{ border_gateways | json_query(qm3) }}"
vars:
Expand Down
Loading

0 comments on commit adc5300

Please sign in to comment.