managing debian alternatives

1,220 views
Skip to first unread message

lluis

unread,
Sep 24, 2009, 6:37:28 AM9/24/09
to puppet...@googlegroups.com
Hello,
there any reason not to configure debian alternatives this way?

file {
"/etc/alternatives/java":
ensure => "/usr/lib/jvm/java-6-sun/jre/bin/java";
}

appart from using non-free software

Marc Fournier

unread,
Sep 24, 2009, 7:01:49 AM9/24/09
to puppet...@googlegroups.com
Hello,

> there any reason not to configure debian alternatives this way?
>
> file {
> "/etc/alternatives/java":
> ensure => "/usr/lib/jvm/java-6-sun/jre/bin/java";
> }

I do the same thing this way:

exec { "update-java-alternatives --set java-6-sun":
unless => 'test $(readlink /etc/alternatives/java) == "/usr/lib/jvm/java-6-sun/jre/bin/java"',
require => Package["sun-java6-bin"],
}

But for alternatives other than java, it probably is fine to do
as you describe.

Marc


lluis

unread,
Sep 24, 2009, 7:53:59 AM9/24/09
to puppet...@googlegroups.com
thank you, I didn't know about update-java-alternatives

El dj 24 de 09 de 2009 a les 13:01 +0200, en/na Marc Fournier va
escriure:

Russ Allbery

unread,
Sep 24, 2009, 7:26:46 PM9/24/09
to puppet...@googlegroups.com
lluis <ll...@ingent.net> writes:

> there any reason not to configure debian alternatives this way?

> file {
> "/etc/alternatives/java":
> ensure => "/usr/lib/jvm/java-6-sun/jre/bin/java";
> }

Yes, you won't modify any slaved alternatives, such as the man page. You
should always use update-alternatives rather than manipulating the file
system to change alternative selections.

--
Russ Allbery (r...@stanford.edu) <http://www.eyrie.org/~eagle/>

daryl wiest

unread,
Aug 29, 2014, 1:42:34 AM8/29/14
to puppet...@googlegroups.com
Marc, or anyone still paying attention.

Sorry for the necro.

I am trying to something similar to 
exec { "update-java-alternatives --set java-6-sun":
  unless => 'test $(readlink /etc/alternatives/java) == "/usr/lib/jvm/java-6-sun/jre/bin/java"',
  require => Package["sun-java6-bin"],
}
 
I am using the jdk_oracle module (https://forge.puppetlabs.com/bcarpio/java_jdk or  puppet module install tylerwalts-jdk_oracle).  It runs the java and javac exec to apply the etc-alternates every single time puppet is run.  I tried to add the unless line to it's definition.  

 exec { "/usr/sbin/update-alternatives --install /usr/bin/java java ${java_home}/bin/java 20000":
   require => Exec['extract_jdk'],
   unless => "test $(readlink /etc/alternatives/java) == '${java_home}/bin/java'",

}
 With that definition, it still runs every single time.  While trying to debug what is going on, I moved the entire unless statement to a notify, and got the following output
Notice: /Stage[main]/Jdk_oracle/Notify[test $(readlink /etc/alternatives/java) == '/opt/jdk1.7.0_55/bin/java']/message: defined 'message' as 'test $(readlink /etc/alternatives/java) == '/opt/jdk1.7.0_55/bin/java''


  if I execute the readlink part of that line in my shell, I see the following.
$ readlink /etc/alternatives/java
/opt/jdk1.7.0_55/bin/java

Two questions... 
1. How can I debug what is going on with that statement?  making it an unless, it always runs, making it an onlyif, it never runs, so something is not working with the comparison.  Is there something different I should be using for the compare?  (tripple equals, contains, etc..)
2. How can I debug the value of the readlink statement (subshell execution?).  It doesn't work in notify.  I have tried assigning it to a value and then using notify, that didn't work either.  


Thanks for your help!

Felix Frank

unread,
Aug 31, 2014, 11:10:38 AM8/31/14
to puppet...@googlegroups.com
On 08/29/2014 07:42 AM, daryl wiest wrote:
> 1. How can I debug what is going on with that statement? making it an
> unless, it always runs, making it an onlyif, it never runs, so
> something is not working with the

Try puppet agent --test --debug

> comparison. Is there something different I should be using for the
> compare? (tripple equals, contains, etc..)

Actually, test(1) does not even take double equals - string comparison
is done via a single = sign.

> 2. How can I debug the value of the readlink statement (subshell
> execution?). It doesn't work in notify. I have tried assigning it to
> a value and then using notify, that didn't work eith

You can try an additional exec.

exec { 'test foo = bar ; echo $?': logoutput => true }

HTH,
Felix
Reply all
Reply to author
Forward
0 new messages