Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion exec's onlyif parameter fails for a bash one-liner

Received: by 10.101.180.28 with SMTP id h28mr1197666anp.24.1335369825875;
        Wed, 25 Apr 2012 09:03:45 -0700 (PDT)
X-BeenThere: puppet-users@googlegroups.com
Received: by 10.101.203.37 with SMTP id f37ls38218anq.9.gmail; Wed, 25 Apr
 2012 09:03:39 -0700 (PDT)
Received: by 10.101.133.8 with SMTP id k8mr1199480ann.19.1335369819759;
        Wed, 25 Apr 2012 09:03:39 -0700 (PDT)
Received: by 10.101.133.8 with SMTP id k8mr1199478ann.19.1335369819729;
        Wed, 25 Apr 2012 09:03:39 -0700 (PDT)
Return-Path: <florian.koch1...@googlemail.com>
Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50])
        by gmr-mx.google.com with ESMTPS id y53si97038yhe.4.2012.04.25.09.03.39
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 25 Apr 2012 09:03:39 -0700 (PDT)
Received-SPF: pass (google.com: domain of florian.koch1...@googlemail.com designates 209.85.213.50 as permitted sender) client-ip=209.85.213.50;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of florian.koch1...@googlemail.com designates 209.85.213.50 as permitted sender) smtp.mail=florian.koch1...@googlemail.com; dkim=pass header...@googlemail.com
Received: by mail-yw0-f50.google.com with SMTP id j63so293988yhj.23
        for <puppet-users@googlegroups.com>; Wed, 25 Apr 2012 09:03:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type;
        bh=M/EUBhPdF3OSfdyAn3JNhlhLDTKKFfGMFXiYGu6Tseo=;
        b=wTJf+UEFmADRRDNypRZw1fVuKN2/KEh0UFX3JznmK63mY4QIgiNBLkNTG+NeUMC49/
         QV28xRXKidD4rXekPCRK2Rny/8sAA3O3RdvuS9tJ069LkuScIVJ24Z4OTqjLov4M2DWW
         6+Ck6kmLUpmmNxOOSnzL0VDyFM9/edqwMWwfdWUhvdRMGK6sj35Mx5UlyXWAdBobYxlm
         1qPpRbaOIPcq7/uD3txGIoK6YoB7a8Jw/Mm/os36o62IIYt7zGxDqnfNWCcT9vlPU6ke
         xj7m0G/dmWbE4CgYKryslyNcW1prd01B4Htb8Y6q7gczjm4aOHMs0Qr9zmf2xGJDmrMp
         vBBg==
MIME-Version: 1.0
Received: by 10.236.189.2 with SMTP id b2mr3085743yhn.11.1335369819564; Wed,
 25 Apr 2012 09:03:39 -0700 (PDT)
Received: by 10.100.249.5 with HTTP; Wed, 25 Apr 2012 09:03:39 -0700 (PDT)
In-Reply-To: <44fc11ab-eb3d-467e-8560-956eafc80...@w5g2000vbp.googlegroups.com>
References: <44fc11ab-eb3d-467e-8560-956eafc80...@w5g2000vbp.googlegroups.com>
Date: Wed, 25 Apr 2012 18:03:39 +0200
Message-ID: <CAJrhObf6Sd82Wue1aPVFWiJ8+C8qCu47EQq5FfPTNn5FgFV...@mail.gmail.com>
Subject: Re: [Puppet Users] exec's onlyif parameter fails for a bash one-liner
From: Florian Koch <florian.koch1...@googlemail.com>
To: puppet-users@googlegroups.com
Content-Type: multipart/alternative; boundary=20cf30549ce3bd2b5804be8303b8

--20cf30549ce3bd2b5804be8303b8
Content-Type: text/plain; charset=ISO-8859-1

Hi,

you need to add provider => shell to your exec to get the subshell working

regards Florian

On Wed, Apr 25, 2012 at 6:01 PM, Shantanu <knowshant...@gmail.com> wrote:

