summaryrefslogtreecommitdiff
path: root/puppet/modules
diff options
context:
space:
mode:
authorkwadronaut <kwadronaut@leap.se>2017-05-23 16:20:26 +0200
committerkwadronaut <kwadronaut@leap.se>2017-05-23 16:20:55 +0200
commit0e09968d8ed3f245a238306de43a037d0749fd5a (patch)
tree165d49dfb17d115dbb649ffe669064f2042bb527 /puppet/modules
parent26be1f84de9efabf5fec1278401ae0c5538454d9 (diff)
parent40f7b49003594a1be8c0540a92292d7cfb63eb61 (diff)
Merge branch 'varac/platform-vagrant_private_networking'
Diffstat (limited to 'puppet/modules')
-rw-r--r--puppet/modules/site_config/lib/facter/vagrant.rb8
-rw-r--r--puppet/modules/site_config/manifests/params.pp13
-rw-r--r--puppet/modules/site_config/manifests/setup.pp2
-rw-r--r--puppet/modules/site_config/manifests/vagrant.pp14
4 files changed, 29 insertions, 8 deletions
diff --git a/puppet/modules/site_config/lib/facter/vagrant.rb b/puppet/modules/site_config/lib/facter/vagrant.rb
new file mode 100644
index 00000000..29a218dd
--- /dev/null
+++ b/puppet/modules/site_config/lib/facter/vagrant.rb
@@ -0,0 +1,8 @@
+# Checks if systems runs inside vagrant
+require 'facter'
+
+Facter.add(:vagrant) do
+ setcode do
+ FileTest.exists?('/vagrant')
+ end
+end
diff --git a/puppet/modules/site_config/manifests/params.pp b/puppet/modules/site_config/manifests/params.pp
index 012b3ce0..4627515a 100644
--- a/puppet/modules/site_config/manifests/params.pp
+++ b/puppet/modules/site_config/manifests/params.pp
@@ -1,3 +1,4 @@
+# Default parameters
class site_config::params {
$ip_address = hiera('ip_address')
@@ -6,8 +7,16 @@ class site_config::params {
$environment = hiera('environment', undef)
- if $environment == 'local' {
- $interface = 'eth1'
+ if $::vagrant {
+ # Depending on the backend hypervisor networking is setup differently.
+ if $::interfaces =~ /eth1/ {
+ # Virtualbox: Private networking creates a second interface eth1
+ $interface = 'eth1'
+ }
+ else {
+ # KVM/Libvirt: Private networking is done by defauly on first interface
+ $interface = 'eth0'
+ }
include site_config::packages::build_essential
}
elsif hiera('interface','') != '' {
diff --git a/puppet/modules/site_config/manifests/setup.pp b/puppet/modules/site_config/manifests/setup.pp
index 82dfe76d..a96f87a6 100644
--- a/puppet/modules/site_config/manifests/setup.pp
+++ b/puppet/modules/site_config/manifests/setup.pp
@@ -37,7 +37,7 @@ class site_config::setup {
# we need to include shorewall::interface{eth0} in setup.pp so
# packages can be installed during main puppetrun, even before shorewall
# is configured completly
- if ( $::site_config::params::environment == 'local' ) {
+ if $::vagrant {
include site_config::vagrant
}
diff --git a/puppet/modules/site_config/manifests/vagrant.pp b/puppet/modules/site_config/manifests/vagrant.pp
index 8f50b305..1682de8b 100644
--- a/puppet/modules/site_config/manifests/vagrant.pp
+++ b/puppet/modules/site_config/manifests/vagrant.pp
@@ -1,11 +1,15 @@
+# Gets included on vagrant nodes
class site_config::vagrant {
- # class for vagrant nodes
include site_shorewall::defaults
- # eth0 on vagrant nodes is the uplink if
- shorewall::interface { 'eth0':
- zone => 'net',
- options => 'tcpflags,blacklist,nosmurfs';
+
+ if ( $::site_config::params::interface == 'eth1' ) {
+ # Don't block eth0 even if eth1 is configured, because
+ # it's vagrant's main interface to access the box
+ shorewall::interface { 'eth0':
+ zone => 'net',
+ options => 'tcpflags,blacklist,nosmurfs';
+ }
}
}