FAQ
Ed, I am having trouble unzipping any tarball via Puppet. So I installed
your module to see how you might have done it. It runs, it creates the
javapath and copies the file... but I get the same error that I get on my
modules... can I please ask how you made unzip work? I am on Ubuntu
10.4.1, and 2.6.4 (Puppet Enterprise 1.0).

err: /Stage[main]/Apache-maven-v3/Exec[install_maven_v3]/returns: change
from notrun to 0 failed: /bin/tar zxf
/usr/local/java/apache-maven-3.0.3-bin.tar.gz returned 2 instead of one of
[0] at /etc/puppetlabs/puppet/modules/apache-maven-v3/manifests/init.pp:18
On Monday, May 2, 2011 7:58:09 AM UTC-7, Edd Grant 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 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.

Search Discussions

  • Matthew Burgess at Sep 12, 2013 at 12:54 pm

    On 11 September 2013 23:55, wrote:

    Ed, I am having trouble unzipping any tarball via Puppet. So I installed
    your module to see how you might have done it. It runs, it creates the
    javapath and copies the file... but I get the same error that I get on my
    modules... can I please ask how you made unzip work? I am on Ubuntu
    10.4.1, and 2.6.4 (Puppet Enterprise 1.0).

    err: /Stage[main]/Apache-maven-v3/Exec[install_maven_v3]/returns: change
    from notrun to 0 failed: /bin/tar zxf
    /usr/local/java/apache-maven-3.0.3-bin.tar.gz returned 2 instead of one of
    [0] at /etc/puppetlabs/puppet/modules/apache-maven-v3/manifests/init.pp:18
    What happens if you run '/bin/tar zxf /usr/local/java/apache-maven-
    3.0.3-bin.tar.gz' from the command line?

    Additionally, you could change your manifest so that it executes 'pwd &&
    /bin/tar zxf /usr/local/java/apache-maven-3.0.3-bin.tar.gz' so that you can
    see what directory the contents of the file are being extracted to. My
    suspicion is that you're either extracting to the wrong directory, or the
    directory you're extracting to has incorrect permissions set on it or the
    tar file has incorrect permissions set on it.

    Regards,

    Matt.

    --
    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.
  • Sean LaFreniere at Sep 16, 2013 at 3:53 pm
    From the command line all works fine, only not from Puppet. BTW, I am
    not the only one with this complaint online on your forums and
    elsewhere, people complain that Tar works, but not UnTar. -S


    On 9/12/13 5:54 AM, Matthew Burgess wrote:

    On 11 September 2013 23:55, wrote:

    Ed, I am having trouble unzipping any tarball via Puppet. So I
    installed your module to see how you might have done it. It runs,
    it creates the javapath and copies the file... but I get the same
    error that I get on my modules... can I please ask how you made
    unzip work? I am on Ubuntu 10.4.1, and 2.6.4 (Puppet Enterprise
    1.0).

    err: /Stage[main]/Apache-maven-v3/Exec[install_maven_v3]/returns:
    change from notrun to 0 failed: /bin/tar zxf
    /usr/local/java/apache-maven-3.0.3-bin.tar.gz returned 2 instead
    of one of [0] at
    /etc/puppetlabs/puppet/modules/apache-maven-v3/manifests/init.pp:18


    What happens if you run '/bin/tar zxf /usr/local/java/apache-maven-
    3.0.3-bin.tar.gz' from the command line?

    Additionally, you could change your manifest so that it executes 'pwd
    && /bin/tar zxf /usr/local/java/apache-maven-3.0.3-bin.tar.gz' so that
    you can see what directory the contents of the file are being
    extracted to. My suspicion is that you're either extracting to the
    wrong directory, or the directory you're extracting to has incorrect
    permissions set on it or the tar file has incorrect permissions set on it.

    Regards,

    Matt.
    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Puppet Users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/puppet-users/AlqzFLkTS28/unsubscribe.
    To unsubscribe from this group and all its topics, 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.
    --
    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.
  • Jcbollinger at Sep 16, 2013 at 6:12 pm

    On Monday, September 16, 2013 10:53:38 AM UTC-5, Sean LaFreniere wrote:
    From the command line all works fine, only not from Puppet. BTW, I am
    not the only one with this complaint online on your forums and elsewhere,
    people complain that Tar works, but not UnTar. -S
    I see no reason to think that this arises from a bug in Puppet. Almost
    certainly it involves issues with how Puppet is being used. Here are some
    of the aspects of the execution environment provided by Puppet Exec
    resources that could be related to such issues:

        - Puppet provides a very sparse environment to commands it executes.
        Any other desired environment variables need to be specified in the
        'environment' property of the Exec resource or set within the command
        itself. Environment variables are not inherited from the environment
        provided to the agent, nor are the shell startup files read.
        - The working directory in which the command starts is not defined
        unless you provide the 'cwd' parameter to the Exec.
        - The 'command', 'unless', and 'onlyif' commands of every exec all have
        independent environments. You cannot use any of them to modify the
        environment variables or working directory provided to others.
        - If you want an executable search path, you must provide it via the
        'path' parameter or among the specified environment variables. Otherwise,
        you must give the fully-qualified pathname of the command(s) you want to
        run.
        - By default, the command is run with the credentials and security
        context of the Puppet process. Even though the agent normally runs as a
        privileged user, mandatory access controls (e.g. SELinux) may still deny it
        permission to perform some actions.
        - Privileged users on the local system may have less -- or even no --
        privilege on remote systems. This can be an issue, for example, with
        remote NFS filesystems mounted on the local machine.
        - By default the command is passed directly to the system to execute,
        bypassing the shell. On POSIX clients, setting provider => 'shell' will
        cause the command to be executed via '/bin/sh', instead, or you can always
        Exec the shell directly.
        - By default, success of an Exec is judged by whether the command exits
        with code 0. Additional or different successful exit codes can be
        specified via the 'returns' parameter.

    All of those are intentional and logical, but some may nevertheless take
    users by surprise, especially users more used to a script-centric model of
    system administration. The Puppet model does not work the same way.


    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 11, '13 at 10:58p
activeSep 16, '13 at 6:12p
posts4
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase