From 9fac9f95ba1eb2e70aa47c02132058a4fea3dd8e Mon Sep 17 00:00:00 2001 From: Michael Chapman Date: Thu, 28 Mar 2013 04:37:59 +0000 Subject: [PATCH 1/2] Remove puppet-network and dependencies, move networking definition into the preseed late command to get a 'free' reboot and use templating to support bonding and other advanced configuration. https://bugs.launchpad.net/openstack-cisco/folsom/+bug/1159597 --- manifests/cobbler-node.pp | 26 ++++++++++++---- manifests/core.pp | 62 --------------------------------------- manifests/modules.list | 3 -- templates/interfaces.erb | 15 ++++++++++ 4 files changed, 35 insertions(+), 71 deletions(-) create mode 100644 templates/interfaces.erb diff --git a/manifests/cobbler-node.pp b/manifests/cobbler-node.pp index 4ed5911..6fac5ae 100644 --- a/manifests/cobbler-node.pp +++ b/manifests/cobbler-node.pp @@ -8,18 +8,32 @@ ####### Shared Variables from Site.pp ####### $cobbler_node_fqdn = "${::build_node_name}.${::domain_name}" +# Be aware this template will not know the address of the machine for which it's writing an interface file. It's a 'feature'. +# The subst puts it all on one line, which makes the .ini file happy. +# Shell interpolation will happen to its contents. +$interfaces_file=regsubst(template("interfaces.erb"), '$', "\\n\\", "G") + ####### Preseed File Configuration ####### cobbler::ubuntu::preseed { "cisco-preseed": admin_user => $::admin_user, password_crypted => $::password_crypted, packages => "openssh-server vim vlan lvm2 ntp puppet", ntp_server => $::build_node_fqdn, - late_command => "sed -e '/logdir/ a pluginsync=true' -i /target/etc/puppet/puppet.conf ; \ - sed -e \"/logdir/ a server=$cobbler_node_fqdn\" -i /target/etc/puppet/puppet.conf ; \ - echo -e \"server $cobbler_node_fqdn iburst\" > /target/etc/ntp.conf ; \ - echo '8021q' >> /target/etc/modules ; \ - true - ", + + late_command => sprintf(' +sed -e "/logdir/ a pluginsync=true" -i /target/etc/puppet/puppet.conf ; \ +sed -e "/logdir/ a runinterval=300" -i /target/etc/puppet/puppet.conf ; \ +sed -e "/logdir/ a server=%s" -i /target/etc/puppet/puppet.conf ; \ +in-target /usr/sbin/ntpdate %s ; in-target /sbin/hwclock --systohc ; \ +sed -e "s/START=no/START=yes/" -i /target/etc/default/puppet ; \ +echo "8021q" >> /target/etc/modules ; \ +echo "bonding" >> /target/etc/modules ; \ +ifconf="`tail +11 /target/etc/network/interfaces ; \ +true +', $::cobbler_node_fqdn, $::cobbler_node_fqdn, $interfaces_file), + proxy => "http://${cobbler_node_fqdn}:3142/", expert_disk => true, diskpart => [$::install_drive], diff --git a/manifests/core.pp b/manifests/core.pp index 84f22f2..670d3b1 100644 --- a/manifests/core.pp +++ b/manifests/core.pp @@ -208,68 +208,6 @@ dhcp_use_namespaces => "True", } -# Needed to ensure a proper "second" interface is online -# This same module may be useable for forcing bonded interfaces as well - - if $::node_gateway { - network_config { "$::private_interface": - ensure => 'present', - hotplug => false, - family => 'inet', - ipaddress => "$::controller_node_address", - method => 'static', - netmask => "$::node_netmask", - options => { - "dns-search" => "$::domain_name", - "dns-nameservers" => "$::cobbler_node_ip", - "gateway" => "$::node_gateway" - }, - onboot => 'true', - notify => Exec['networking-restart'], - } - } else { - network_config { "$::private_interface": - ensure => 'present', - hotplug => false, - family => 'inet', - ipaddress => "$::controller_node_address", - method => 'static', - netmask => "$::node_netmask", - options => { - "dns-search" => "$::domain_name", - "dns-nameservers" => "$::cobbler_node_ip", - }, - onboot => 'true', - notify => Exec['networking-restart'], - } - } - - network_config { 'lo': - ensure => 'present', - hotplug => false, - family => 'inet', - method => 'loopback', - onboot => 'true', - notify => Exec['networking-restart'], - } - - network_config { "$::external_interface": - ensure => 'present', - hotplug => false, - family => 'inet', - method => 'static', - ipaddress => '0.0.0.0', - netmask => '255.255.255.255', - onboot => 'true', - notify => Exec['networking-restart'], - } - - exec {'networking-restart': - command => '/etc/init.d/networking restart', - path => '/usr/bin:/usr/sbin:/bin/sbin', - refreshonly => true, - } - class { "naginator::control_target": } diff --git a/manifests/modules.list b/manifests/modules.list index 8eba2b5..49da41b 100644 --- a/manifests/modules.list +++ b/manifests/modules.list @@ -31,6 +31,3 @@ swift sysctl vswitch xinetd -network -filemapper -boolean diff --git a/templates/interfaces.erb b/templates/interfaces.erb new file mode 100644 index 0000000..1186a7e --- /dev/null +++ b/templates/interfaces.erb @@ -0,0 +1,15 @@ +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +auto <%= public_interface %> +iface <%= public_interface %> inet static +$ifconf + +auto <%= external_interface %> +iface <%= external_interface %> inet static + address 0.0.0.0 + netmask 255.255.255.255 From 4b6907cd832f5f644ce1bb488e0a658620d05a1c Mon Sep 17 00:00:00 2001 From: Michael Chapman Date: Thu, 28 Mar 2013 06:13:16 +0000 Subject: [PATCH 2/2] build_node_fqdn doesn't exist, and cobbler_node_fqdn had the wrong scope, leading to empty strings in the preseed. --- manifests/cobbler-node.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/cobbler-node.pp b/manifests/cobbler-node.pp index 6fac5ae..0684d1d 100644 --- a/manifests/cobbler-node.pp +++ b/manifests/cobbler-node.pp @@ -18,7 +18,7 @@ admin_user => $::admin_user, password_crypted => $::password_crypted, packages => "openssh-server vim vlan lvm2 ntp puppet", - ntp_server => $::build_node_fqdn, + ntp_server => $cobbler_node_fqdn, late_command => sprintf(' sed -e "/logdir/ a pluginsync=true" -i /target/etc/puppet/puppet.conf ; \ @@ -32,7 +32,7 @@ echo -e "%s " > /target/etc/network/interfaces ; \ true -', $::cobbler_node_fqdn, $::cobbler_node_fqdn, $interfaces_file), +', $cobbler_node_fqdn, $cobbler_node_fqdn, $interfaces_file), proxy => "http://${cobbler_node_fqdn}:3142/", expert_disk => true,