Skip to content

Commit

Permalink
Replace ntpd by chronyd
Browse files Browse the repository at this point in the history
ntpd is now deprecated
  • Loading branch information
jubarbot-cisco committed Sep 18, 2018
1 parent b58132c commit c54d072
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 94 deletions.
4 changes: 0 additions & 4 deletions pillar/packages/CentOS.sls
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ nmap-ncat:
nss-pam-ldapd:
package-name: nss-pam-ldapd
version: ""
ntp:
package-name: ntp
version: ""
service_name: ntpd
openldap-clients:
package-name: openldap-clients
version: ""
Expand Down
4 changes: 0 additions & 4 deletions pillar/packages/RedHat.sls
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ nmap-ncat:
nss-pam-ldapd:
package-name: nss-pam-ldapd
version: ""
ntp:
package-name: ntp
version: ""
service_name: ntpd
openldap-clients:
package-name: openldap-clients
version: ""
Expand Down
4 changes: 0 additions & 4 deletions salt/ntp/files/ntpdate.sh

This file was deleted.

33 changes: 10 additions & 23 deletions salt/ntp/init.sls
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
{% set ntp_servers = salt['pillar.get']('ntp:servers', []) %}
{% set timezone = salt['pillar.get']('ntp:timezone', 'UTC') %}
{% set ntp_service = pillar['ntp']['service_name'] %}

ntp-set_timezone:
timezone.system:
- name: {{ timezone }}

ntp-install_ntp_package:
pkg.installed:
- name: {{ pillar['ntp']['package-name'] }}
- version: {{ pillar['ntp']['version'] }}
- name: chrony
- ignore_epoch: True

ntp-install_conf:
file.managed:
- name: /etc/ntp.conf
- source: salt://ntp/templates/ntp.conf.tpl
- name: /etc/chrony.conf
- source: salt://ntp/templates/chrony.conf.tpl
- template: jinja
- context:
ntp_servers: {{ ntp_servers }}

ntp-ntpdate_sync_on_boot_script:
file.managed:
- name: /etc/ntpdate.sh
- source: salt://ntp/files/ntpdate.sh
- mode: 0755
- template: jinja
- context:
ntp_service: {{ ntp_service }}
ntp_servers: {{ ntp_servers }}

ntp-systemctl_reload:
cmd.run:
- name: /bin/systemctl daemon-reload; /bin/systemctl enable {{ ntp_service }}; /bin/systemctl stop chronyd; /bin/systemctl disable chronyd; /bin/systemctl enable ntpdate;

ntp-ntpdate-sync:
cmd.run:
- name: '/etc/ntpdate.sh'

ntp-enable_chronyd:
service.running:
- name: chronyd
- enable: True
- watch:
- pkg: ntp-install_ntp_package
- file: ntp-install_conf
42 changes: 42 additions & 0 deletions salt/ntp/templates/chrony.conf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

{% for ntp_server in ntp_servers -%}
server {{ ntp_server }}
{% endfor %}

# 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
59 changes: 0 additions & 59 deletions salt/ntp/templates/ntp.conf.tpl

This file was deleted.

0 comments on commit c54d072

Please sign in to comment.