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

Add support for HWCLOCK sync when configuring ntp.ng #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ntp/ng/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,22 @@ ntpd:
- watch:
- file: ntpd_conf
{% endif %}

{#% if 'defaults' in ntp.lookup %#}
ntpd_defaults:
file.managed:
- name: {{ ntp.lookup.defaults }}
- user: root
- group: root
- mode: 0664
- contents: |
# Options for ntpdate
OPTIONS="{{ ntp.service.options }}"

# Number of retries before giving up
RETRIES={{ ntp.service.retries }}

# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK={{ ntp.service.sync_hwclock }}

{#% endif %#}
14 changes: 11 additions & 3 deletions ntp/ng/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
'RedHat': {
'package': 'ntp',
'service': 'ntpd',
'ntp_conf': '/etc/ntp.conf'
'ntp_conf': '/etc/ntp.conf',
'defaults': '/etc/sysconfig/ntpdate'
},
'Suse': {
'package': 'ntp',
Expand All @@ -40,6 +41,13 @@
'restrict': ['default noquery nopeer', '127.0.0.1', '::1'],
'driftfile': [ default_driftfile ]
}
}),
'service': { 'options': '-p 2',
'retries': '2',
'sync_hwclock': 'no',
}

}
%}

})
} %}
{% do ntp.service.update( salt['pillar.get']('ntp:ng:service', {})) %}
7 changes: 7 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ ntp:
ng:
# OS-specific data that should, in most cases, be handled by map.jinja.
# It is an optional key and is only used to override defaults.
service:
# overrides daemon startup options
options: -p 2
retries: 2
sync_hwclock: False
lookup:
package: ntp
service: ntpd
provider: systemd
ntp_conf: /etc/ntp.conf
# State-specific options
settings:
# if `yes`, set flags to update the hardware after sync
sync_hwclock: no
# If `True`, ntpd will be enabled. Otherwise ntp.conf will be configured
# but ntpd will not be enabled or started.
ntpd: True
Expand Down