---
# some variables are set during execution
venom_local_vars:
  - name: 'pfserver_mgmt_ip'
    value: "{{ packetfence_install__mgmt_interface['ip'] }}"

  - name: 'pfserver_mgmt_netmask'
    value: "{{ packetfence_install__mgmt_interface['mask'] }}"

  - name: 'pfserver_mgmt_interface'
    value: "{{ packetfence_install__mgmt_interface['id']  }}"

  - name: 'pfserver_mgmt_cidr'
    value: "{{ packetfence_install__mgmt_interface['ip_mask'] | ansible.netcommon.ipaddr('host/prefix')  }}"

  - name: 'pfserver_mgmt_net'
    value: "{{ packetfence_install__mgmt_interface['ip_mask'] | ansible.netcommon.ipaddr('network')  }}"

  # get second IP (.2) usable without /CIDR
  - name: 'configurator.interfaces.reg.ip'
    value: "{{ users_vars[dict_name]['networks'][1]['subnet'] | ansible.netcommon.next_nth_usable(2) | ansible.netcommon.ipaddr('address') }}"

  # get netmask based on CIDR
  - name: 'configurator.interfaces.reg.netmask'
    value: "{{ users_vars[dict_name]['networks'][1]['subnet'] | ansible.netcommon.ipaddr('netmask') }}"

  # get second IP (.2) usable without /CIDR
  - name: 'configurator.interfaces.iso.ip'
    value: "{{ users_vars[dict_name]['networks'][2]['subnet'] | ansible.netcommon.next_nth_usable(2) | ansible.netcommon.ipaddr('address') }}"

  # get netmask based on CIDR
  - name: 'configurator.interfaces.iso.netmask'
    value: "{{ users_vars[dict_name]['networks'][2]['subnet'] | ansible.netcommon.ipaddr('netmask') }}"

  # return latest usable IP (.254) based on CIDR
  - name: 'configurator_inline_l2.interfaces.inline.ip'
    value: "{{ users_vars[dict_name]['networks'][3]['subnet'] | ansible.netcommon.ipaddr('last_usable') }}"

  # get netmask based on CIDR
  - name: 'configurator_inline_l2.interfaces.inline.netmask'
    value: "{{ users_vars[dict_name]['networks'][3]['subnet'] | ansible.netcommon.ipaddr('netmask') }}"

  - name: 'smtp_server'
    value: "{{ packetfence_install__mgmt_interface['ip'] }}"

  - name: 'smtp_port'
    value: '{{ mailhog__smtp_port }}'

  - name: 'smtp_api_port'
    value: '{{ mailhog__api_port }}'

  - name: 'internet_int_ip'
    value: "{{ ansible_default_ipv4.address }}"

  - name: 'internet_int_netmask'
    value: "{{ ansible_default_ipv4.netmask }}"
  
  - name: 'timezone'
    value: "{{ ansible_date_time['tz'] }}"

  - name: 'mariadb_socket'
    value: "{{ mariadb_socket }}"

  - name: 'ad_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['ad']['ip'] }}"

  - name: 'switch01_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['switch01']['ip'] }}"

  - name: 'node01_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['node01']['ip'] }}"

  - name: 'node02_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['node02']['ip'] }}"

  - name: 'node03_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['node03']['ip'] }}"

  - name: 'wireless01_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['wireless01']['ip'] }}"

  - name: 'linux01_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['linux01']['ip'] }}"

  - name: 'linux02_mgmt_ip'
    value: "{{ users_vars[dict_name]['vms']['linux02']['ip'] }}"

  - name: 'fingerbank_api_key.secret_id'
    value: "{{ users_vars[dict_name]['vars']['fingerbank_api_key']['secret_id'] }}"

  - name: 'fingerbank_api_key.email'
    value: "{{ users_vars[dict_name]['vars']['fingerbank_api_key']['email'] }}"
