summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/dnac/playbooks/PnP.yml
blob: 31cb11f9bf07c61603c54ff22341ca2199e82909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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_params:
              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