Fix resolver for EL7 systems
[releng/builder.git] / vagrant / lf-networking / confignetwork.pp
1 # make system modifications to handle being on a private Rackspace network
2
3 # lint:ignore:80chars
4 notice ("Operating system detected is: '${::operatingsystem} ${::operatingsystemrelease}'")
5 # lint:endignore
6 notice ("Subdomain being used is: '${::subdomain}'")
7
8 # configure nameservers for domains
9 case $::subdomain {
10   /^dfw\./: {
11     $ns1 = '72.3.128.241'
12     $ns2 = '72.3.128.240'
13     case $::subdomain {
14       /opendaylight/: {
15         $router = '10.30.11.1'
16       }
17       /odlforge/: {
18         $router = '10.30.12.1'
19       }
20       default: {
21         fail("Unrecognized subdomain ${::subdomain}")
22       }
23     }
24   }
25   /^ord\./: {
26     $ns1 = '173.203.4.9'
27     $ns2 = '173.203.4.8'
28     $router = '10.30.32.1'
29   }
30   default: {
31     fail("Unrecognized subdomain ${::subdomain}")
32   }
33 }
34
35 # dnsmasq
36 class { 'dnsmasq': }
37
38 # Setup dnsmasq special domain handlers
39 dnsmasq::conf { 'LF-ns1':
40   ensure  => present,
41   content => 'server=/linux-foundation.org/172.17.192.30',
42 }
43
44 dnsmasq::conf { 'LF-ns2':
45   ensure  => present,
46   content => 'server=/linux-foundation.org/172.17.192.31',
47 }
48
49 dnsmasq::conf { 'ODL-ns1':
50   ensure  => present,
51   content => 'server=/opendaylight.org/172.17.192.30',
52 }
53
54 dnsmasq::conf { 'ODL-ns2':
55   ensure  => present,
56   content => 'server=/opendaylight.org/172.17.192.31',
57 }
58
59 dnsmasq::conf { 'ODLForge-ns1':
60   ensure  => present,
61   content => 'server=/odlforge.org/172.17.192.30',
62 }
63
64 dnsmasq::conf { 'ODLForge-ns2':
65   ensure  => present,
66   content => 'server=/odlforge.org/172.17.192.31',
67 }
68
69 # fix the resolver
70 file { '/etc/resolv.conf':
71   content => "search ${::subdomain}
72 nameserver 127.0.0.1
73 nameserver ${ns1}
74 nameserver ${ns2}
75 options timeout:2
76 ",
77 }
78
79 file { '/etc/cloud/cloud.cfg.d/00_lf_resolv.cfg':
80   content => "#cloud-config
81
82 manage_resolv_conf: true
83
84 resolv_conf:
85   nameservers: ['127.0.0.1', '${ns1}', '${ns2}']
86   searchdomains:
87     - ${::subdomain}
88   options:
89     timeout: 2
90 ",
91 }
92
93 file_line { 'add_resolver':
94   path  => '/etc/cloud/cloud.cfg.d/10_rackspace.cfg',
95   line  => ' - resolv_conf',
96   after => ' - update_etc_hosts',
97 }
98
99 # OS specific configuration
100 case $::operatingsystem {
101   'CentOS', 'Fedora', 'RedHat': {
102     file { '/etc/sysconfig/network-scripts/route-eth0':
103       content => "default via ${router} dev eth0",
104     }
105
106     # disable the DNS peerage so that our resolv.conf doesn't
107     # get destroyed
108     file_line { 'disable_peerdns':
109       path => '/etc/sysconfig/network',
110       line => 'PEERDNS=no',
111     }
112   }
113   'Ubuntu': {
114     file { '/etc/network/if-up.d/0000routing':
115       content => "#!/bin/sh\nip route add default via ${router} dev eth0",
116       mode    => '0755',
117     }
118   }
119   default: {
120     notice ("${::operatingsystem} is not supported by this configuration")
121   }
122 }