creating symlinks with wildcards

330 views
Skip to first unread message

Edward Bailey

unread,
May 12, 2009, 11:16:48 AM5/12/09
to puppet...@googlegroups.com
To explain the background behind my question

We have a number of situations where it would be great if I could have puppet automatically maintain a symlink for a resource such as the Java JVM.

For example - we install the JDK in /usr/java so after the RPM  install, the path to the JVM is /usr/java/jdk1.5.0_16. In order to simplify application configuration, I like to make JAVA_HOME something generic like /usr/java/java. I do this by creating a symlink

 ln -s /usr/java/jdk1.5.0_16/ /usr/java/java

I would like to have puppet maintain the symlink so that when YUM updates the JVM, the symlink gets updated as well. I know I could do this in the RPM or using exec but that sounds like too much work:)

Just for fun I tried to setup a file type in puppet to create the symlink using a wildcard. I did not expect this to work given the need for shell expansion.

file { "/usr/java/java":
    ensure => "/usr/java/jdk1.*"
}

Is their another way to do this in the puppet framework? I can do this using exec, but I wanted to work from within puppet first.

Thanks for any ideas

Ed

Nigel Kersten

unread,
May 12, 2009, 11:23:20 AM5/12/09
to puppet...@googlegroups.com

So if you write a fact that is your jdk path, you could then use it in
your manifests:

file { "/usr/java/java":
ensure => symlink,
replace => true
target => $jdk_path,
}

That would seem to be the simplest option.

--
Nigel Kersten
nig...@google.com
System Administrator
Google, Inc.

Trevor Hemsley

unread,
May 12, 2009, 11:34:34 AM5/12/09
to puppet...@googlegroups.com
I think you picked a bad example :)

Java installs a symlink /usr/java/latest which points to (surprise!) the
latest version that is installed.

Or maybe this is a Java 1.6 thing in which case you might want to
accelerate your migration
--

Trevor Hemsley
Infrastructure Engineer
.................................................
* C A L Y P S O
* Brighton, UK

OFFICE +44 (0) 1273 666 350
FAX +44 (0) 1273 666 351

.................................................
www.calypso.com

This electronic-mail might contain confidential information intended
only for the use by the entity named. If the reader of this message is
not the intended recipient, the reader is hereby notified that any
dissemination, distribution or copying is strictly prohibited.

* P * /*/ Please consider the environment before printing this e-mail /*/

List Account

unread,
May 13, 2009, 8:59:18 AM5/13/09
to puppet...@googlegroups.com, puppet...@googlegroups.com
I wish I could upgrade to 1.6. We just upgraded to the 1.5 jdk. The
rpms I have do not create a symlink.
Thanks!

Sent from my iPhone

On May 12, 2009, at 11:34 AM, Trevor Hemsley <trevor....@codefarm.com

List Account

unread,
May 13, 2009, 9:01:49 AM5/13/09
to puppet...@googlegroups.com, puppet...@googlegroups.com
That's a really good idea. Thanks for sharing.

Ed

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages