Copy files after Apache install...but only once.

735 views
Skip to first unread message

pskov...@gmail.com

unread,
Jan 30, 2014, 11:22:59 AM1/30/14
to puppet...@googlegroups.com
Hi,

I am trying to install Apache with a default set of config files. I have the following class:

class base_apache {

    case $operatingsystem {
        windows: {
            file { 'apache_installer_package':
                path            => 'D:/Downloads/Puppet/',
                ensure          => directory,
                source          => 'puppet:///files/Apache-Installers/',
                recurse         => true,
                purge           => false,
                source_permissions => ignore,
                replace         => no,
                before          => Package['Apache HTTP Server 2.2.25']
            }

            package { 'Apache HTTP Server 2.2.25':
                ensure          => installed,
                source          => 'D:\\Downloads\\Puppet\\httpd-2.2.25-win32-x86-openssl-0.9.8y.msi',
                install_options => {'INSTALLDIR' => 'D:\Apache2.2','SERVICENAME' => 'Apache.2.2','ALLUSERS' => 1},
                before          => File['default_apache_config']
            }

            file { 'default_apache_config':
                path            => "D:/Apache2.2/conf",
                ensure          => directory,
                source          => 'puppet:///files/Apache2.2/conf',
                recurse         => true,
                purge           => true,
                source_permissions => ignore,
                replace         => yes,
            }
        }
    }
}

As you can see, I am installing Apache using MSI package and then copying over the default set of configs. This works, however.... If I make a modification to the config files, Puppet will notice that it has changed and overwrite it on the next run. 

What I want it to do if copy the files ONLY IF the "package" directive had to install Apache. If it already existed on the server and it didn't do anything, don't do the File['default_apache_config'] bit... I could set replace => no but then it wouldn't work on the first one run either as the installer creates its own default set of configs.

Is this possible or do I have to be a bit cleverer than that?

Thanks
Alex

jcbollinger

unread,
Jan 31, 2014, 9:41:58 AM1/31/14
to puppet...@googlegroups.com


Puppet manifests do not model processes, they model target state.  Generally speaking, therefore, you cannot easily tell Puppet to perform some action only if it has done / plans to do some other action -- actions are not a subject that can even be expressed in the DSL.

Puppet does have the concept of 'refreshing' a resource when another has been modified in the same run, but only in the case of Execs is that paired with the possibility of not managing the resource under other circumstances.

You could consider building a custom Apache installer package that has your desired starting configs already baked in.  Or perhaps you could put the alternative configs in their own installer, and manage them as a Package.


John

Louis Coilliot

unread,
Feb 1, 2014, 3:23:25 AM2/1/14
to puppet...@googlegroups.com
Hello,

for a an individual config file you can :

1° delete the file unless there is a special tag line in it
2° then ensure the file with replace = false

Example here :
https://github.com/lofic/puppet-jboss7/blob/master/templates/domain.xml.jboss-as-7.1.1#L35
https://github.com/lofic/puppet-jboss7/blob/master/manifests/init.pp#L99-L104
https://github.com/lofic/puppet-jboss7/blob/master/manifests/domain.pp#L47-L56

Louis






2014-01-31 jcbollinger <John.Bo...@stjude.org>:

--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ab072a71-6f47-4418-8216-402ab0fda4a3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

pskov...@gmail.com

unread,
Feb 2, 2014, 7:44:19 AM2/2/14
to puppet...@googlegroups.com, louis.c...@think.fr
Thanks John and Louis. That's what I was thinking as well. I went in a slightly different direction - I check whether a package is installed and then execute the package and file bits if not

Alex
Reply all
Reply to author
Forward
0 new messages