# requires driving repo to be cloned on vision machines
---
- name: Configure chrony GPS
  become: yes
  copy:
    src: "chrony.gps.conf"
    dest: "/etc/chrony/chrony.conf"
    owner: root
    group: root
    mode: '644'
  when: "time_source == 'GPS'"
  notify:
  - Restart chrony

- name: Configure chrony NTP External
  become: yes
  copy:
    src: "chrony.ntp.conf"
    dest: "/etc/chrony/chrony.conf"
    owner: root
    group: root
    mode: '644'
  when: "time_source == 'NTP_EXTERNAL_NET'"
  notify:
  - Restart chrony

- name: Configure chrony NTP_SIM
  become: yes
  copy:
    src: "chrony.sim.conf"
    dest: "/etc/chrony/chrony.conf"
    owner: root
    group: root
    mode: '644'
  when: "time_source == 'NTP_SIM'"
  notify:
  - Restart chrony

- name: Setup chrony
  become: yes
  service:
    name: chrony
    enabled: "{{ time_source != 'EMU' }}"
  notify:
  - "{{ 'Stop chrony' if time_source == 'EMU' else 'Restart chrony' }}"
