Hi,

I wanted to know if there is an easy way to replace a file in puppet (using 
the file directive) but only when a certain string exists.

My use case:
I have a package that installs a config file, I want to replace that file 
with puppet, but I in normal operation the application may also write to 
that file.
So a simple replace => true is not sufficient.

I tried with something like this:
define configfile ($source) {

                $grepcommand = '/bin/grep --quiet "string to check"'
                exec { "check_${name}":
                        command => "/bin/true",
                        onlyif => "${grepcommand} ${name}",
                }

                file { "$name":
                        ensure => "present",
                        replace => "true",
                        mode => "0644",
                        owner => 'user',
                        group => 'user',
                        source => $source,
                        require => Exec["check_${name}"]
                }

        }

        configfile {"/etc/software/config.xml":
                source => "puppet:///modules/software/config.xml"
        }

I can't get that to work properly, the file is always getting replaced.

Regards,
Steven

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to