diff --git a/files/chrony/chrony.conf.j2 b/files/chrony/chrony.conf.j2 new file mode 100644 index 0000000..1bf112c --- /dev/null +++ b/files/chrony/chrony.conf.j2 @@ -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 \ No newline at end of file diff --git a/inst-raps.sh b/inst-raps.sh index 3d4dcda..fb1444a 100755 --- a/inst-raps.sh +++ b/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 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 #----------------------------------------------------------------------------- @@ -147,6 +139,14 @@ if [ ! -f "/root/ansible/.vault_pass.txt" ]; then fi 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 #----------------------------------------------------------------------------- diff --git a/playbook-chrony.yml b/playbook-chrony.yml new file mode 100644 index 0000000..5b867d0 --- /dev/null +++ b/playbook-chrony.yml @@ -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