Interestingly enough, I learned about the require keyword when I did this same thing, but left out the 'require'. And (even using 0.24.8), I had problems where it tried to copy the file into a non-existent directory. Adding the 'require' line made that go away...
David P.S. BTW, Jason, the root cause of your confusion is that you are approaching this as a procedural/functional thing, instead of a 'state' problem. What you should be doing with puppet, 99.9% of the time, is describing the state that you would like your system to be in, and then let puppet take care of the details. I.e., if you find yourself writing 'exec' statements to do stuff like create directories, then you're probably doing it wrong. Note the benefits: if the /opt/scripts directory exists but is set to 0200, or is owned by a user, or has a group ownership of uucp, then puppet will fix it. In your 'exec mkdir' scenario, all puppet would do is see if the directory exists. Using puppet to it's fullest potential takes a shift in how you think about the problem, but it's generally worth it. Note: I'm nowhere near "there"! I'm a newbie on the road, same as you... On Wed, Jun 24, 2009 at 01:29:54PM -0700, Nigel Kersten wrote: > > On Wed, Jun 24, 2009 at 1:24 PM, David Bishop<[email protected]> wrote: > > > > Re-do that as: > > > > class theclass { > > file { "/opt/scripts": > > ensure => "directory", > > owner => "root", > > group => "root", > > mode => 755, > > } > > > > file { "/opt/scripts/my_script.sh": > > owner => "root", > > group => "thegroup", > > mode => 770, > > source => "puppet:///files/my_script.sh", > > require => File['/opt/scripts'], > > } > > } > > > > That way, it won't copy down my_script.sh without first creating > > /opt/scripts. > > Note that if you have a file resource defined as well as the parent > directory, the require is automatic, so you don't have to explicitly > state it. > > > > > > David > > > > > > On Wed, Jun 24, 2009 at 10:00:47AM -0700, jason wrote: > >> > >> > >> I want to create a directory and THEN get files into that directory on > >> a client. > >> Puppet it seems does not follow the order of commands, like below in > >> my example. > >> Sometimes it creates the directory, then downloads the file, and > >> sometimes it tries to download the file before creating the directory, > >> so the file won't be downloaded. > >> > >> How can I download a file and make certain the destination directory > >> will be there before this file is downloaded? thanks again! -jason > >> > >> class theclass ( > >> > >> exec{'mkdir -p /opt/scripts': > >> unless => 'test -d /opt/scripts', > >> } > >> > >> file { "/opt/scripts/my_script.sh": > >> owner => "root", > >> group => "thegroup", > >> mode => 770, > >> source => "puppet:///files/my_script.sh", > >> } > >> > >> ) > >> > >> >> > > > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v1.4.9 (GNU/Linux) > > > > iEYEARECAAYFAkpCi40ACgkQTKX6T9GeRTZA4wCeMqTNUiTLGdqMDRD9qPF6fPFi > > NqwAn2towM7FwXvkDwbm/cQyirkTItbw > > =u/9R > > -----END PGP SIGNATURE----- > > > > > > > > -- > Nigel Kersten > [email protected] > System Administrator > Google, Inc. > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en > -~----------~----~----~----~------~----~------~--~--- >
signature.asc
Description: Digital signature
