Skip to content

Commit bb220f4

Browse files
committed
Add bool() to control config-deploy and config-save, more...
Added config_deploy_for_existing_device bool() to the when: conditional for config-save and config-deploy tasks. This may not be needed, but wanted to give use control over when these REST calls are made. Also, removed items from vars_dict for config-save since this REST call does not require anything in vars_dict payload.
1 parent 5655106 commit bb220f4

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

roles/ndfc_device_merged/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Variable | Type | Description
88
----------------|-------|----------------------------------------
99
device_name | str() | The device to be merged
1010
fabric_name | str() | The fabric in which ``device_name`` resides
11+
config_deploy_for_existing_device | bool() | Default: ``true``. Determines whether to skip config-save + config-deploy if the device already exists in the topology. If set to ``false``, the config-save and config-deploy tasks will be skipped if the device already exists. If set to ``true``, the tasks will run unconditionally (i.e. regardless whether the device exists or not).
12+
1113

1214
Device and Fabric names are defined in the following file:
1315

@@ -23,9 +25,11 @@ From ``./roles/ndfc_devices_merged/defaults/main.yml``:
2325

2426
Variable | Type | Description
2527
----------------|--------|------------
26-
auth_proto | str() | the protocol to use to authenticate to each device. We assume all devices use the same protocol
27-
max_hops | int() | the number of CDP hops to traverse when discovering devices. We set this to 0 to discover one device at a time
28+
auth_proto | str() | The protocol to use to authenticate to each device. We assume all devices use the same protocol.
29+
max_hops | int() | The number of CDP hops to traverse when discovering devices. We set this to 0 to discover one device at a time.
2830
preserve_config | bool() | If true, preserve the existing config on the device(s). If false, do not preserve the configs.
31+
forceShowRun | bool() | Default: ``false`` Included in the config-deploy REST call payload.
32+
inclAllMSDSwitches | bool() | Default: ``false`` Included in the config-deploy REST call payload.
2933

3034
From ``./inventory/group_vars/ndfc``:
3135

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# ndfc_devices_create/defaults/main.yml
22
auth_proto: MD5
33
max_hops: 0
4-
preserve_config: False
4+
preserve_config: false
55
forceShowRun: false
66
inclAllMSDSwitches: false
7+
# config_deploy_for_existing_device determines whether to skip
8+
# config-save + config-deploy if the device already
9+
# exists in the topology. If set to false, the tasks will
10+
# be skipped if the device already exists. If set to true,
11+
# all tasks will run unconditionally (i.e. regardless whether
12+
# the device exists or not).
13+
config_deploy_for_existing_device: true

roles/ndfc_device_merged/tasks/worker.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
- seed_ip: "{{ item.ip }}"
88
register: result
99

10-
# serial is used below to skip device creation if the
11-
# device already exists
10+
# serial is used below to skip REST calls to config-save
11+
# and config-deploy if the device already exists
1212
- name: worker set_fact device serial number
1313
set_fact:
1414
serial: "{{ result.response | json_query(q2) }}"
@@ -26,8 +26,7 @@
2626
password: "{{ device_password }}"
2727
max_hops: "{{ max_hops }}"
2828
role: "{{ item.role }}"
29-
preserve_config: "{{ preserve_config }}"
30-
when: "serial == ''"
29+
preserve_config: "{{ preserve_config }}"
3130

3231
- name: worker REST POST config-save FABRIC {{ fabric_name }}
3332
cisco.dcnm.dcnm_rest:
@@ -36,9 +35,8 @@
3635
json_data: "{{ vars_dict | to_json }}"
3736
vars:
3837
vars_dict:
39-
forceShowRun: "{{ forceShowRun }}"
40-
inclAllMSDSwitches: "{{ inclAllMSDSwitches }}"
41-
when: "serial == ''"
38+
when: "serial == '' or config_deploy_for_existing_device == true"
39+
4240
- name: worker REST POST config-deploy FABRIC {{ fabric_name }}
4341
cisco.dcnm.dcnm_rest:
4442
method: POST
@@ -48,4 +46,4 @@
4846
vars_dict:
4947
forceShowRun: "{{ forceShowRun }}"
5048
inclAllMSDSwitches: "{{ inclAllMSDSwitches }}"
51-
when: "serial == ''"
49+
when: "serial == '' or config_deploy_for_existing_device == true"

0 commit comments

Comments
 (0)