- name: Play Name
  hosts: localhost
  vars_files:
    - credentials.yml
  vars:
    org_id: "828099381482762270"
    corp_name: Umbrella Corp
  gather_facts: false
  tasks:
    - name: Get Organization Networks
      cisco.meraki.networks_info:
        organizationId: "{{ org_id }}"
      register: result
    - name: Filter networks with "wireless" productTypes
      ansible.builtin.set_fact:
        filtered_networks:
          "{{ result.meraki_response | selectattr('productTypes',
          'contains', 'wireless') | list }}"
    - name: Create corporate SSID
      cisco.meraki.networks_wireless_ssids:
        state: present
        enabled: true
        name: "{{ corp_name }}"
        networkId: "{{ item.id }}"
        number: 1
        ipAssignmentMode: Bridge mode
        defaultVlanId: 100
        useVlanTagging: true
        authMode: 8021x-radius
        radiusServers:
          - one: null
            host: 1.2.3.4
            port: 1812
            secret: SuperSecretPassword
      loop: "{{ filtered_networks }}"
      loop_control:
        label: "{{ item.id }}"
    - name: Create Mobile/PSK SSID
      cisco.meraki.networks_wireless_ssids:
        state: present
        enabled: true
        name: "{{ corp_name }}-legacy"
        networkId: "{{ item.id }}"
        number: 2
        ipAssignmentMode: Bridge mode
        defaultVlanId: 200
        useVlanTagging: true
        authMode: psk
        encryptionMode: wpa
        psk: SuperSecretPreSharedKey
      loop: "{{ filtered_networks }}"
      loop_control:
        label: "{{ item.id }}"
    - name: Create Guest SSID
      cisco.meraki.networks_wireless_ssids:
        state: present
        enabled: true
        name: "{{ corp_name }}-Guests"
        networkId: "{{ item.id }}"
        number: 3
        ipAssignmentMode: Bridge mode
        defaultVlanId: 300
        useVlanTagging: true
        authMode: open
        splashPage: Click-through splash page
      loop: "{{ filtered_networks }}"
      loop_control:
        label: "{{ item.id }}"
