Re: [Puppet Users] Deployed but unmanaged file

Daniel Piddock
Wed, 29 Jun 2011 15:57:58 -0000

On 29/06/11 16:34, Craig White wrote:
> This seems to work but it does seem perilous and ugly. A meta description
of what I am trying to do is:
> - install firebird sql server
> - replace the ''security'' file with a known file
> - restart the firebird service
>
> I''m not going to include firebird::install class because the part
that worries me is that I can''t work on
/var/lib/firebird/2.1/system/security.fdb directly because we will want to
maintain it locally after installation. I only want a single shot deploy. So I
am linking to /root/security.fdb and then copying it from there to it''s
home. I suppose there is a much better way to do this but I haven''t
found it.
>
> My worry is that I never actually overwrite
/var/lib/firebird/2.1/system/security.fdb after the initial install/configure
phase is completed.
>
> class firebird::configure {
>   file {"/root/security.fdb":
>     source => "puppet:///modules/firebird/security.fdb",
>     owner    => root,
>     group    => root,
>     mode     => 640,
>     replace  => false,
>   }
>   exec { "Copy KNOWN security.fdb into position":
>     path        =>
"/usr/local/bin:/usr/local/sbin:/bin:/usr/bin",
>     environment => "HOME=/root",
>     command     => "/bin/cp /root/security.fdb
/var/lib/firebird/2.1/system",
>     user        => "root",
>     group       => "root",
>     logoutput   => on_failure,
>     require  => Class["firebird::install"],
>   }
> }
>
> Is there a better way?

Looking at this you''ll be overwriting the security file every puppet
run, rather than never at all. The first run *may* fail as the copy has
no dependency on File[''/root/security.fdb''].

Maintaining local configs on the servers is fighting the Puppet
mentality. You''d be better off using an array of source files so that
puppet will fall through the list until hitting a positive. Have a read
through the Source part of
http://docs.puppetlabs.com/references/stable/type.html#file

This class doesn''t restart the sql server. Is that handled elsewhere?

An example:
class firebird::configure {
    file { ''/var/lib/firebird/2.1/system/security.fdb'':
        source => [
"puppet:///modules/firebird/custom/security.$host",
              ''puppet:///modules/firebird/security.fdb''],
        owner => root,
        group => root,
        mode => 640,
        require => Class[''firebird::install''],
        # notify => Service[''firebird''],
    }
}

HTH,
Dan