--- # Copyright Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Install, configure, and enable chrony become: true block: - name: Install chrony ansible.builtin.dnf: name: chrony state: present - name: Configure original chrony.conf file ansible.builtin.lineinfile: path: "{{ cifmw_ntp_chrony_conf_file }}" regexp: "{{ item.regexp | default(omit) }}" line: "{{ item.line }}" insertafter: "{{ item.insertafter | default(omit) }}" backrefs: "{{ item.backrefs | default(omit) }}" state: present backup: true loop: - { regexp: "^(server.*)$", line: "#\\g<1>", backrefs: true } - { line: "include {{ cifmw_ntp_chrony_extra_conf_file }}", insertafter: "EOF" } - name: Render chrony extra config file ansible.builtin.template: src: chrony.conf.j2 dest: "{{ cifmw_ntp_chrony_extra_conf_file }}" owner: root group: root mode: '0644' backup: true notify: Restart chrony - name: Enable chrony service ansible.builtin.systemd_service: name: chronyd.service state: started enabled: true