Adding LICENSE file
[genesis.git] / fuel / build / f_ntp / puppet / modules / opnfv / manifests / ntp.pp
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 # Class: Ntp
12 #
13 # Add Ntp content passed through astute.yaml into ntp.conf depending on the role
14 #
15 # Suitable yaml content:
16 # <begin>
17 # opnfv:
18 #   ntp:
19 #     controller: |
20 #      line 1
21 #      line 2
22 #    compute: |
23 #      line 1
24 #      line 2
25 # <end>
26 #
27 #
28 #
29
30 class opnfv::ntp(
31   $file='/etc/ntp.conf'
32 ) {
33
34   if $::fuel_settings['role'] {
35     if ($::fuel_settings['opnfv'] and
36     $::fuel_settings['opnfv']['ntp']) {
37       case $::fuel_settings['role'] {
38         /controller/: {
39           if $::fuel_settings['opnfv']['ntp']['controller'] {
40             $template = 'opnfv/ntp.conf.controller.erb'
41             $file_content = $::fuel_settings['opnfv']['ntp']['controller']
42           }
43         }
44         /compute/:    {
45           if $::fuel_settings['opnfv']['ntp']['compute'] {
46             $template = 'opnfv/ntp.conf.compute.erb'
47             $file_content = $::fuel_settings['opnfv']['ntp']['compute']
48           }
49         }
50       }
51     }
52   }
53
54   if $file_content {
55     package { 'ntp':
56       ensure => installed,
57     }
58
59     file { $file:
60       content => template($template),
61       notify  => Service['ntp'],
62     }
63
64     service { 'ntp':
65       ensure  => running,
66       enable  => true,
67       require => [ Package['ntp'], File[$file]]
68     }
69   }
70 }
71