Skip to content

Instantly share code, notes, and snippets.

@ciastek
Created March 13, 2012 13:35
Show Gist options
  • Save ciastek/2028806 to your computer and use it in GitHub Desktop.
Save ciastek/2028806 to your computer and use it in GitHub Desktop.
vagrant lucid32 restart networking
# ./Vagrantfile
Vagrant::Config.run do |config|
# (...)
config.vm.provision :puppet
# (...)
end
# ./manifests/default.pp
include lucid
class lucid {
# group 'puppet' required by default vagrant's puppet, but absent in lucid32 box
group { 'puppet':
ensure => present,
}
# another lucid32 bug - ssh connects only at initial boot. workaround:
file { "/etc/rc.local":
ensure => present,
}
line { restart_networking:
file => "/etc/rc.local",
line => "/etc/init.d/networking restart",
ensure => present,
insert_before => "^exit 0$",
}
define line($file, $line, $ensure = 'present', $insert_before = '') {
case $ensure {
default : { err ( "unknown ensure value ${ensure}" ) }
present: {
if $insert_before == '' {
exec { "/bin/echo '${line}' >> '${file}'":
unless => "/bin/grep -qFx '${line}' '${file}'"
}
}
# don't know what happens, if ${insert_before} is not found in ${file}
else {
exec { "/bin/sed -i '\\|${insert_before}|i ${line}' ${file}":
unless => "/bin/grep -qFx '${line}' '${file}'"
}
}
}
absent: {
exec { "/bin/grep -vFx '${line}' '${file}' | /usr/bin/tee '${file}' > /dev/null 2>&1":
onlyif => "/bin/grep -qFx '${line}' '${file}'"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment