# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low




- name: "Synchronize internal information system clocks"
  block:
    - name: "Check for duplicate values"
      ansible.builtin.lineinfile:
        path: '/etc/chrony/chrony.conf'
        create: True
        regexp: '(?i)^\s*makestep '
        state: 'absent'
      check_mode: yes
      changed_when: no
      register: 'dupes'
    - name: "Deduplicate values from /etc/chrony/chrony.conf"
      ansible.builtin.lineinfile:
        path: '/etc/chrony/chrony.conf'
        create: True
        regexp: '(?i)^\s*makestep '
        state: 'absent'
      when: 'dupes.found is defined and dupes.found > 1'
    - name: "Insert correct line to /etc/chrony/chrony.conf"
      ansible.builtin.lineinfile:
        path: '/etc/chrony/chrony.conf'
        create: True
        regexp: '(?i)^\s*makestep '
        line: 'makestep 1 -1'
        state: present
