Fatih Degirmenci | 8457c07 | 2019-02-27 10:59:35 +0000 | [diff] [blame] | 1 | --- |
| 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 Degirmenci | 5042f63 | 2019-04-29 14:15:59 -0600 | [diff] [blame^] | 19 | - name: Add the OS specific variables |
| 20 | include_vars: '{{ ansible_os_family }}.yml' |
Fatih Degirmenci | 8457c07 | 2019-02-27 10:59:35 +0000 | [diff] [blame] | 21 | |
Fatih Degirmenci | 5042f63 | 2019-04-29 14:15:59 -0600 | [diff] [blame^] | 22 | - 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 Degirmenci | 8457c07 | 2019-02-27 10:59:35 +0000 | [diff] [blame] | 45 | service: |
Fatih Degirmenci | 5042f63 | 2019-04-29 14:15:59 -0600 | [diff] [blame^] | 46 | name: "{{ chrony_service_name }}" |
| 47 | state: "restarted" |
| 48 | become: true |
Fatih Degirmenci | 8457c07 | 2019-02-27 10:59:35 +0000 | [diff] [blame] | 49 | |
Fatih Degirmenci | 5042f63 | 2019-04-29 14:15:59 -0600 | [diff] [blame^] | 50 | |
| 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 Degirmenci | 8457c07 | 2019-02-27 10:59:35 +0000 | [diff] [blame] | 58 | |
| 59 | # vim: set ts=2 sw=2 expandtab: |