>
> I would like to 'exec' an installation script 'onlyif' an installation
> directory is empty. I tried using following bash one-liner however it
> didn't work:
> <code>
>  exec{$one_install_script:
>    require => File[$one_install_script],
>    onlyif => "[ \"$(/bin/ls -A  $one_location)\" ] && exit 1 || exit
> 0"
>  }
>
> </code>
>
> It failed with following error:
>
> <error>
> err: Failed to apply catalog: Parameter onlyif failed: '[ "$(/bin/ls -
> A  /srv/cloud/one)" ] && exit 1 || exit 0' is not qualified and no
> path was specified. Please qualify the command or specify a path.
> </error>
>
> A bash script with above one-liner worked fine though.
> <code>
>  exec{$one_install_script:
>    require => File[$one_install_script],
>    onlyif  => "/tmp/is-dir-empty.sh $one_location"
> </code>
>
> The bash script approach works fine for me. However I am not sure what
> is wrong with the one-liner command. Is $(cmd) command substitution or
> built-in function 'exit' a problem?  Any pointers will be really
> helpful.
>
> --
> Thanks,
> Shantanu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>

--20cf30549ce3bd2b5804be8303b8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div class=3D"gmail_extra">Hi,<br><br>you need to add provider =3D&gt; shel=
l to your exec to get the subshell working<br><br>regards Florian<br><br><d=
iv class=3D"gmail_quote">On Wed, Apr 25, 2012 at 6:01 PM, Shantanu <span di=
r=3D"ltr">&lt;<a href=3D"mailto:knowshant...@gmail.com" target=3D"_blank">k=
nowshant...@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><br>
I would like to &#39;exec&#39; an installation script &#39;onlyif&#39; an i=
nstallation<br>
directory is empty. I tried using following bash one-liner however it<br>
didn&#39;t work:<br>
&lt;code&gt;<br>
 =A0exec{$one_install_script:<br>
 =A0 =A0require =3D&gt; File[$one_install_script],<br>
 =A0 =A0onlyif =3D&gt; &quot;[ \&quot;$(/bin/ls -A =A0$one_location)\&quot;=
 ] &amp;&amp; exit 1 || exit<br>
0&quot;<br>
 =A0}<br>
<br>
&lt;/code&gt;<br>
<br>
It failed with following error:<br>
<br>
&lt;error&gt;<br>
err: Failed to apply catalog: Parameter onlyif failed: &#39;[ &quot;$(/bin/=
ls -<br>
A =A0/srv/cloud/one)&quot; ] &amp;&amp; exit 1 || exit 0&#39; is not qualif=
ied and no<br>
path was specified. Please qualify the command or specify a path.<br>
&lt;/error&gt;<br>
<br>
A bash script with above one-liner worked fine though.<br>
&lt;code&gt;<br>
 =A0exec{$one_install_script:<br>
 =A0 =A0require =3D&gt; File[$one_install_script],<br>
 =A0 =A0onlyif =A0=3D&gt; &quot;/tmp/is-dir-empty.sh $one_location&quot;<br=
>
&lt;/code&gt;<br>
<br>
The bash script approach works fine for me. However I am not sure what<br>
is wrong with the one-liner command. Is $(cmd) command substitution or<br>
built-in function &#39;exit&#39; a problem? =A0Any pointers will be really<=
br>
helpful.<br>
<br>
--<br>
Thanks,<br>
Shantanu<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;Puppet Users&quot; group.<br>
To post to this group, send email to <a href=3D"mailto:puppet-users@googleg=
roups.com">puppet-users@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:puppet-user=
s%2Bunsubscribe@googlegroups.com">puppet-users+unsubscribe@googlegroups.com=
</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/puppet-users?hl=3Den" target=3D"_blank">http://groups.google.com/group=
/puppet-users?hl=3Den</a>.<br>
<br>
</font></span></blockquote></div><br></div>

--20cf30549ce3bd2b5804be8303b8--