Installing and Configuring Chrony with Ansible on Rocky 8


If you are using Ansible to configure chrony which is a versatile implementation of the Network Time Protocol (NTP), you may want to take a look at the simple script below

- hosts: all
  tasks:

  - name: Install Chrony package
    dnf:
        name: chrony
        state: present
    when: ansible_distribution == "Rocky"

  - name: Configure Chrony servers
    lineinfile:
        path: /etc/chrony.conf
        line: "server sg.pool.ntp.org iburst"
        insertafter: '^#.*server 3.centos.pool.ntp.org iburst'
        state: present
    when: ansible_distribution == "Rocky"

  - name: Enable Chrony service
    service:
        name: chronyd
        state: started
        enabled: yes
    when: ansible_distribution == "Rocky"

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.