Adding LICENSE file
[genesis.git] / fuel / build / f_resolvconf / puppet / modules / opnfv / manifests / resolver.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: opnfv::resolver
12 #
13 # Add resolver content passed through astute.yaml into resolv.conf
14 # depending on the role
15 #
16 # Suitable yaml content:
17 # <begin>
18 # opnfv:
19 #  dns:
20 #    compute:
21 #    - 100.100.100.2
22 #    - 100.100.100.3
23 #    controller:
24 #    - 100.100.100.102
25 #    - 100.100.100.104
26 # <end>
27 #
28 #
29 #
30
31 class opnfv::resolver()
32 {
33   if $::fuel_settings['role'] {
34     if $::fuel_settings['role']  == 'primary-controller' {
35       $role = 'controller'
36     } else {
37       $role = $::fuel_settings['role']
38     }
39
40     if ($::fuel_settings['opnfv']
41         and $::fuel_settings['opnfv']['dns']
42         and $::fuel_settings['opnfv']['dns'][$role]) {
43       $nameservers=$::fuel_settings['opnfv']['dns'][$role]
44
45       file { '/etc/resolv.conf':
46             owner   => root,
47             group   => root,
48             mode    => '0644',
49             content => template('opnfv/resolv.conf.erb'),
50       }
51 # /etc/resolv.conf is re-generated at each boot by resolvconf, so we
52 # need to store there as well.
53       file { '/etc/resolvconf/resolv.conf.d/head':
54             owner   => root,
55             group   => root,
56             mode    => '0644',
57             content => template('opnfv/resolv.conf.erb'),
58       }
59     }
60   }
61 }
62
63