# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low
{{{ ansible_instantiate_variables("var_multiple_time_servers") }}}

{{% set timesyncd_conf_file = "/etc/systemd/timesyncd.conf.d/oscap-remedy.conf" %}}

- name: {{{ rule_title }}} - Set Primary NTP Servers
  ansible.builtin.set_fact:
    preferred_ntp_servers: '{{ var_multiple_time_servers.split(",") | slice(2)| first | join(" ") }}'

- name: {{{ rule_title }}} - Set Fallback NTP Servers
  ansible.builtin.set_fact:
    fallback_ntp_servers: '{{ var_multiple_time_servers.split(",") | slice(2)| list | last | join(" ") }}'

{{{ ansible_ini_file_set(timesyncd_conf_file, "Time", "NTP", "{{ preferred_ntp_servers }}") }}}
{{{ ansible_ini_file_set(timesyncd_conf_file, "Time", "FallbackNTP", "{{ fallback_ntp_servers }}") }}}
