summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/ise/playbooks/trustsec_vn.yml
blob: 18197a71e5a7f7f8a511497f3c210ec5bb508005 (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
---
- hosts: ise_servers
  gather_facts: false

  vars:
    ise_login: &ise_login
      ise_hostname: "{{ ise_hostname }}"
      ise_username: "{{ ise_username }}"
      ise_password: "{{ ise_password }}"
      ise_verify: "{{ ise_verify }}"
      ise_debug: "{{ ise_debug }}"

  tasks:
    # - name: '[Get Virtual Network]'
    #   cisco.ise.trustsec_vn_info:
    #     <<: *ise_login
    #     page: 1
    #     size: 100
    #   register: vn_all

    # - name: '[Print Virtual Network all]'
    #   ansible.builtin.debug:
    #     var: vn_all

    - name: "Get VN filtered by name"
      cisco.ise.trustsec_vn_info:
        <<: *ise_login
        filter: name.EQ.vn1
      register: vn_filtered

    - name: "Create VN"
      cisco.ise.trustsec_vn:
        <<: *ise_login
        state: present
        name: vn1
        additionalAttributes: '{"Created": "1616961914"}'
      when:
        - vn_filtered is defined
        - vn_filtered.ise_response is defined
        - vn_filtered.ise_response | length == 0
      register: vn_manage

    - name: "Print Create Vn"
      ansible.builtin.debug:
        var: vn_manage

    - name: "Update Vn"
      cisco.ise.trustsec_vn:
        <<: *ise_login
        state: present
        name: vn1
        additionalAttributes: '{"Created": "1616961914", "Update": "1616962914"}'
      when:
        - vn_filtered is defined
        - vn_filtered.ise_response is defined
        - vn_filtered.ise_response | length > 0
      register: vn_manage

    - name: "Print Update VN"
      ansible.builtin.debug:
        var: vn_manage

    - name: "Get VN by id"
      cisco.ise.trustsec_vn_info:
        <<: *ise_login
        id: "{{ vn_manage.ise_response.id }}"
      when:
        - vn_manage is defined
        - vn_manage.ise_response is defined
      register: vn_by_id

    - name: "Print VN by id"
      ansible.builtin.debug:
        var: vn_by_id

    - name: "Delete Vn"
      cisco.ise.trustsec_vn:
        <<: *ise_login
        state: absent
        name: vn1
        additionalAttributes: '{"Created": "1616961914", "Update": "1616962914"}'
      when:
        - vn_filtered is defined
        - vn_filtered.ise_response is defined
        - vn_filtered.ise_response | length > 0
      register: vn_manage

    - name: "Print Delete VN"
      ansible.builtin.debug:
        var: vn_manage