blob: 1c96d12fb9f5838e3d271980cbfe96ebaa78a75d [file] [log] [blame]
Fatih Degirmenci8457c072019-02-27 10:59:35 +00001---
2# ============LICENSE_START=======================================================
3# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# SPDX-License-Identifier: Apache-2.0
18# ============LICENSE_END=========================================================
Fatih Degirmenci5042f632019-04-29 14:15:59 -060019- name: Add the OS specific variables
20 include_vars: '{{ ansible_os_family }}.yml'
Fatih Degirmenci8457c072019-02-27 10:59:35 +000021
Fatih Degirmenci5042f632019-04-29 14:15:59 -060022- name: Remove NTP if installed
23 action: >
24 {{ ansible_pkg_mgr }} name={{ item }} state=absent update_cache=yes
25 with_items:
26 - "ntp"
27
28- name: Install Chrony
29 action: >
30 {{ ansible_pkg_mgr }} name={{ item }} state=present update_cache=yes
31 with_items:
32 - "chrony"
33
34- name: Copy the chrony.conf template file
35 template:
36 src: "chrony.conf.j2"
37 dest: "{{ chrony_config_location }}"
38 owner: "root"
39 group: "root"
40 mode: "0755"
41 become: true
42 when: idf.ntp_servers is defined
43
44- name: Restart chrony
Fatih Degirmenci8457c072019-02-27 10:59:35 +000045 service:
Fatih Degirmenci5042f632019-04-29 14:15:59 -060046 name: "{{ chrony_service_name }}"
47 state: "restarted"
48 become: true
Fatih Degirmenci8457c072019-02-27 10:59:35 +000049
Fatih Degirmenci5042f632019-04-29 14:15:59 -060050
51- name: "NTP should be synchronized"
52 shell: timedatectl | grep 'synchronized'
53 register: synchronized
54 changed_when: false
55 until: "'yes' in synchronized.stdout"
56 retries: 300
57 delay: 2
Fatih Degirmenci8457c072019-02-27 10:59:35 +000058
59# vim: set ts=2 sw=2 expandtab: