From 38b7c80217c4e72b1d8988eb1e60bb6e77334114 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 18 Apr 2024 07:52:22 +0200 Subject: Adding upstream version 9.4.0+dfsg. Signed-off-by: Daniel Baumann --- ansible_collections/cisco/dnac/playbooks/PnP.yml | 111 ++++++++++++ .../playbooks/PnP_Workflow_Manager_Playbook.yml | 111 ++++++++++++ .../cisco/dnac/playbooks/credentials.template | 5 +- .../cisco/dnac/playbooks/credentials.yml | 10 +- .../dnac/playbooks/device_credential_intent.yml | 119 +++++++++++++ .../device_credential_workflow_manager.yml | 103 +++++++++++ .../cisco/dnac/playbooks/device_details.template | 69 ++++++++ .../cisco/dnac/playbooks/device_details.yml | 54 ------ .../cisco/dnac/playbooks/device_provision.yml | 37 ++++ .../dnac/playbooks/device_provision_workflow.yml | 38 ++++ .../cisco/dnac/playbooks/discovery.yml | 14 +- .../cisco/dnac/playbooks/discovery_intent.yml | 197 +++++++++++++++++++++ .../dnac/playbooks/discovery_workflow_manager.yml | 197 +++++++++++++++++++++ .../cisco/dnac/playbooks/global_credentials.yml | 6 +- .../cisco/dnac/playbooks/inventory_device.yml | 53 ++++++ .../dnac/playbooks/inventory_workflow_manager.yml | 67 +++++++ .../dnac/playbooks/network_settings_intent.yml | 112 ++++++++++++ .../network_settings_workflow_manager.yml | 108 +++++++++++ .../cisco/dnac/playbooks/site_intent.yml | 32 ++++ .../cisco/dnac/playbooks/site_workflow_manager.yml | 39 ++++ .../cisco/dnac/playbooks/swim_import_local.yml | 22 +++ .../cisco/dnac/playbooks/swim_intent.yml | 43 +++++ .../cisco/dnac/playbooks/swim_workflow_manager.yml | 54 ++++++ .../cisco/dnac/playbooks/template_pnp_intent.yml | 37 ++-- .../dnac/playbooks/template_workflow_manager.yml | 34 ++++ .../cisco/dnac/playbooks/test_swim_module.yml | 51 +++--- .../dnac/playbooks/tests/test-1592357065255.csv | 3 + .../cisco/dnac/playbooks/user_info.yml | 18 ++ 28 files changed, 1631 insertions(+), 113 deletions(-) create mode 100644 ansible_collections/cisco/dnac/playbooks/PnP.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/PnP_Workflow_Manager_Playbook.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/device_credential_intent.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/device_credential_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/device_details.template delete mode 100644 ansible_collections/cisco/dnac/playbooks/device_details.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/device_provision.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/device_provision_workflow.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/discovery_intent.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/discovery_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/inventory_device.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/inventory_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/network_settings_intent.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/network_settings_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/site_intent.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/site_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/swim_import_local.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/swim_intent.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/swim_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/template_workflow_manager.yml create mode 100644 ansible_collections/cisco/dnac/playbooks/tests/test-1592357065255.csv create mode 100644 ansible_collections/cisco/dnac/playbooks/user_info.yml (limited to 'ansible_collections/cisco/dnac/playbooks') diff --git a/ansible_collections/cisco/dnac/playbooks/PnP.yml b/ansible_collections/cisco/dnac/playbooks/PnP.yml new file mode 100644 index 000000000..63bad68e0 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/PnP.yml @@ -0,0 +1,111 @@ +--- +- name: Manage operations - Add, claim, and delete devices of Onboarding Configuration (PnP) + hosts: localhost + connection: local + gather_facts: no + + vars_files: + - "{{ CLUSTERFILE }}" + + vars: + dnac_login: &dnac_login + dnac_host: "{{ dnac_host }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_port: "{{ dnac_port }}" + dnac_version: "{{ dnac_version }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log_level: DEBUG + + tasks: + + - name: Import devices in bulk + cisco.dnac.pnp_intent: + <<: *dnac_login + dnac_log: True + state: merged + config_verify: True + config: + - device_info: + - serial_number: QD2425L8M7 + state: Unclaimed + pid: c9300-24P + is_sudi_required: False + + - serial_number: QTC2320E0H9 + state: Unclaimed + pid: c9300-24P + hostname: Test-123 + + - serial_number: ETC2320E0HB + state: Unclaimed + pid: c9300-24P + + - name: Add a new device and claim it + cisco.dnac.pnp_intent: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + device_info: + - serial_number: FJC2330E0BB + hostname: Test-9300-10 + state: Unclaimed + pid: c9300-24P + is_sudi_required: True + + - name: Claim a pre-added switch, apply a template, and perform an image upgrade for a specific site + cisco.dnac.pnp_intent: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + template_name: "Ansible_PNP_Switch" + image_name: cat9k_iosxe_npe.17.03.07.SPA.bin + project_name: Onboarding Configuration + template_details: + hostname: SJC-Switch-1 + interface: TwoGigabitEthernet1/0/2 + device_info: + - serial_number: FJC271924EQ + hostname: Switch + state: Unclaimed + pid: C9300-48UXM + + - name: Claim an existing Wireless Controller, apply a template, and upgrade its image for a specified site + cisco.dnac.pnp_intent: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + pnp_type: CatalystWLC + template_name: "Ansible_PNP_WLC" + image_name: C9800-40-universalk9_wlc.17.12.01.SPA.bin + template_params: + hostname: IAC-EWLC-Claimed + device_info: + - serial_number: FOX2639PAY7 + hostname: New_WLC + state: Unclaimed + pid: C9800-CL-K9 + gateway: 204.192.101.1 + ip_interface_name: TenGigabitEthernet0/0/0 + static_ip: 204.192.101.10 + subnet_mask: 255.255.255.0 + vlan_id: 1101 + + - name: Remove multiple devices from the PnP dashboard safely (ignores non-existent devices) + cisco.dnac.pnp_intent: + <<: *dnac_login + dnac_log: True + state: deleted + config_verify: True + config: + - device_info: + - serial_number: QD2425L8M7 #Will get deleted + - serial_number: FTC2320E0HA #Doesn't exist in the inventory + - serial_number: FKC2310E0HB #Doesn't exist in the inventory \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/PnP_Workflow_Manager_Playbook.yml b/ansible_collections/cisco/dnac/playbooks/PnP_Workflow_Manager_Playbook.yml new file mode 100644 index 000000000..846ebf3a7 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/PnP_Workflow_Manager_Playbook.yml @@ -0,0 +1,111 @@ +--- +- name: Manage operations - Add, claim, and delete devices of Onboarding Configuration (PnP) + hosts: localhost + connection: local + gather_facts: no + + vars_files: + - "{{ CLUSTERFILE }}" + + vars: + dnac_login: &dnac_login + dnac_host: "{{ dnac_host }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_port: "{{ dnac_port }}" + dnac_version: "{{ dnac_version }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log_level: DEBUG + + tasks: + + - name: Import devices in bulk + cisco.dnac.pnp_workflow_manager: + <<: *dnac_login + dnac_log: True + state: merged + config_verify: True + config: + - device_info: + - serial_number: QD2425L8M7 + state: Unclaimed + pid: c9300-24P + is_sudi_required: False + + - serial_number: QTC2320E0H9 + state: Unclaimed + pid: c9300-24P + hostname: Test-123 + + - serial_number: ETC2320E0HB + state: Unclaimed + pid: c9300-24P + + - name: Add a new device and claim it + cisco.dnac.pnp_workflow_manager: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + device_info: + - serial_number: FJC2330E0BB + hostname: Test-9300-10 + state: Unclaimed + pid: c9300-24P + is_sudi_required: True + + - name: Claim a pre-added switch, apply a template, and perform an image upgrade for a specific site + cisco.dnac.pnp_workflow_manager: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + template_name: "Ansible_PNP_Switch" + image_name: cat9k_iosxe_npe.17.03.07.SPA.bin + project_name: Onboarding Configuration + template_details: + hostname: SJC-Switch-1 + interface: TwoGigabitEthernet1/0/2 + device_info: + - serial_number: FJC271924EQ + hostname: Switch + state: Unclaimed + pid: C9300-48UXM + + - name: Claim an existing Wireless Controller, apply a template, and upgrade its image for a specified site + cisco.dnac.pnp_workflow_manager: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + pnp_type: CatalystWLC + template_name: "Ansible_PNP_WLC" + image_name: C9800-40-universalk9_wlc.17.12.01.SPA.bin + template_params: + hostname: IAC-EWLC-Claimed + device_info: + - serial_number: FOX2639PAY7 + hostname: New_WLC + state: Unclaimed + pid: C9800-CL-K9 + gateway: 204.192.101.1 + ip_interface_name: TenGigabitEthernet0/0/0 + static_ip: 204.192.101.10 + subnet_mask: 255.255.255.0 + vlan_id: 1101 + + - name: Remove multiple devices from the PnP dashboard safely (ignores non-existent devices) + cisco.dnac.pnp_workflow_manager: + <<: *dnac_login + dnac_log: True + state: deleted + config_verify: True + config: + - device_info: + - serial_number: QD2425L8M7 #Will get deleted + - serial_number: FTC2320E0HA #Doesn't exist in the inventory + - serial_number: FKC2310E0HB #Doesn't exist in the inventory diff --git a/ansible_collections/cisco/dnac/playbooks/credentials.template b/ansible_collections/cisco/dnac/playbooks/credentials.template index e621bdaa5..5270c0816 100644 --- a/ansible_collections/cisco/dnac/playbooks/credentials.template +++ b/ansible_collections/cisco/dnac/playbooks/credentials.template @@ -5,4 +5,7 @@ dnac_username: dnac_password: dnac_version: 2.3.5.3 dnac_verify: False -dnac_debug: False \ No newline at end of file +dnac_debug: False +dnac_log_level: [CRITICAL, ERROR, WARNING, INFO, DEBUG] +dnac_log_file_path: +dnac_log_append: True diff --git a/ansible_collections/cisco/dnac/playbooks/credentials.yml b/ansible_collections/cisco/dnac/playbooks/credentials.yml index 5413d0e8f..133e03cb9 100644 --- a/ansible_collections/cisco/dnac/playbooks/credentials.yml +++ b/ansible_collections/cisco/dnac/playbooks/credentials.yml @@ -1,8 +1,8 @@ --- -dnac_host: 192.168.196.2 +dnac_host: 100.119.103.190 dnac_port: 443 -dnac_username: admin -dnac_password: Maglev123 -dnac_version: 2.2.2.3 +dnac_username: cloverhound_user +dnac_password: LABchsys!23$ +dnac_version: 2.3.5.3 dnac_verify: False -dnac_debug: True +dnac_debug: True \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/device_credential_intent.yml b/ansible_collections/cisco/dnac/playbooks/device_credential_intent.yml new file mode 100644 index 000000000..bd5834ffe --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/device_credential_intent.yml @@ -0,0 +1,119 @@ +- hosts: dnac_servers + vars_files: + - credentials.yml + gather_facts: no + connection: local + tasks: +# +# Project Info Section +# + + - name: Create Credentials and assign it to a site. + cisco.dnac.device_credential_intent: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + state: merged + config: + - global_credential_details: + cli_credential: + - description: CLI1 + username: cli1 + password: '12345' + enable_password: '12345' + # old_description: + # old_username: + # id: e448ea13-4de0-406b-bc6e-f72b57ed6746 # Use this for updation or deletion + snmp_v2c_read: + - description: SNMPv2c Read1 # use this for deletion + read_community: '123456' + # old_description: # use this for updating the description + # id: 0ee7d677-8804-43f2-8b6c-599c5f18348f # Use this for updation or deletion + snmp_v2c_write: + - description: SNMPv2c Write1 # use this for deletion + write_community: '123456' + # old_description: # use this for updating the description + # id: a96abc1b-1fd6-41f1-8a6d-a5569c17262d # Use this for updation or deletion + snmp_v3: + - auth_password: '12345678' # Atleast 8 characters + auth_type: SHA # [SHA, MD5] (SHA is recommended) + snmp_mode: AUTHPRIV # [AUTHPRIV, AUTHNOPRIV, NOAUTHNOPRIV] + privacy_password: '12345678' # Atleast 8 characters + privacy_type: AES128 # [AE128, AE192, AE256] + username: snmpV31 + description: snmpV31 + # old_description: + # id: d8974823-250a-41b0-8c9b-b27b2ae01472 # Use this for updation or deletion + https_read: + - description: HTTP Read1 + username: HTTP_Read1 + password: '12345' + port: 443 + # old_description: + # old_username: + # id: a7ef9995-e404-4240-94ca-b5f37f65c19d # Use this for updation or deletion + https_write: + - description: HTTP Write1 + username: HTTP_Write1 + password: '12345' + port: 443 + # old_description: + # old_username: + # id: bec9818e-30cd-468b-bf75-292beefc2e20 # Use this for updation or deletion + assign_credentials_to_site: + cli_credential: + # description: CLI + # username: cli + id: 2fc5f7d4-cf15-4a4f-99b3-f086e8dd6350 + snmp_v2c_read: + # description: SNMPv2c Read + id: a966a4e5-9d11-4683-8edc-a5ad8fa59ee3 + snmp_v2c_write: + # description: SNMPv2c Write + id: 7cd072a4-2263-4087-b6ec-93b20958e286 + snmp_v3: + # description: snmpV3 + id: c08a1797-84ce-4add-94a3-b419b13621e4 + https_read: + # description: HTTP Read + # username: HTTP_Read + id: 1009725d-373b-4e7c-a091-300777e2bbe2 + https_write: + # description: HTTP Write + # username: HTTP_Write + id: f1ab6e3d-01e9-4d87-8271-3ac5fde83980 + site_name: + - Global/Chennai/Trill + - Global/Chennai/Tidel + + - name: Delete Credentials + cisco.dnac.device_credential_intent: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + state: deleted + config: + - global_credential_details: + cli_credential: + - description: CLI1 + username: cli1 + snmp_v2c_read: + - description: SNMPv2c Read1 # use this for deletion + snmp_v2c_write: + - description: SNMPv2c Write1 # use this for deletion + snmp_v3: + - description: snmpV31 + https_read: + - description: HTTP Read1 + username: HTTP_Read1 + https_write: + - description: HTTP Write1 + username: HTTP_Write1 diff --git a/ansible_collections/cisco/dnac/playbooks/device_credential_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/device_credential_workflow_manager.yml new file mode 100644 index 000000000..3d77584f0 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/device_credential_workflow_manager.yml @@ -0,0 +1,103 @@ +- hosts: dnac_servers + vars_files: + - credentials.yml + gather_facts: no + connection: local + tasks: + - name: Create Credentials and assign it to a site. + cisco.dnac.device_credential_workflow_manager: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + state: merged + config: + - global_credential_details: + cli_credential: + - description: CLI1 + username: cli1 + password: '12345' + enable_password: '12345' + # old_description: + # old_username: + snmp_v2c_read: + - description: SNMPv2c Read1 # use this for deletion + read_community: '123456' + # old_description: # use this for updating the description + snmp_v2c_write: + - description: SNMPv2c Write1 # use this for deletion + write_community: '123456' + # old_description: # use this for updating the description + snmp_v3: + - auth_password: '12345678' # Atleast 8 characters + auth_type: SHA # [SHA, MD5] (SHA is recommended) + snmp_mode: AUTHPRIV # [AUTHPRIV, AUTHNOPRIV, NOAUTHNOPRIV] + privacy_password: '12345678' # Atleast 8 characters + privacy_type: AES128 # [AE128, AE192, AE256] + username: snmpV31 + description: snmpV31 + # old_description: + https_read: + - description: HTTP Read1 + username: HTTP_Read1 + password: '12345' + port: 443 + # old_description: + # old_username: + https_write: + - description: HTTP Write1 + username: HTTP_Write1 + password: '12345' + port: 443 + # old_description: + # old_username: + assign_credentials_to_site: + cli_credential: + description: CLI + username: cli + snmp_v2c_read: + description: SNMPv2c Read + snmp_v2c_write: + description: SNMPv2c Write + snmp_v3: + description: snmpV3 + https_read: + description: HTTP Read + username: HTTP_Read + https_write: + description: HTTP Write + username: HTTP_Write + site_name: + - Global/Chennai/Trill + - Global/Chennai/Tidel + + - name: Delete Credentials + cisco.dnac.device_credential_workflow_manager: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + state: deleted + config: + - global_credential_details: + cli_credential: + - description: CLI1 + username: cli1 + snmp_v2c_read: + - description: SNMPv2c Read1 # use this for deletion + snmp_v2c_write: + - description: SNMPv2c Write1 # use this for deletion + snmp_v3: + - description: snmpV31 + https_read: + - description: HTTP Read1 + username: HTTP_Read1 + https_write: + - description: HTTP Write1 + username: HTTP_Write1 diff --git a/ansible_collections/cisco/dnac/playbooks/device_details.template b/ansible_collections/cisco/dnac/playbooks/device_details.template new file mode 100644 index 000000000..38c95c627 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/device_details.template @@ -0,0 +1,69 @@ +template_details: + - proj_name: 'Onboarding Configuration' + device_config: 'hostname cat9k-1\n' + language: 'velocity' + family: 'Switches and Hubs' + type: 'IOS-XE' + variant: 'XE' + temp_name: 'temp_cat9k-1' + description: 'Test Template' + export_project: + - 'Cloud DayN Templates' + export_template: + - project_name: 'Cloud DayN Templates' + template_name: 'DMVPN Spoke for Branch Router - System Default' + import_project: + do_version: false + payload: + - name: 'Onboarding Configuration2' + import_template: + do_version: false + project_name: 'Onboarding Configuration' + payload: + - name: 'Platinum-Onboarding-Template-J21' + device_types: + - product_family: 'Switches and Hubs' + productSeries: 'Cisco Catalyst 9300 Series Switches' + software_type: 'IOS' + language: 'JINJA' + - name: 'Platinum-Onboarding-Template-J22' + device_types: + - product_family: 'Switches and Hubs' + productSeries: 'Cisco Catalyst 9300 Series Switches' + software_type: 'IOS' + language: 'JINJA' + - name: 'Platinum-Onboarding-Template-J23' + device_types: + - product_family: 'Switches and Hubs' + productSeries: 'Cisco Catalyst 9300 Series Switches' + software_type: 'IOS' + language: 'JINJA' + +device_details: + - site_name: 'Global/Chennai/Trill' + image_name: 'cat9k_iosxe.17.04.01.SPA.bin' + proj_name: 'Onboarding Configuration' + temp_name: 'temp_cat9k-1' + device_version: '2' + device_number: 'AB2425L8M7' + device_name: 'Cat9k-1' + device_state: 'Unclaimed' + device_id: 'C9300-48UXM' + - site_name: 'Global/Chennai/Trill' + image_name: cat9k_iosxe.17.04.01.SPA.bin' + proj_name: 'Onboarding Configuration' + temp_name: 'temp_cat9k-2' + device_version: '2' + device_number: 'CD2425L8M7' + device_name: 'Cat9k-2' + device_state: 'Unclaimed' + device_id: 'C9300-48UXM' + - site_name: 'Global/Chennai/Trill' + image_name: 'cat9k_iosxe.17.04.01.SPA.bin' + proj_name: 'Onboarding Configuration' + temp_name: 'temp_cat9k-3' + device_version: '2' + device_number: 'EF2425L8M7' + device_name: 'Cat9k-3' + device_state: 'Unclaimed' + device_id: 'C9300-48UXM' diff --git a/ansible_collections/cisco/dnac/playbooks/device_details.yml b/ansible_collections/cisco/dnac/playbooks/device_details.yml deleted file mode 100644 index 0c9dfdfef..000000000 --- a/ansible_collections/cisco/dnac/playbooks/device_details.yml +++ /dev/null @@ -1,54 +0,0 @@ -template_details: - - proj_name: "Onboarding Configuration" - device_config: "hostname cat9k-1\n" - language: "velocity" - family: "Switches and Hubs" - type: "IOS-XE" - variant: "XE" - temp_name: "temp_cat9k-1" - description: "Test Template 1" - - proj_name: "Onboarding Configuration" - device_config: "hostname cat9k-2\n" - language: "velocity" - family: "Switches and Hubs" - type: "IOS-XE" - variant: "XE" - temp_name: "temp_cat9k-2" - description: "Test Template 2" - - proj_name: "Onboarding Configuration" - device_config: "hostname cat9k-3\n" - language: "velocity" - family: "Switches and Hubs" - type: "IOS-XE" - variant: "XE" - temp_name: "temp_cat9k-3" - description: "Test Template 3" - -device_details: - - site_name: "Global/Chennai/Trill" - image_name: "cat9k_iosxe.17.04.01.SPA.bin" - proj_name: "Onboarding Configuration" - temp_name: "temp_cat9k-1" - device_version: "2" - device_number: "AB2425L8M7" - device_name: "Cat9k-1" - device_state: "Unclaimed" - device_id: "C9300-25UX" - - site_name: "Global/Chennai/Trill" - image_name: "cat9k_iosxe.17.04.01.SPA.bin" - proj_name: "Onboarding Configuration" - temp_name: "temp_cat9k-2" - device_version: "2" - device_number: "CD2425L8M7" - device_name: "Cat9k-2" - device_state: "Unclaimed" - device_id: "C9300-25UX" - - site_name: "Global/Chennai/Trill" - image_name: "cat9k_iosxe.17.04.01.SPA.bin" - proj_name: "Onboarding Configuration" - temp_name: "temp_cat9k-3" - device_version: "2" - device_number: "EF2425L8M7" - device_name: "Cat9k-3" - device_state: "Unclaimed" - device_id: "C9300-25UX" diff --git a/ansible_collections/cisco/dnac/playbooks/device_provision.yml b/ansible_collections/cisco/dnac/playbooks/device_provision.yml new file mode 100644 index 000000000..fe3efe919 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/device_provision.yml @@ -0,0 +1,37 @@ +--- +- name: Provision and Re-provision wired and wireless devices + hosts: localhost + connection: local + gather_facts: no + + vars_files: + - "{{ CLUSTERFILE }}" + + vars: + dnac_login: &dnac_login + dnac_host: "{{ dnac_host }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_port: "{{ dnac_port }}" + dnac_version: "{{ dnac_version }}" + dnac_debug: "{{ dnac_debug }}" + + tasks: + - name: Provision a wired device to a site + cisco.dnac.provision_intent: + <<: *dnac_login + dnac_log: True + state: merged + config: + - site_name: Global/USA/San Francisco/BGL_18 + management_ip_address: 204.1.2.2 + + + - name: Unprovision a wired device to a site + cisco.dnac.provision_intent: + <<: *dnac_login + dnac_log: True + state: deleted + config: + - management_ip_address: 204.1.2.2 diff --git a/ansible_collections/cisco/dnac/playbooks/device_provision_workflow.yml b/ansible_collections/cisco/dnac/playbooks/device_provision_workflow.yml new file mode 100644 index 000000000..362556a09 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/device_provision_workflow.yml @@ -0,0 +1,38 @@ +--- +- name: Provision and Re-provision wired and wireless devices + hosts: localhost + connection: local + gather_facts: no + + vars_files: + - "{{ CLUSTERFILE }}" + + vars: + dnac_login: &dnac_login + dnac_host: "{{ dnac_host }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_port: "{{ dnac_port }}" + dnac_version: "{{ dnac_version }}" + dnac_debug: "{{ dnac_debug }}" + + tasks: + - name: Provision a wired device to a site + cisco.dnac.workflow_manager: + <<: *dnac_login + dnac_log: True + state: merged + config_verify: True + config: + - site_name_hierarchy: Global/USA/San Francisco/BGL_18 + management_ip_address: 204.1.1.1 + + + - name: Unprovision a wired device from a site + cisco.dnac.workflow_manager: + <<: *dnac_login + dnac_log: True + state: deleted + config: + - management_ip_address: 204.1.1.1 diff --git a/ansible_collections/cisco/dnac/playbooks/discovery.yml b/ansible_collections/cisco/dnac/playbooks/discovery.yml index d05d201a3..ce9a38770 100644 --- a/ansible_collections/cisco/dnac/playbooks/discovery.yml +++ b/ansible_collections/cisco/dnac/playbooks/discovery.yml @@ -1,5 +1,9 @@ --- - hosts: dnac_servers + vars: + globalCredentialIdList: + - "90acbab8-03d5-4726-9c19-e1e51a40b3cd" + - "f979d842-f6fd-456a-8137-2cb5113cd2e8" vars_files: - credentials.yml gather_facts: false @@ -17,7 +21,7 @@ - name: Set fact of filtered discoveries ansible.builtin.set_fact: - discoveries_filtered: "{{ discovery_range_result.dnac_response.response | selectattr('name', 'equalto', 'start_discovery_test2')}}" + discoveries_filtered: "{{ discovery_range_result.dnac_response.response | selectattr('name', 'equalto', 'DMZ Lab 2')}}" when: - discovery_range_result is defined - discovery_range_result.dnac_response is defined @@ -54,9 +58,7 @@ state: present cdpLevel: 16 discoveryType: CDP - globalCredentialIdList: - - 90acbab8-03d5-4726-9c19-e1e51a40b3cd - - f979d842-f6fd-456a-8137-2cb5113cd2e8 + globalCredentialIdList: "{{globalCredentialIdList}}" ipAddressList: 10.10.22.22 name: start_discovery_test2 protocolOrder: ssh @@ -93,9 +95,7 @@ state: present cdpLevel: 16 discoveryType: CDP - globalCredentialIdList: - - 90acbab8-03d5-4726-9c19-e1e51a40b3cd, - - f979d842-f6fd-456a-8137-2cb5113cd2e8, + globalCredentialIdList: "{{globalCredentialIdList}}" ipAddressList: 10.10.22.22 name: start_discovery_test2 protocolOrder: ssh diff --git a/ansible_collections/cisco/dnac/playbooks/discovery_intent.yml b/ansible_collections/cisco/dnac/playbooks/discovery_intent.yml new file mode 100644 index 000000000..9f004802f --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/discovery_intent.yml @@ -0,0 +1,197 @@ +--- +- name: Discover devices using multiple discovery specific credentials and delete all the discoveries + hosts: localhost + connection: local + gather_facts: no + + vars_files: + - "{{ CLUSTERFILE }}" + + vars: + dnac_login: &dnac_login + dnac_host: "{{ dnac_host }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_port: "{{ dnac_port }}" + dnac_version: "{{ dnac_version }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + dnac_log_level: DEBUG + + tasks: + + - name: Execute discovery devices using MULTI RANGE with various global credentials + cisco.dnac.discovery_intent: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: Multi_global + discovery_type: MULTI RANGE + ip_address_list: + - 204.1.2.1-204.1.2.5 + - 204.192.3.40 + - 204.192.4.200 + - 204.1.2.6 + - 204.1.2.7 + - 204.1.2.8 + - 204.1.2.9 + - 204.1.2.10 + - 204.1.2.11 + global_credentials: + cli_credentials_list: + - description: ISE + username: cisco + - description: CLI1234 #Incorrect name passed + username: cli + http_read_credential_list: + - description: HTTP Read + username: HTTP_Read + snmp_v3_credential_list: + - description: snmpV3 + username: snmpV3 + protocol_order: ssh + + - name: Execute discovery of single device using various discovery specific credentials and all the global credentials + cisco.dnac.discovery_intent: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: Single IP Discovery + discovery_type: "SINGLE" + ip_address_list: + - 204.1.2.5 + discovery_specific_credentials: + cli_credentials_list: + - username: cisco + password: Cisco#123 + enable_password: Cisco#123 + http_read_credential: + username: string + password: Lablab#123 + port: 443 + secure: True + snmp_v2_read_credential: + desc: string + community: string + snmp_v2_write_credential: + desc: string + community: string + snmp_v3_credential: + username: v3Public2 + snmp_mode: AUTHPRIV + auth_type: SHA + auth_password: Lablab#1234 + privacy_type: AES256 + privacy_password: Lablab#1234 + protocol_order: ssh + + - name: Execute discovery of single device using various discovery specific credentials only + cisco.dnac.discovery_intent: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: Single without Global Credentials + discovery_type: "SINGLE" + ip_address_list: + - 204.1.2.5 + use_global_credentials: False + discovery_specific_credentials: + cli_credentials_list: + - username: cisco + password: Cisco#123 + enable_password: Cisco#123 + http_read_credential: + username: string + password: Lablab#123 + port: 443 + secure: True + snmp_v2_read_credential: + desc: string + community: string + snmp_v2_write_credential: + desc: string + community: string + snmp_v3_credential: + username: v3Public2 + snmp_mode: AUTHPRIV + auth_type: SHA + auth_password: Lablab#1234 + privacy_type: AES256 + privacy_password: Lablab#1234 + protocol_order: ssh + + - name: Execute discovery devices using MULTI RANGE with various discovery specific credentials and all global credentials (max 5 allowed) + cisco.dnac.discovery_intent: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_type: "MULTI RANGE" + discovery_name: Multi_range + ip_address_list: + - 204.1.2.1-204.1.2.100 #It will be taken as 204.1.2.1 - 204.1.2.1 + - 205.2.1.1-205.2.1.10 + ip_filter_list: + - 204.1.2.5 #Devie with IP 204.1.2.5 won't be discovered + discovery_specific_credentials: + cli_credentials_list: + - username: admin + password: maglev123 + enable_password: maglev123 + http_read_credential: + username: admin + password: maglev123 + port: 443 + secure: True + snmp_v2_read_credential: + desc: new + community: password + snmp_v3_credential: + username: administrator + snmp_mode: AUTHPRIV + auth_password: admin123 + auth_type: SHA + privacy_type: AES192 + privacy_password: cisco#123 + protocol_order: ssh + start_index: 1 + records_to_return: 1000 + snmp_version: v2 + + - name: Execute discovery devices using CDP/LLDP/CIDR leveraging discovery specific credentials and all the global credentials + cisco.dnac.discovery_intent: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: CDP_Test_1 + discovery_type: "CDP" #Can be LLDP and CIDR + ip_address_list: #List length should be one + - 204.1.2.1 + cdp_level: 2 #Instead use lldp_level for LLDP and prefix length for CIDR + discovery_specific_credentials: + cli_credentials_list: + - username: admin + password: maglev123 + enable_password: maglev123 + protocol_order: ssh + + - name: Execute deletion of single discovery from the dashboard + cisco.dnac.discovery_intent: + <<: *dnac_login + state: deleted + config_verify: True + config: + - discovery_name: CDP_Test_1 + + - name: Execute deletion of all the discoveries from the dashboard + cisco.dnac.discovery_intent: + <<: *dnac_login + state: deleted + config_verify: True + config: + - delete_all: True \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/discovery_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/discovery_workflow_manager.yml new file mode 100644 index 000000000..6a7e6cf7d --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/discovery_workflow_manager.yml @@ -0,0 +1,197 @@ +--- +- name: Discover devices using multiple discovery specific credentials and delete all the discoveries + hosts: localhost + connection: local + gather_facts: no + + vars_files: + - "{{ CLUSTERFILE }}" + + vars: + dnac_login: &dnac_login + dnac_host: "{{ dnac_host }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_port: "{{ dnac_port }}" + dnac_version: "{{ dnac_version }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + dnac_log_level: DEBUG + + tasks: + + - name: Execute discovery devices using MULTI RANGE with various global credentials + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: Multi_global + discovery_type: MULTI RANGE + ip_address_list: + - 204.1.2.1-204.1.2.5 + - 204.192.3.40 + - 204.192.4.200 + - 204.1.2.6 + - 204.1.2.7 + - 204.1.2.8 + - 204.1.2.9 + - 204.1.2.10 + - 204.1.2.11 + global_credentials: + cli_credentials_list: + - description: ISE + username: cisco + - description: CLI1234 #Incorrect name passed + username: cli + http_read_credential_list: + - description: HTTP Read + username: HTTP_Read + snmp_v3_credential_list: + - description: snmpV3 + username: snmpV3 + protocol_order: ssh + + - name: Execute discovery of single device using various discovery specific credentials and all the global credentials + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: Single IP Discovery + discovery_type: "SINGLE" + ip_address_list: + - 204.1.2.5 + discovery_specific_credentials: + cli_credentials_list: + - username: cisco + password: Cisco#123 + enable_password: Cisco#123 + http_read_credential: + username: string + password: Lablab#123 + port: 443 + secure: True + snmp_v2_read_credential: + desc: string + community: string + snmp_v2_write_credential: + desc: string + community: string + snmp_v3_credential: + username: v3Public2 + snmp_mode: AUTHPRIV + auth_type: SHA + auth_password: Lablab#1234 + privacy_type: AES256 + privacy_password: Lablab#1234 + protocol_order: ssh + + - name: Execute discovery of single device using various discovery specific credentials only + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: Single without Global Credentials + discovery_type: "SINGLE" + ip_address_list: + - 204.1.2.5 + use_global_credentials: False + discovery_specific_credentials: + cli_credentials_list: + - username: cisco + password: Cisco#123 + enable_password: Cisco#123 + http_read_credential: + username: string + password: Lablab#123 + port: 443 + secure: True + snmp_v2_read_credential: + desc: string + community: string + snmp_v2_write_credential: + desc: string + community: string + snmp_v3_credential: + username: v3Public2 + snmp_mode: AUTHPRIV + auth_type: SHA + auth_password: Lablab#1234 + privacy_type: AES256 + privacy_password: Lablab#1234 + protocol_order: ssh + + - name: Execute discovery devices using MULTI RANGE with various discovery specific credentials and all global credentials (max 5 allowed) + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_type: "MULTI RANGE" + discovery_name: Multi_range + ip_address_list: + - 204.1.2.1-204.1.2.100 #It will be taken as 204.1.2.1 - 204.1.2.1 + - 205.2.1.1-205.2.1.10 + ip_filter_list: + - 204.1.2.5 #Devie with IP 204.1.2.5 won't be discovered + discovery_specific_credentials: + cli_credentials_list: + - username: admin + password: maglev123 + enable_password: maglev123 + http_read_credential: + username: admin + password: maglev123 + port: 443 + secure: True + snmp_v2_read_credential: + desc: new + community: password + snmp_v3_credential: + username: administrator + snmp_mode: AUTHPRIV + auth_password: admin123 + auth_type: SHA + privacy_type: AES192 + privacy_password: cisco#123 + protocol_order: ssh + start_index: 1 + records_to_return: 1000 + snmp_version: v2 + + - name: Execute discovery devices using CDP/LLDP/CIDR leveraging discovery specific credentials and all the global credentials + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: merged + config_verify: True + config: + - discovery_name: CDP_Test_1 + discovery_type: "CDP" #Can be LLDP and CIDR + ip_address_list: #List length should be one + - 204.1.2.1 + cdp_level: 2 #Instead use lldp_level for LLDP and prefix length for CIDR + discovery_specific_credentials: + cli_credentials_list: + - username: admin + password: maglev123 + enable_password: maglev123 + protocol_order: ssh + + - name: Execute deletion of single discovery from the dashboard + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: deleted + config_verify: True + config: + - discovery_name: CDP_Test_1 + + - name: Execute deletion of all the discoveries from the dashboard + cisco.dnac.discovery_workflow_manager: + <<: *dnac_login + state: deleted + config_verify: True + config: + - delete_all: True \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/global_credentials.yml b/ansible_collections/cisco/dnac/playbooks/global_credentials.yml index c485e5d20..dca7df37c 100644 --- a/ansible_collections/cisco/dnac/playbooks/global_credentials.yml +++ b/ansible_collections/cisco/dnac/playbooks/global_credentials.yml @@ -17,8 +17,8 @@ validate_response_schema: false enablePassword: C2sco456! username: Test2 - password: C2sco456! - description: Test2 + password: C2sco456!2 + description: Test2 Ansible - name: Create SNMPV3 Credential cisco.dnac.snmpv3_credential: @@ -33,4 +33,4 @@ validate_response_schema: false username: user2 snmpMode: NOAUTHNOPRIV - description: user2 cred + description: user2 222 diff --git a/ansible_collections/cisco/dnac/playbooks/inventory_device.yml b/ansible_collections/cisco/dnac/playbooks/inventory_device.yml new file mode 100644 index 000000000..e17bf6791 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/inventory_device.yml @@ -0,0 +1,53 @@ +--- +- name: Configure device credentials on Cisco DNA Center + hosts: localhost + connection: local + gather_facts: no + vars_files: + - "input_inventory.yml" + - "credentials.yml" + tasks: + - name: Add/Update/Resync/Delete the devices in Cisco DNA Center Inventory. + cisco.dnac.inventory_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: true + state: merged + config: + - username: "{{item.username}}" + enable_password: "{{item.enable_password}}" + password: "{{item.password}}" + ip_address: "{{item.ip_address}}" + snmp_auth_passphrase: "{{item.snmp_auth_passphrase}}" + snmp_auth_protocol: "{{item.snmp_auth_protocol}}" + snmp_mode: "{{item.snmp_mode}}" + snmp_priv_passphrase: "{{item.snmp_priv_passphrase}}" + snmp_priv_protocol: "{{item.snmp_priv_protocol}}" + snmp_ro_community: "{{item.snmp_ro_community}}" + snmp_rw_community: "{{item.snmp_rw_community}}" + snmp_username: "{{item.snmp_username}}" + device_updated: "{{item.device_updated}}" + clean_config: "{{item.clean_config}}" + type: "{{item.type}}" + update_device_role: + role: "{{item.role}}" + role_source: "{{item.role_source}}" + add_user_defined_field: + name: "{{item.name}}" + description: "{{item.description}}" + value: "{{item.value}}" + provision_wired_device: + site_name: "{{item.site_name}}" + export_device_list: + password: "{{item.export_device_list.password}}" + operation_enum: "{{item.export_device_list.operation_enum}}" + reboot_device: "{{item.reboot_device}}" + + with_items: "{{ device_details }}" + tags: + - inventory_device \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/inventory_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/inventory_workflow_manager.yml new file mode 100644 index 000000000..72bcc39d0 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/inventory_workflow_manager.yml @@ -0,0 +1,67 @@ +--- +- name: Configure device credentials on Cisco DNA Center + hosts: localhost + connection: local + gather_facts: no + vars_files: + - "input_inventory.yml" + - "credentials.yml" + tasks: + - name: Add/Update/Resync/Delete the devices in Cisco DNA Center Inventory. + cisco.dnac.inventory_workflow_manager: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log_level: DEBUG + dnac_log: true + config_verify: true + state: merged + config: + - username: "{{item.username}}" + password: "{{item.password}}" + enable_password: "{{item.enable_password}}" + ip_address_list: "{{item.ip_address_list}}" + cli_transport: "{{item.cli_transport}}" + snmp_auth_passphrase: "{{item.snmp_auth_passphrase}}" + snmp_auth_protocol: "{{item.snmp_auth_protocol}}" + snmp_mode: "{{item.snmp_mode}}" + snmp_priv_passphrase: "{{item.snmp_priv_passphrase}}" + snmp_priv_protocol: "{{item.snmp_priv_protocol}}" + snmp_ro_community: "{{item.snmp_ro_community}}" + snmp_rw_community: "{{item.snmp_rw_community}}" + snmp_username: "{{item.snmp_username}}" + credential_update: "{{item.credential_update}}" + clean_config: "{{item.clean_config}}" + type: "{{item.type}}" + device_resync: "{{item.device_resync}}" + reboot_device: "{{item.reboot_device}}" + role: "{{item.role}}" + add_user_defined_field: + - name: Test123 + description: "Added first udf for testing" + value: "value123" + - name: Test321 + description: "Added second udf for testing" + value: "value321" + provision_wired_device: + - device_ip: "1.1.1.1" + site_name: "Global/USA/San Francisco/BGL_18/floor_pnp" + resync_retry_count: 200 + resync_interval: 2 + - device_ip: "2.2.2.2" + site_name: "Global/USA/San Francisco/BGL_18/floor_test" + resync_retry_count: 200 + resync_retry_interval: 2 + update_interface_details: + description: "{{item.update_interface_details.description}}" + interface_name: "{{item.interface_name}}" + export_device_list: + password: "{{item.export_device_list.password}}" + + with_items: "{{ device_details }}" + tags: + - inventory_device diff --git a/ansible_collections/cisco/dnac/playbooks/network_settings_intent.yml b/ansible_collections/cisco/dnac/playbooks/network_settings_intent.yml new file mode 100644 index 000000000..92d045a4d --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/network_settings_intent.yml @@ -0,0 +1,112 @@ +- hosts: dnac_servers + vars_files: + - credentials.yml + gather_facts: no + connection: local + tasks: +# +# Project Info Section +# + + - name: Create global pool, reserve subpool and network functions + cisco.dnac.network_settings_intent: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + dnac_log_level: "{{ dnac_log_level }}" + dnac_log_append: True + dnac_log_file_path: "{{ dnac_log_file_path }}" + state: merged + config_verify: True + config: + - global_pool_details: + settings: + ip_pool: + - name: Global_Pool2 + gateway: '' #use this for updating + ip_address_space: IPv6 #required when we are creating + cidr: 2001:db8::/64 #required when we are creating + pool_type: Generic + dhcp_server_ips: [] #use this for updating + dns_server_ips: [] #use this for updating + # prev_name: Global_Pool2 + reserve_pool_details: + ipv6_address_space: True + ipv4_global_pool: 100.0.0.0/8 + ipv4_prefix: True + ipv4_prefix_length: 9 + ipv4_subnet: 100.128.0.0 + ipv4_gateway: 100.128.0.1 + # ipv4_dns_servers: [100.128.0.1] + name: IP_Pool_3 + ipv6_prefix: True + ipv6_prefix_length: 64 + ipv6_global_pool: 2001:db8::/64 + ipv6_subnet: '2001:db8::' + site_name: Global/Chennai/Trill + slaac_support: True + # prev_name: IP_Pool_4 + type: LAN + network_management_details: + settings: + dhcp_server: + - 10.0.0.1 + dns_server: + domain_name: cisco.com + primary_ip_address: 10.0.0.2 + secondary_ip_address: 10.0.0.3 + client_and_endpoint_aaa: #works only if we system settigns is set + ip_address: 10.197.156.42 #Mandatory for ISE, sec ip for AAA + network: 10.0.0.20 + protocol: RADIUS + servers: AAA + # shared_secret: string #ISE + message_of_the_day: + banner_message: hello + retain_existing_banner: 'true' + netflow_collector: + ip_address: 10.0.0.4 + port: 443 + network_aaa: #works only if we system settigns is set + ip_address: 10.0.0.21 #Mandatory for ISE, sec ip for AAA + network: 10.0.0.20 + protocol: TACACS + servers: AAA + # shared_secret: string #ISE + ntp_server: + - 10.0.0.5 + snmp_server: + configure_dnac_ip: false + # ip_addresses: + # - 10.0.0.6 + syslog_server: + configure_dnac_ip: false + # ip_addresses: + # - 10.0.0.7 + timezone: GMT + site_name: Global/Chennai + + - name: Delete Global Pool and Release Pool Reservation + cisco.dnac.network_settings_intent: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + dnac_log_level: "{{ dnac_log_level }}" + state: deleted + config_verify: True + config: + - global_pool_details: + settings: + ip_pool: + - name: Global_Pool2 + reserve_pool_details: + name: IP_Pool_3 + site_name: Global/Chennai/Trill diff --git a/ansible_collections/cisco/dnac/playbooks/network_settings_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/network_settings_workflow_manager.yml new file mode 100644 index 000000000..36b88ac2d --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/network_settings_workflow_manager.yml @@ -0,0 +1,108 @@ +- hosts: dnac_servers + vars_files: + - credentials.yml + gather_facts: no + connection: local + tasks: + - name: Create global pool, reserve subpool and network functions + cisco.dnac.network_settings_workflow_manager: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + dnac_log_level: "{{ dnac_log_level }}" + dnac_log_append: True + dnac_log_file_path: "{{ dnac_log_file_path }}" + state: merged + config_verify: True + config: + - global_pool_details: + settings: + ip_pool: + - name: Global_Pool2 + gateway: '' #use this for updating + ip_address_space: IPv6 #required when we are creating + cidr: 2001:db8::/64 #required when we are creating + pool_type: Generic + dhcp_server_ips: [] #use this for updating + dns_server_ips: [] #use this for updating + # prev_name: Global_Pool2 + reserve_pool_details: + ipv6_address_space: True + ipv4_global_pool: 100.0.0.0/8 + ipv4_prefix: True + ipv4_prefix_length: 9 + ipv4_subnet: 100.128.0.0 + ipv4_gateway: 100.128.0.1 + # ipv4_dns_servers: [100.128.0.1] + name: IP_Pool_3 + ipv6_prefix: True + ipv6_prefix_length: 64 + ipv6_global_pool: 2001:db8::/64 + ipv6_subnet: '2001:db8::' + site_name: Global/Chennai/Trill + slaac_support: True + # prev_name: IP_Pool_4 + pool_type: LAN + network_management_details: + settings: + dhcp_server: + - 10.0.0.1 + dns_server: + domain_name: cisco.com + primary_ip_address: 10.0.0.2 + secondary_ip_address: 10.0.0.3 + client_and_endpoint_aaa: #works only if we system settigns is set + ip_address: 10.197.156.42 #Mandatory for ISE, sec ip for AAA + network: 10.0.0.20 + protocol: RADIUS + servers: AAA + # shared_secret: string #ISE + message_of_the_day: + banner_message: hello + retain_existing_banner: 'true' + netflow_collector: + ip_address: 10.0.0.4 + port: 443 + network_aaa: #works only if we system settigns is set + ip_address: 10.0.0.21 #Mandatory for ISE, sec ip for AAA + network: 10.0.0.20 + protocol: TACACS + servers: AAA + # shared_secret: string #ISE + ntp_server: + - 10.0.0.5 + snmp_server: + configure_dnac_ip: false + # ip_addresses: + # - 10.0.0.6 + syslog_server: + configure_dnac_ip: false + # ip_addresses: + # - 10.0.0.7 + timezone: GMT + site_name: Global/Chennai + + - name: Delete Global Pool and Release Pool Reservation + cisco.dnac.network_settings_workflow_manager: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: True + dnac_log_level: "{{ dnac_log_level }}" + state: deleted + config_verify: True + config: + - global_pool_details: + settings: + ip_pool: + - name: Global_Pool2 + reserve_pool_details: + name: IP_Pool_3 + site_name: Global/Chennai/Trill diff --git a/ansible_collections/cisco/dnac/playbooks/site_intent.yml b/ansible_collections/cisco/dnac/playbooks/site_intent.yml new file mode 100644 index 000000000..9dfe26099 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/site_intent.yml @@ -0,0 +1,32 @@ +- hosts: localhost + connection: local + gather_facts: no + vars_files: + - "credentials.yml" + tasks: + - name: Get site info and updating site details + cisco.dnac.site_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: true + state: merged + config: + - site: + floor: + name: Test_Floor2 + parent_name: 'Global/USA/San Francisco/BGL_18' + length: "101" + width: "75" + height: "50" + rf_model: 'Cubes And Walled Offices' + floor_number: 3 + - site: + area: + name: Canada + parent_name: 'Global' + type: area diff --git a/ansible_collections/cisco/dnac/playbooks/site_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/site_workflow_manager.yml new file mode 100644 index 000000000..79b42a436 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/site_workflow_manager.yml @@ -0,0 +1,39 @@ +- hosts: localhost + connection: local + gather_facts: no + vars_files: + - "credentials.yml" + tasks: + - name: Get site info and updating site details + cisco.dnac.site_workflow_manager: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: True + dnac_log_level: DEBUG + config_verify: True + state: merged + config: + - site: + floor: + name: Test_Floor6 + parent_name: 'Global/USA/San Francisco/BGL_18' + length: 103.23 + width: 75.1 + height: 50.22 + rf_model: 'Cubes And Walled Offices' + floor_number: 3 + site_type: floor + - site: + area: + name: Abc + parent_name: 'Global' + address: Bengaluru, Karnataka, India + latitude: 22.2111 + longitude: -42.1234434 + country: "United States" + site_type: area diff --git a/ansible_collections/cisco/dnac/playbooks/swim_import_local.yml b/ansible_collections/cisco/dnac/playbooks/swim_import_local.yml new file mode 100644 index 000000000..8f6c55994 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/swim_import_local.yml @@ -0,0 +1,22 @@ +- hosts: dnac_servers + vars_files: + - credentials.yml + gather_facts: false + connection: local + tasks: + - name: Import Local + cisco.dnac.swim_import_local: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + #headers: "{{my_headers | from_json}}" + isThirdParty: False + thirdPartyVendor: "string" + thirdPartyImageFamily: "string" + thirdPartyApplicationType: "string" + filePath: "./tests/test-1592357065255.csv" + register: result \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/swim_intent.yml b/ansible_collections/cisco/dnac/playbooks/swim_intent.yml new file mode 100644 index 000000000..687a84e25 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/swim_intent.yml @@ -0,0 +1,43 @@ +--- +- name: Configure device credentials on Cisco DNA Center + hosts: localhost + connection: local + gather_facts: no + vars_files: + - "input_swim.yml" + - "credentials.yml" + tasks: + - name: Import an image, tag it as golden and load it on device {{ item.device_serial_number }} + cisco.dnac.swim_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: true + config: + - import_image_details: + type: "{{ item.type }}" + url_details: + payload: "{{ item.url_details.payload }}" + tagging_details: + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + device_type: "{{item.device_type}}" + tagging: true + image_distribution_details: + site_name: "{{item.site_name}}" + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + image_activation_details: + site_name: "{{item.site_name}}" + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + scehdule_validate: false + distribute_if_needed: true + + with_items: "{{ image_details }}" + tags: + - swim \ No newline at end of file diff --git a/ansible_collections/cisco/dnac/playbooks/swim_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/swim_workflow_manager.yml new file mode 100644 index 000000000..c4f027c46 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/swim_workflow_manager.yml @@ -0,0 +1,54 @@ +--- +- name: Configure device credentials on Cisco DNA Center + hosts: localhost + connection: local + gather_facts: no + vars_files: + - "input_swim.yml" + - "credentials.yml" + tasks: + - name: Import an image, tag it as golden and load it on device + cisco.dnac.swim_workflow_manager: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: True + dnac_log_level: DEBUG + config_verify: True + dnac_api_task_timeout: 1000 + dnac_task_poll_interval: 1 + config: + - import_image_details: + type: "{{ item.type }}" + url_details: + payload: + - source_url: http://172.21.236.183/swim/V1712_2_CCO/cat9k_iosxe.17.12.02.SPA.bin + third_party: False + tagging_details: + image_name: cat9k_iosxe.17.12.02.SPA.bin + device_role: ALL + device_image_family_name: Cisco Catalyst 9300 Switch + site_name: "{{item.site_name}}" + tagging: True + # image_distribution_details: + # image_name: cat9k_iosxe.17.12.02.SPA.bin + # site_name: "{{item.site_name}}" + # device_role: "{{ item.device_role }}" + # device_family_name: "{{ item.device_family_name }}" + # device_series_name: "Catalyst 9300 Series" + image_activation_details: + image_name: cat9k_iosxe.17.12.02.SPA.bin + site_name: "{{item.site_name}}" + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + device_series_name: "Catalyst 9300 Series" + scehdule_validate: False + distribute_if_needed: True + + with_items: "{{ image_details }}" + tags: + - swim diff --git a/ansible_collections/cisco/dnac/playbooks/template_pnp_intent.yml b/ansible_collections/cisco/dnac/playbooks/template_pnp_intent.yml index 4ce25e16d..09ea6a722 100644 --- a/ansible_collections/cisco/dnac/playbooks/template_pnp_intent.yml +++ b/ansible_collections/cisco/dnac/playbooks/template_pnp_intent.yml @@ -1,14 +1,14 @@ -- hosts: dnac_servers +- hosts: localhost vars_files: - credentials.yml - - device_details.yml + - device_details.template gather_facts: false connection: local tasks: # # Project Info Section # - - name: Test project template + - name: Test project template cisco.dnac.template_intent: dnac_host: "{{ dnac_host }}" dnac_port: "{{ dnac_port }}" @@ -18,17 +18,19 @@ dnac_debug: "{{ dnac_debug }}" dnac_log: true state: "merged" + config_verify: true #ignore_errors: true #Enable this to continue execution even the task fails config: - - projectName: "{{ item.proj_name }}" - templateContent: "{{ item.device_config }}" - language: "{{ item.language }}" - deviceTypes: - - productFamily: "{{ item.family }}" - softwareType: "{{ item.type }}" - softwareVariant: "{{ item.variant }}" - templateName: "{{ item.temp_name }}" - versionDescription: "{{ item.description }}" + - configuration_templates: + project_name: "{{ item.proj_name }}" + template_name: "{{ item.temp_name }}" + template_content: "{{ item.device_config }}" + version_description: "{{ item.description }}" + language: "{{ item.language }}" + software_type: "{{ item.type }}" + software_variant: "{{ item.variant }}" + device_types: + - product_family: "{{ item.family }}" register: template_result with_items: '{{ template_details }}' tags: @@ -49,12 +51,11 @@ project_name: "{{ item.proj_name }}" template_name: "{{ item.temp_name }}" image_name: "{{ item.image_name }}" - device_version: "{{ item.device_version }}" - deviceInfo: - serialNumber: "{{ item.device_number }}" - hostname: "{{ item.device_name}}" - state: "{{ item.device_state }}" - pid: "{{ item.device_id }}" + device_info: + - serial_number: "{{ item.device_number }}" + hostname: "{{ item.device_name}}" + state: "{{ item.device_state }}" + pid: "{{ item.device_id }}" register: pnp_result with_items: '{{ device_details }}' tags: diff --git a/ansible_collections/cisco/dnac/playbooks/template_workflow_manager.yml b/ansible_collections/cisco/dnac/playbooks/template_workflow_manager.yml new file mode 100644 index 000000000..25b0ec797 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/template_workflow_manager.yml @@ -0,0 +1,34 @@ +- hosts: localhost + vars_files: + - credentials.yml + - device_details.template + gather_facts: false + connection: local + tasks: + - name: Test project template + cisco.dnac.template_workflow_manager: + dnac_host: "{{ dnac_host }}" + dnac_port: "{{ dnac_port }}" + dnac_username: "{{ dnac_username }}" + dnac_password: "{{ dnac_password }}" + dnac_verify: "{{ dnac_verify }}" + dnac_debug: "{{ dnac_debug }}" + dnac_log: true + state: "merged" + config_verify: true + #ignore_errors: true #Enable this to continue execution even the task fails + config: + - configuration_templates: + project_name: "{{ item.proj_name }}" + template_name: "{{ item.temp_name }}" + template_content: "{{ item.device_config }}" + version_description: "{{ item.description }}" + language: "{{ item.language }}" + software_type: "{{ item.type }}" + software_variant: "{{ item.variant }}" + device_types: + - product_family: "{{ item.family }}" + register: template_result + with_items: '{{ template_details }}' + tags: + - template diff --git a/ansible_collections/cisco/dnac/playbooks/test_swim_module.yml b/ansible_collections/cisco/dnac/playbooks/test_swim_module.yml index 0fbbc2045..7e6e50007 100644 --- a/ansible_collections/cisco/dnac/playbooks/test_swim_module.yml +++ b/ansible_collections/cisco/dnac/playbooks/test_swim_module.yml @@ -1,14 +1,12 @@ -- hosts: dnac_servers - vars_files: - - credentials_245.yml - - image_details.yml #Contains image and device details - gather_facts: false +--- +- name: Configure device credentials on Cisco DNA Center + hosts: localhost connection: local + gather_facts: no + vars_files: + - "input_swim.yml" #Contains image and device details + - "credentials.yml" tasks: -# -# Project Info Section -# - - name: Import an image, tag it as golden and load it on device cisco.dnac.swim_intent: dnac_host: "{{ dnac_host }}" @@ -19,23 +17,26 @@ dnac_debug: "{{ dnac_debug }}" dnac_log: true config: - - importImageDetails: - type: "{{ item.import_type }}" - urlDetails: - payload: - - sourceURL: "{{ item.url_source }}" - isThirdParty: false - taggingDetails: - deviceRole: "{{ item.device_role }}" - deviceFamilyName: "{{ item.device_family_name }}" + - import_image_details: + type: "{{ item.type }}" + url_details: + payload: "{{ item.url_details.payload }}" + tagging_details: + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + device_type: "{{item.device_type}}" tagging: true - imageDistributionDetails: - deviceSerialNumber: "{{ item.device_serial_number }}" - imageActivationDetails: - scehduleValidate: false - activateLowerImageVersion: true - deviceSerialNumber: "{{ item.device_serial_number }}" - distributeIfNeeded: true + image_distribution_details: + site_name: "{{item.site_name}}" + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + image_activation_details: + site_name: "{{item.site_name}}" + device_role: "{{ item.device_role }}" + device_family_name: "{{ item.device_family_name }}" + scehdule_validate: false + distribute_if_needed: true + with_items: '{{ image_details }}' tags: - swim diff --git a/ansible_collections/cisco/dnac/playbooks/tests/test-1592357065255.csv b/ansible_collections/cisco/dnac/playbooks/tests/test-1592357065255.csv new file mode 100644 index 000000000..95d096fa3 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/tests/test-1592357065255.csv @@ -0,0 +1,3 @@ +Device IP,Device Name,DeviceType,Target Image,Target Version,Image Type,Reboot,Check Type,Description,PreCheck Status,LastChecked +10.10.20.51,3504_WLC,Wireless Controller,AIR-CT3504-K9-8-10-121-0,8.10.121.0,WLC_SW,Yes,Service Entitlement Check,Service Entitlement Check: WARNING : Unable to validate license for Device. Not enough information to validate.,WARNING,2020-06-17 01:24:04, +10.10.20.51,3504_WLC,Wireless Controller,AIR-CT3504-K9-8-10-121-0,8.10.121.0,WLC_SW,Yes,Flash check,Upgrade Analysis feature is not supported for Cisco Interfaces and Modules/Content Networking/Third Party devices/Wireless Controllers excluding Cisco 5760 Series; : ,SUCCESS,2020-06-17 01:24:04, diff --git a/ansible_collections/cisco/dnac/playbooks/user_info.yml b/ansible_collections/cisco/dnac/playbooks/user_info.yml new file mode 100644 index 000000000..da08c51c9 --- /dev/null +++ b/ansible_collections/cisco/dnac/playbooks/user_info.yml @@ -0,0 +1,18 @@ +- hosts: dnac_servers + vars_files: + - credentials.yml + gather_facts: false + connection: local + tasks: + - name: Get all User + cisco.dnac.user_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + #headers: "{{my_headers | from_json}}" + invokeSource: string + register: result \ No newline at end of file -- cgit v1.2.3