install chrony
This commit is contained in:
parent
b1eaf8d809
commit
e6b2e7872a
42
files/chrony/chrony.conf.j2
Normal file
42
files/chrony/chrony.conf.j2
Normal file
@ -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).
|
||||||
|
#pool 2.pool.ntp.org iburst
|
||||||
|
server 0.ch.pool.ntp.org
|
||||||
|
server 1.ch.pool.ntp.org
|
||||||
|
server 2.ch.pool.ntp.org
|
||||||
|
server 3.ch.pool.ntp.org
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Get TAI-UTC offset and leap seconds from the system tz database.
|
||||||
|
leapsectz right/UTC
|
||||||
|
|
||||||
|
# Specify directory for log files.
|
||||||
|
logdir /var/log/chrony
|
||||||
|
|
||||||
|
# Select which information is logged.
|
||||||
|
#log measurements statistics tracking
|
||||||
16
inst-raps.sh
16
inst-raps.sh
@ -129,14 +129,6 @@ echo "export PATH=~/.local/bin:\$PATH" >> ~/.bashrc
|
|||||||
if [ $? -ne 0 ]; then printError "Problem to install ansible";exit; fi
|
if [ $? -ne 0 ]; then printError "Problem to install ansible";exit; fi
|
||||||
printSuccess "./.local/bin added in path successfully "
|
printSuccess "./.local/bin added in path successfully "
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# update date and time
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
printInfo "Update date and time"
|
|
||||||
chronyc -a makestep
|
|
||||||
if [ $? -ne 0 ]; then printError "Problem to update date and time";exit; fi
|
|
||||||
printSuccess "Date and Time updated successfully"
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# check /root/ansible/.vault_pass.txt exits
|
# check /root/ansible/.vault_pass.txt exits
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@ -147,6 +139,14 @@ if [ ! -f "/root/ansible/.vault_pass.txt" ]; then
|
|||||||
fi
|
fi
|
||||||
printSuccess "/root/ansible/.vault_pass.txt exist"
|
printSuccess "/root/ansible/.vault_pass.txt exist"
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# update date and time
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
printInfo "Update date and time"
|
||||||
|
~/.local/bin/ansible-playbook playbook-chrony.yml
|
||||||
|
if [ $? -ne 0 ]; then printError "Problem to update date and time";exit; fi
|
||||||
|
printSuccess "Date and Time updated successfully"
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# execute playbook
|
# execute playbook
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|||||||
25
playbook-chrony.yml
Normal file
25
playbook-chrony.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: install chrony
|
||||||
|
yum:
|
||||||
|
name: chrony
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: config time server
|
||||||
|
template:
|
||||||
|
src: chrony/chrony.conf.j2
|
||||||
|
dest: /etc/chrony.conf
|
||||||
|
|
||||||
|
- name: disable chrony ipv6
|
||||||
|
replace:
|
||||||
|
path: /etc/sysconfig/chronyd
|
||||||
|
regexp: '^OPTIONS=""'
|
||||||
|
replace: 'OPTIONS="-4"'
|
||||||
|
|
||||||
|
- name: start and active service chronyd
|
||||||
|
systemd:
|
||||||
|
name: chronyd
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
Loading…
x
Reference in New Issue
Block a user