Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REBASED: add support for chrony on EL7 #72

Merged
merged 4 commits into from Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions defaults/main.yml
@@ -1,6 +1,8 @@
---
ntp_enabled: true
ntp_timezone: Etc/UTC
ntp_package: ntp
ntp_configfile: /etc/ntp.conf

ntp_manage_config: false

Expand Down
12 changes: 8 additions & 4 deletions tasks/main.yml
Expand Up @@ -2,9 +2,13 @@
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"

- name: Include OS- Release specific variables on EL6.
include_vars: RedHat6.yml
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == '6'

- name: Ensure NTP-related packages are installed.
package:
name: ntp
name: "{{ ntp_package }}"
state: present

- name: Ensure tzdata package is installed (Linux).
Expand Down Expand Up @@ -34,9 +38,9 @@
enabled: false
when: not (ntp_enabled | bool)

- name: Generate ntp.conf file
- name: Generate ntp configuration file
template:
src: ntp.conf.j2
dest: /etc/ntp.conf
src: "{{ ntp_configfile |basename }}.j2"
dest: "{{ ntp_configfile }}"
notify: restart ntp
when: ntp_manage_config | bool
40 changes: 40 additions & 0 deletions templates/chrony.conf.j2
@@ -0,0 +1,40 @@
# {{ ansible_managed }}

# These servers were defined in the installation:
{% for server in ntp_servers %}
server {{ server }} iburst
{% endfor %}
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking
5 changes: 3 additions & 2 deletions vars/RedHat.yml
@@ -1,4 +1,5 @@
---
ntp_daemon: ntpd
ntp_daemon: chronyd
ntp_configfile: /etc/chrony.conf
ntp_package: chrony
ntp_tzdata_package: tzdata
ntp_driftfile: /var/lib/ntp/drift
6 changes: 6 additions & 0 deletions vars/RedHat6.yml
@@ -0,0 +1,6 @@
---
ntp_daemon: ntpd
ntp_configfile: /etc/ntp.conf
ntp_package: ntp
ntp_tzdata_package: tzdata
ntp_driftfile: /var/lib/ntp/drift