From a2ea6270efc928dfb062cb32065162df4396b6a4 Mon Sep 17 00:00:00 2001 From: "carey.xu" Date: Mon, 21 Sep 2015 17:06:32 +0800 Subject: ntp configure bugfix JIRA: COMPASS-68 Change-Id: I0ff0d382bbd9c6931cabe764f83343cfc1dbcafe Signed-off-by: carey.xu --- deploy/adapters/ansible/roles/common/tasks/main.yml | 15 +++++++++++---- deploy/adapters/ansible/roles/common/templates/ntp.conf | 16 +++++++--------- .../roles/setup-network/files/setup_networks/net_init | 2 +- .../adapters/ansible/roles/setup-network/tasks/main.yml | 3 +-- 4 files changed, 20 insertions(+), 16 deletions(-) (limited to 'deploy/adapters/ansible') diff --git a/deploy/adapters/ansible/roles/common/tasks/main.yml b/deploy/adapters/ansible/roles/common/tasks/main.yml index b58bb44d..ead70aed 100644 --- a/deploy/adapters/ansible/roles/common/tasks/main.yml +++ b/deploy/adapters/ansible/roles/common/tasks/main.yml @@ -36,13 +36,20 @@ - name: update pip.conf template: src=pip.conf dest=~/.pip/pip.conf -- name: sync between sys clock and hard clock - command: su -s /bin/sh -c "service {{ ntp_service }} stop; ntpd -gq; hwclock --systohc" - ignore_errors: True - - name: update ntp conf template: src=ntp.conf dest=/etc/ntp.conf backup=yes +- name: stop ntp + service: name={{ ntp_service }} state=stopped enabled=yes + +- name: use ntpdate once for initial sync time + shell: ntpdate {{ ntp_server }} + ignore_errors: True + +- name: sync sys clock to hard clock + shell: hwclock --systohc + ignore_errors: True + - name: restart ntp service: name={{ ntp_service }} state=restarted enabled=yes diff --git a/deploy/adapters/ansible/roles/common/templates/ntp.conf b/deploy/adapters/ansible/roles/common/templates/ntp.conf index c6138092..2d560be2 100644 --- a/deploy/adapters/ansible/roles/common/templates/ntp.conf +++ b/deploy/adapters/ansible/roles/common/templates/ntp.conf @@ -16,14 +16,12 @@ filegen clockstats file clockstats type day enable # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for # more information. -server {{ NTP_SERVER_LOCAL }} -server 0.ubuntu.pool.ntp.org -server 1.ubuntu.pool.ntp.org -server 2.ubuntu.pool.ntp.org -server 3.ubuntu.pool.ntp.org +server {{ ntp_server }} +server {{ internal_vip.ip }} -# Use Ubuntu's ntp server as a fallback. -server ntp.ubuntu.com +# Use local server as a fallback. +server 127.127.1.0 # local clock +fudge 127.127.1.0 stratum 10 # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page @@ -34,8 +32,8 @@ server ntp.ubuntu.com # up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration. -restrict -4 default kod notrap nomodify nopeer noquery -restrict -6 default kod notrap nomodify nopeer noquery +restrict -4 default kod notrap nomodify +restrict -6 default kod notrap nomodify # Local users may interrogate the ntp server more closely. restrict 127.0.0.1 diff --git a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/net_init b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/net_init index a74a0065..c27a8bf8 100755 --- a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/net_init +++ b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/net_init @@ -12,7 +12,7 @@ # # anamon.init: Starts the cobbler post-install boot notification program # -# chkconfig: 35 95 95 +# chkconfig: 35 0 6 # # description: anamon runs the first time a machine is booted after # installation. diff --git a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml index 689e6e3d..8667a9b1 100644 --- a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml +++ b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml @@ -41,5 +41,4 @@ shell: python /opt/setup_networks/setup_networks.py - name: add to boot scripts - shell: update-rc.d net_init defaults 0 6 - when: ansible_os_family == "Debian" + service: name=net_init enabled=yes -- cgit 1.2.3-korg