On Wednesday, September 11, 2013 3:54:11 PM UTC-5, Nathan Nobbe
wrote:>
> Hi everyone,
>
> Just getting into Puppet, so please bear with me :D
>
> I''m setting up a java module to keep an eye on the java
installation on
> our RHEL machines. Quick background, RHEL ships openjdk, we need to use
> Oracle instead. I''ve gone ahead and put the latest oracle java6
RPM, *
> jre-6u45-linux-amd64*, on one of our puppet-managed boxes.
>
> Like many distributions, RHEL has a utility to manage multiple
> installations of java. I''ve already set the default version of
java to the
> latest oracle, so java -version yields java version "1.6.0_45".
>
> Here is a dead simple java module to verify installation
>
> class java {
> package { ''jre-6u45-linux-amd64'':
> ensure => installed,
> }
> }
>
> This works great, but suppose I change the default by hand, just to gauge
> puppet''s reaction.
>
> sudo alternatives --set java /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
> java -version
> java version "1.6.0_24"
>
> Now, when I run sudo puppet agent --test, this is what comes out
>
> Error: Execution of ''/usr/bin/yum -d 0 -e 0 -y install
> jre-6u45-linux-amd64'' returned 1: Error: Nothing to do
>
> Error: /Stage[main]/Java/Package[jre-6u45-linux-amd64]/ensure: change from
> absent to present failed: Execution of ''/usr/bin/yum -d 0 -e 0 -y
install
> jre-6u45-linux-amd64'' returned 1: Error: Nothing to do
>
> This is actually not what I expected, since* jre-6u45-linux-amd* is
> installed, just not set to be the default. Puppet seems to think the
> package is absent however, any thoughts on the reaction from puppet?
>
Your expectation is right for what you presented, supposing that
"jre-6u45-linux-amd" is the actual package name. The only way Puppet
should ever present the error message you show is if the package in
question is initially absent, but is installed while the agent is running.
You should check that you are really using the correct package *name*,
however. RPM packages can define logical facilities that they provide,
which frequently have names similar to the package name. You can ask yum
to install a logical facility by name, and it will find and install an RPM
that provides it.
Puppet, on the other hand, expects you to identify packages by their actual
names, not indirectly by logical facility names. It checks which packages
are already installed by querying the RPM database for the names of all
installed packages (on RPM-based systems, by default). The result you
showed is consistent with jre-6u45-linux-amd being a logical facility name
instead of the actual package name.
This command should tell you the actual package names of the JRE packages
installed on your system:
rpm -qa --qf ''%{name}\n'' | grep ''jre''
My bet is that you''ll find something like "jre-6u45" in place
of
"jre-6u45-linux-amd".
> Ultimately what I''d like to achieve is a smooth check / ensure
that java
> is installed and at the correct version, but since this is an RPM from
> outside yum I''m running into a little trouble
>
I don''t think the trouble you described is related to your RPM not
being in
any of the configured repositories. On the other hand, I highly recommend
that you create a local Yum repository for your organization, and put that
RPM in it. It will not solve the issue you describe, I think, but it will
make your life a lot easier in other ways. Puppet can configure your
clients to know about the local repo -- see the Yumrepo resource type.
> . First off, I''d expect the above module to work, even when the
correct
> version isn''t configured. The next step in my mind would be to
coax puppet
> into running sudo alternatives --set java /usr/java/jre1.6.0_45/bin/javaif
the installation check succeeds, but the default isn''t correctly set.
>
> I grabbed a *java_version* fact from another groups
discussion<https://groups.google.com/forum/#!topic/puppet-users/W67dvqS-GdU>,
> and naively the module code would look something like this
>
> # if version check in package resource succeeds ..
> if($java_version != ''1.6.0_45'')
> # run sudo alternatives --set java /usr/java/jre1.6.0_45/bin/java
>
>
A fact should only gather information, never alter the system. Instead,
you can use the value of a fact to determine whether to instruct Puppet to
alter the system. In this case, though, I wouldn''t even bother with a
fact:
package { ''jre6u45'': # or whatever the actual package name is
ensure => ''installed''
}
exec { ''set_java_version'':
path => [''/usr/bin'', ''/bin'',
''/usr/sbin'', ''/sbin''],
command => ''alternatives --set java
/usr/java/jre1.6.0_45/bin/java'',
unless => "java -version | grep -q
''1\.6\.0_45''",
require => Package[''jre6u45'']
}
HTH,
John
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.