---
- name: Set OS platform facts
  set_fact:
    is_debian_based: "{{ ansible_distribution in ['Debian', 'Ubuntu'] }}"
    uses_systemd_socket: "{{ ansible_distribution in ['Debian', 'Ubuntu'] }}"
    is_ubuntu_22_plus: "{{ ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('22.04', '>=') }}"
  tags: always

- name: Define facts
  set_fact:
    p12_export_password: "{{ p12_password | default(lookup('password', '/dev/null length=9 chars=ascii_letters,digits,_,@')) }}"
  tags: update-users
  no_log: true

- name: Set facts
  set_fact:
    CA_password: "{{ ca_password | default(lookup('password', '/dev/null length=16 chars=ascii_letters,digits,_,@')) }}"
    IP_subject_alt_name: "{{ IP_subject_alt_name }}"
  no_log: true

- name: Set IPv6 support as a fact
  set_fact:
    ipv6_support: "{{ ansible_default_ipv6['gateway'] is defined }}"
  tags: always

- name: Check size of MTU
  set_fact:
    reduce_mtu: "{{ 1500 - ansible_default_ipv4['mtu'] | int if reduce_mtu | int == 0 and ansible_default_ipv4['mtu'] | int < 1500 else reduce_mtu | int }}"
  tags: always
