apiVersion: v1
kind: ConfigMap
metadata:
  name: aviansible-configmap
  namespace: default
data:
  main.yml: |
    - hosts: localhost
      connection: local
      vars_files:
        - "/etc/avi/conf/avi_vars.yml"
      vars:
        - api_version: "{{ version }}"
        - avi_controller: "{{ avi_controller }}"
        - avi_username: "{{ username }}"
        - avi_password: "{{ password }}"
      roles:
        - role: avinetworks.avisdk
      tasks:
        - name: Create new cloud
          avi_cloud:
            controller: "{{ avi_controller }}" 
            username: "{{ username }}"
            password: "{{ password }}"
            api_version: "{{ version }}"
            state: "present"
            name: "{{ cloud_name }}"
            tenant_ref: "/api/tenant?name=admin"
            vtype: "CLOUD_NONE"
        #- name: Configure EW Network
        #  avi_network:
        #    controller: "{{ avi_controller }}" 
        #    username: "{{ username }}"
        #    password: "{{ password }}"
        #    api_version: "{{ version }}"
        #    state: "present"
        #    name: "EW-Net-{{ cloud_name }}"
        #    configured_subnets:
        #      - prefix:
        #          mask: "16"
        #          ip_addr:
        #            type: V4
        #            addr: "172.90.0.0"
        #        static_ranges:
        #        - begin:
        #            type: V4
        #            addr: "172.90.0.10"
        #          end:
        #            type: V4
        #            addr: "172.90.255.250"
        - name: Configure Avi | IPAM, DNS, k8s Cloud
          include_role:
            name: avinetworks.aviconfig
          vars:
            avi_config_file: "/etc/avi/conf/aviconfig.yml"
        - name: Set DNS VS as system DNS
          avi_systemconfiguration:
            controller: "{{ avi_controller }}" 
            username: "{{ username }}"
            password: "{{ password }}"
            api_version: "{{ version }}"
            state: "present"
            avi_api_update_method: "patch"
            avi_api_patch_op: "add"
            dns_virtualservice_refs:
              - "/api/virtualservice?name=DNS-VS-{{ cloud_name }}"
