Skip to content

Commit

Permalink
Merge pull request #72 from ogajduse/feature-chronyd
Browse files Browse the repository at this point in the history
REBASED: add support for chrony on EL7
  • Loading branch information
geerlingguy committed Mar 26, 2020
2 parents d0048de + d2f510a commit c9e2a45
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -6,6 +6,7 @@ env:
global:
- ROLE_NAME: ntp
matrix:
- MOLECULE_DISTRO: centos8
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: centos6
- MOLECULE_DISTRO: ubuntu1804
Expand Down
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 @@ -35,9 +39,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
4 changes: 3 additions & 1 deletion vars/RedHat.yml
@@ -1,5 +1,7 @@
---
ntp_daemon: ntpd
ntp_daemon: chronyd
ntp_configfile: /etc/chrony.conf
ntp_package: chrony
ntp_tzdata_package: tzdata
ntp_driftfile: /var/lib/ntp/drift
ntp_cron_daemon: crond
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

0 comments on commit c9e2a45

Please sign in to comment.