---
- name: Testing
  hosts: dnac_servers
  gather_facts: false

  vars_files:
    - "credentials.yml"

  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: INFO
      dnac_log_append: false
      config_verify: true

  tasks:
    - name: Create Extranet Policy
      cisco.dnac.network_compliance_workflow_manager:
        <<: *dnac_login
        state: merged
        config:
          - extranet_policy_name: "test_extranet_policy_1"
            provider_virtual_network: "VN_1"
            subscriber_virtual_networks: ["VN_2", "VN_3"]


    - name: Create Extranet Policy with Fabric Site(s) specified
      cisco.dnac.network_compliance_workflow_manager:
        <<: *dnac_login
        state: merged
        config:
          - extranet_policy_name: "test_extranet_policy_1"
            provider_virtual_network: "VN_1"
            subscriber_virtual_networks: ["VN_2", "VN_3"]
            fabric_sites: ["Global/Test_Extranet_Polcies/USA", "Global/Test_Extranet_Polcies/India"]


    - name: Update existing Extranet Policy
      cisco.dnac.network_compliance_workflow_manager:
        <<: *dnac_login
        state: merged
        config:
          - extranet_policy_name: "test_extranet_policy_1"
            provider_virtual_network: "VN_1"
            subscriber_virtual_networks: ["VN_2", "VN_4"]

    - name: Update existing Extranet Policy with Fabric Site(s) specified
      cisco.dnac.network_compliance_workflow_manager:
        <<: *dnac_login
        state: merged
        config:
          - extranet_policy_name: "test_extranet_policy_1"
            provider_virtual_network: "VN_1"
            subscriber_virtual_networks: ["VN_2", "VN_4"]
            fabric_sites: ["Global/Test_Extranet_Polcies/USA", "Global/Test_Extranet_Polcies/India"]


    - name: Delete Extranet Policy
      cisco.dnac.network_compliance_workflow_manager:
        <<: *dnac_login
        state: deleted
        config:
          - extranet_policy_name: "test_extranet_policy_1"
