centos - Overwrite if if it exists or create if it does not -


i trying rewrite file using puppet following function.

if file exists still want file rewrite source. achieved following method?

define setup_sysctl_conf( $dependence=file[$dummy_dependence_file] )   {         file { $name:          path    => '/etc/sysctl.conf',                  ensure  => present,          mode    => 0777,          source  => '/vagrant/files/sysctl.conf',          require => $dependence,       }    } 

the file: /etc/sysctl.conf present on host (created initscripts package).

i recommend modify existing files puppet using augeas instead of replacing them.

example (changes net.ipv4.ip_forward 1):

class sysctl_augeas_example {   augeas{"set net.ipv4.ip_forward 1":     context   => "/files",     changes   => [       "set etc/sysctl.conf/net.ipv4.ip_forward 1",     ]   } } include sysctl_augeas_example 

save example test.pp , run puppet apply test.pp


Comments