From 1071c3622469b7b02dd3b772070db540b6842dfb Mon Sep 17 00:00:00 2001 From: Christoph Kluenter Date: Mon, 29 Sep 2014 13:53:39 +0200 Subject: new fact to check if dhcp is used; from https://github.com/gds-operations/puppet-resolvconf/blob/master/lib/facter/dhcp_enabled.rb --- .../modules/site_config/lib/facter/dhcp_enabled.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 puppet/modules/site_config/lib/facter/dhcp_enabled.rb (limited to 'puppet') diff --git a/puppet/modules/site_config/lib/facter/dhcp_enabled.rb b/puppet/modules/site_config/lib/facter/dhcp_enabled.rb new file mode 100644 index 00000000..33220da3 --- /dev/null +++ b/puppet/modules/site_config/lib/facter/dhcp_enabled.rb @@ -0,0 +1,22 @@ +require 'facter' +def dhcp_enabled?(ifs, recurse=true) + dhcp = false + included_ifs = [] + if FileTest.exists?(ifs) + File.open(ifs) do |file| + dhcp = file.enum_for(:each_line).any? do |line| + if recurse && line =~ /^\s*source\s+([^\s]+)/ + included_ifs += Dir.glob($1) + end + line =~ /inet\s+dhcp/ + end + end + end + dhcp || included_ifs.any? { |ifs| dhcp_enabled?(ifs, false) } +end +Facter.add(:dhcp_enabled) do + confine :osfamily => 'Debian' + setcode do + dhcp_enabled?('/etc/network/interfaces') + end +end -- cgit v1.2.3 From 63ca770b6913d674db639c486a8ba215ea0b7a65 Mon Sep 17 00:00:00 2001 From: Christoph Kluenter Date: Mon, 29 Sep 2014 13:57:30 +0200 Subject: configure dhclient if its used in /e/network/interfaces we don't dhclient to to set domain and search in /etc/reslov.conf bigcouch has a strange way to find its hostname. It uses the domain stanza in /etc/resolv.conf to find its domain --- puppet/modules/site_config/manifests/default.pp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'puppet') diff --git a/puppet/modules/site_config/manifests/default.pp b/puppet/modules/site_config/manifests/default.pp index fc2179de..42359a00 100644 --- a/puppet/modules/site_config/manifests/default.pp +++ b/puppet/modules/site_config/manifests/default.pp @@ -25,10 +25,7 @@ class site_config::default { # i.e. openstack/aws nodes, vagrant nodes # fix dhclient from changing resolver information - if $::ec2_instance_id { - include site_config::dhclient - } - if $::virtual == 'virtualbox' { + if $::dhcp_enabled == 'true' { include site_config::dhclient } -- cgit v1.2.3 From 664dca31dec0c7935ee96359209d9dcefc03e38c Mon Sep 17 00:00:00 2001 From: Christoph Kluenter Date: Mon, 29 Sep 2014 14:31:54 +0200 Subject: ensure dhclicent and resolv.conf are configured before bigcouch --- puppet/modules/site_config/manifests/dhclient.pp | 4 +++- puppet/modules/site_couchdb/manifests/bigcouch.pp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'puppet') diff --git a/puppet/modules/site_config/manifests/dhclient.pp b/puppet/modules/site_config/manifests/dhclient.pp index 7ac0caf3..dbe2ef1c 100644 --- a/puppet/modules/site_config/manifests/dhclient.pp +++ b/puppet/modules/site_config/manifests/dhclient.pp @@ -17,7 +17,9 @@ class site_config::dhclient { exec { 'reload_dhclient': refreshonly => true, - command => '/usr/local/sbin/reload_dhclient'; + command => '/usr/local/sbin/reload_dhclient', + before => Class['site_config::resolvconf'], + require => File['/usr/local/sbin/reload_dhclient'], } file { '/etc/dhcp/dhclient-enter-hooks.d/disable_resolvconf': diff --git a/puppet/modules/site_couchdb/manifests/bigcouch.pp b/puppet/modules/site_couchdb/manifests/bigcouch.pp index f0aab734..d3352000 100644 --- a/puppet/modules/site_couchdb/manifests/bigcouch.pp +++ b/puppet/modules/site_couchdb/manifests/bigcouch.pp @@ -17,6 +17,7 @@ class site_couchdb::bigcouch { # stunnel must running correctly before bigcouch dbs can be set up. # Class['site_config::default'] + -> Class['site_config::resolvconf'] -> Class['couchdb::bigcouch::package::cloudant'] -> Service['shorewall'] -> Service['stunnel'] -- cgit v1.2.3