Hi Edd,
here is an example:
class apache-maven-v3 {
# prepare local filesystem
file { 'java_path':
path => "/usr/local/java",
ensure => directory,
}
# copy file from puppet master to local system
file { 'copy_maven_v3':
path => "/usr/local/java/apache-maven-3.0.3-bin.tar.gz",
source =>
"puppet:///modules/apache-maven-v3/apache-maven-3.0.3-bin.tar.gz",
}
# extract local file
exec { 'install_maven_v3':
command => "/bin/tar zxf
/usr/local/java/apache-maven-3.0.3-bin.tar.gz",
cwd => "/usr/local/java",
creates => "/usr/local/java/apache-maven-3.0.3",
}
# make sure the order is set properly
File['java_path'] -> File['copy_maven_v3'] -> Exec['install_maven_v3']
}
kind regards,
Martin
On 05/03/2011 11:06 AM, Edd Grant wrote:
> Hi Nan,
>
> Thanks for the answer - I'm not 100% clear how I could acheive this,
> could you expand on your suggestion a little, perhaps with an example?
> Would the file resource point at the .gz file in the module? If so how
> would I then reference the file resource in the tar command?
>
> Many thanks,
>
> Edd
>
> On May 2, 4:15 pm, Nan Liu <[email protected]> wrote:
>> Use a file resource to deploy it to the agent and make the exec depend
>> on the file resource.
>>
>> On May 2, 2011, at 7:58, Edd Grant <[email protected]> wrote:
>>
>>
>>
>>
>>
>>
>>
>>> Hi All,
>>
>>> I have defined the following module to untar/unzip and copy the Maven
>>> distributable to a convenient location:
>>
>>> class apache-maven-v3 {
>>> exec { "/bin/tar xzf /etc/puppet/modules/apache-maven-v3/files/
>>> apache-maven-3.0.3-bin.tar.gz":
>>> cwd => "/usr/local/java",
>>> creates => "/usr/local/java/apache-maven-3.0.3",
>>> }
>>> ...
>>> }
>>
>>> The above definition executes perfectly however in order to keep the
>>> module portable I want to replace the absolute path to the .gz file
>>> with a puppet:/// URI e.g.
>>
>>> exec { "/bin/tar xzf
>>> puppet:///modules/apache-maven-v3/apache-maven-3.0.3-bin.tar.gz":
>>
>>> When I change the class to use the puppet:/// URI I get the following
>>> error:
>>
>>> (/Stage[main]/Apache-maven-v3/Exec[/bin
>>> /tar xzf
>>> puppet:///modules/apache-maven-v3/apache-maven-3.0.3-bin.tar.gz]/return
>>> s) change from notrun to 0 failed: /bin/tar xzf
>>> puppet:///modules/apache-maven-v
>>> 3/apache-maven-3.0.3-bin.tar.gz returned 2 instead of one of [0] at /
>>> etc/puppet/
>>> modules/apache-maven-v3/manifests/init.pp:11
>>
>>> It appears to me that the puppet:/// URI is not being resolved in the
>>> exec and this is causing the tar command to operate on the literal
>>> path puppet:///modules/apache-maven-v3/apache-maven-3.0.3-bin.tar.gz
>>> which of course doesn't exist.
>>
>>> Looking at the docs I can't see any examples of puppet:/// being used
>>> in this way, is there anyway I can obtain the resolved absolute path
>>> to pass this in to my exec? Failing that it there a standard approach
>>> for combining a puppet:/// URI with an exec?
>>
>>> Cheers,
>>
>>> Edd
>>
>>> --
>>> 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
>>> athttp://groups.google.com/group/puppet-users?hl=en.
>
--
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.