Skip to content

Instantly share code, notes, and snippets.

@roidelapluie
Created November 15, 2012 08:29
Show Gist options
  • Save roidelapluie/4077387 to your computer and use it in GitHub Desktop.
Save roidelapluie/4077387 to your computer and use it in GitHub Desktop.
file {
'initial-config':
path => "${config_file}.bak",
source => "${config_file}",
replace => no,
}
exec {
'rm config':
command => "rm ${initial-config}",
subscribe => File['initial-config'],
refreshonly => true,
}
file {
"init_config":
path => "${config_file}",
require => Exec['rm config'],
replace => no,
content => template("${module_name}/foobar.erb")
}
@vStone
Copy link

vStone commented Nov 15, 2012

define stupidfile(
  $name,
  $path = $name,
  $content = undef
) {
  file {$name:
    ensure  => 'present',
    path    => $path,
    replace => false,
    content => $content,
    require => Exec['rm initial file'],
  }
  exec {"rm_initial_${name}":
    creates => "${path}.lck",
    command => "rm ${path}; echo 'THIS FILE PREVENTS PUPPET FROM OVERWRITING ${path}' >  ${path}.lck",
    path    => ['/bin','/usr/bin'],
  }
}

@vStone
Copy link

vStone commented Nov 15, 2012

There obviously is an error in what I wrote :) the require => Exec['THIS IS WRONG'] ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment