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

- name: "Detect if ntp is already configured with pools or servers"
  ansible.builtin.find:
    path: /etc
    patterns: ntp.conf
    contains: '^[\s]*(?:server|pool)[\s]+[\w]+'
  register: ntp_servers

- name: "Configure remote time servers"
  ansible.builtin.lineinfile:
    path: /etc/ntp.conf
    line: 'server {{ item }}'
    state: present
    create: True
  loop: '{{ var_multiple_time_servers.split(",") }}'
  when: ntp_servers.matched == 0
