summaryrefslogtreecommitdiff
path: root/puppet/modules
diff options
context:
space:
mode:
authormicah <micah@leap.se>2013-06-19 21:53:51 +0200
committermicah <micah@leap.se>2013-06-19 21:53:51 +0200
commit16b2a5593ce4ced4a21635b0638147bff250d13f (patch)
tree4f8ff484d30f76fb76470d9f6148ed844b3715f2 /puppet/modules
parentcd9f0dc7d3fed744ea9bf695a497845a7297e1ca (diff)
parentd9614163ed327fc17d27ac623dfd639ce00a43ce (diff)
Merge branch 'feature/2842' of /home/git/repositories/micah/leap_platform into develop
Diffstat (limited to 'puppet/modules')
-rw-r--r--puppet/modules/site_config/manifests/default.pp6
-rw-r--r--puppet/modules/site_config/manifests/dhclient.pp30
-rw-r--r--puppet/modules/site_config/templates/reload_dhclient.erb13
3 files changed, 48 insertions, 1 deletions
diff --git a/puppet/modules/site_config/manifests/default.pp b/puppet/modules/site_config/manifests/default.pp
index cfb46130..5518ea56 100644
--- a/puppet/modules/site_config/manifests/default.pp
+++ b/puppet/modules/site_config/manifests/default.pp
@@ -12,10 +12,14 @@ class site_config::default {
# configure apt
include site_apt
-
# configure ssh and include ssh-keys
include site_config::sshd
+ # fix dhclient from changing resolver information
+ if $::ec2_instance_id {
+ include site_config::dhclient
+ }
+
# configure /etc/resolv.conf
include site_config::resolvconf
diff --git a/puppet/modules/site_config/manifests/dhclient.pp b/puppet/modules/site_config/manifests/dhclient.pp
new file mode 100644
index 00000000..7ac0caf3
--- /dev/null
+++ b/puppet/modules/site_config/manifests/dhclient.pp
@@ -0,0 +1,30 @@
+class site_config::dhclient {
+
+ # Unfortunately, there does not seem to be a way to reload the dhclient.conf
+ # config file, or a convenient way to disable the modifications to
+ # /etc/resolv.conf. So the following makes the functions involved noops and
+ # ships a script to kill and restart dhclient. See the debian bugs:
+ # #681698, #712796
+
+ include site_config::params
+
+ file { '/usr/local/sbin/reload_dhclient':
+ owner => 0,
+ group => 0,
+ mode => '0755',
+ content => template('site_config/reload_dhclient.erb');
+ }
+
+ exec { 'reload_dhclient':
+ refreshonly => true,
+ command => '/usr/local/sbin/reload_dhclient';
+ }
+
+ file { '/etc/dhcp/dhclient-enter-hooks.d/disable_resolvconf':
+ content => 'make_resolv_conf() { : ; } ; set_hostname() { : ; }',
+ mode => '0644',
+ owner => 'root',
+ group => 'root',
+ notify => Exec['reload_dhclient'];
+ }
+}
diff --git a/puppet/modules/site_config/templates/reload_dhclient.erb b/puppet/modules/site_config/templates/reload_dhclient.erb
new file mode 100644
index 00000000..882c985a
--- /dev/null
+++ b/puppet/modules/site_config/templates/reload_dhclient.erb
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Get the PID
+PIDFILE='/var/run/dhclient.<%= scope.lookupvar('site_config::params::interface') %>.pid
+
+# Capture how dhclient is currently running so we can relaunch it
+dhclient=`/bin/ps --no-headers --pid $(cat $PIDFILE) -f | /usr/bin/awk '{for(i=8;i<=NF;++i) printf("%s ", $i) }'`
+
+# Kill the current dhclient
+/usr/bin/pkill -F $PIDFILE
+
+# Restart dhclient with the arguments it had previously
+$dhclient