package {"ruby-devel": ensure=>latest}
package {"rubygems": ensure=>latest}
exec {"install-mysql-gem":
command=>'gem install mysql',
path=>"/bin:/usr/bin:/usr/sbin:/sbin",
require=>[ Package["ruby-devel"], Package["rubygems"]]
}
Now in many cases puppet tries to execute Exec["install-mysql-gem"]
before Package["ruby-devel"] or Package["rubygems"] or both.
Is there a way that I can ensure that puppet renders the file in order
the script is written ?
BTW I'm using CentOS 5.4 with puppet-server-0.24.5-1.el5 and
puppet-0.24.5-1.el5.
Regards,
Mayank
No. And that's not a bug it's (really!) a feature.
If you have dependencies and they matter, then define (via
require,before,subscribe,notify) and hence _document_ them. If there
are no dependencies, the order doesn't matter.
cheers pete
> Now in many cases puppet tries to execute Exec["install-mysql-gem"]
> before Package["ruby-devel"] or Package["rubygems"] or both.
no that shouldn't be the case. if you define such a require, both
packages are installed _before_ the exec is executed.
Are you really sure that it is the way you explain here?
cheers pete
Like Pete says, that is what 'require' is supposed to do. Can you run
"puppetd --verbose --debug --test" (when you expect puppet to fail)
and post the output?
Mike
I posted about this exact thing yesterday (Subj: require inside define), only you actually got replies. :)
In my case, it seems as though there's something deep in the heart of Puppet that always causes 'realize'd resources (User, in this case) to be promoted to the top of the task list. The User line gets eval'd before everything else regardless of how many 'require's I put in front of it.
One difference, though, is that I'm using 0.25.4 from the EPEL repo.
-Jim
nigel
As a temporary workaround, try adding an entry to install ruby-libs between ruby-gems-install and ruby-devel. I say temporary because this looks like a bug that will cause you other problems down the road if you don't find the root cause.
On Apr 18, 2010, at 1:55 AM, Daniel Pittman wrote:
>> Any ideas as to why ruby-devel was not able to install properly during first
>> run?
>
> Nope. I can tell you right now that it isn't a puppet problem, though.[1]
>
> The problem is that puppet executed ...
>
> /usr/bin/yum -d 0 -e 0 -y install ruby-devel
>
> ... and yum returned an error, claiming that it couldn't find a dependency of
> the package.
>
> Fix your yum setup and puppet will start working. (Maybe you need something
> to run a 'yum update' or something like that?)
>
> Daniel
>
> Footnotes:
> [1] Technically, it may be puppet *related* problem, since the way puppet
> invokes the yum command, or the scheduling of it, may cause the failure
> by way of some side-effect.
Here's one way to diagnose this. Try running puppet on a new system in debug mode. Then run those same commands yourself on a new system replacing -d 0 -e 0 with -d 8 -e 1. Hopefully someone will have an easier idea.
you can shorten that by either wrap your package installation with a
> Now I am able to get puppet work for me in very first run. I had to do a
> require => Exec["updateyum"] for every package installation in order to
> ensure that the command yum update -y ran before package is being installed.
> However this brings me to my initial question. Since I'd mentioned
> exec{"updateyum": ....} before any package statement so had puppet some way
> of ensuring serial execution of script I would have been saved from
> mentioning it every time in package statements.
define, or define at the top:
Package{ require => Exec["updateyum"] }
which will introduce a global dependency on the Package resource on that
exec. Note: afair if you set another dependency you will have to reset
it. But it looks like this will be once for your setup.
cheers pete