0

I tried the following in 2.7.11-1ubuntu2.3. And got the following error: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not match $(pecl at /etc/puppet/modules/php5/manifests/init.pp:90 on node xxxx.

Any idea how I can run commands?

On client,

puppet agent --test

On master

    exec { "pecl_memcache" :
            provider => shell,
            command  => "if [ -n "$(pecl install memcache | egrep fail )" ]; then echo y | pecl install memcache-3.0.8; fi",
            logoutput => true,
    }

1 Answer 1

3

You'll need to escape those quotes and variables inside the command parameter; they are being evaluated by Puppet instead of by bash.

However, it is cleaner to use onlyif instead of relying on the shell to check output:

exec { "pecl_memcache" :
        provider  => shell,
        command   => "pecl install memcache-3.0.8",
        unless    => "pecl install memcache | egrep fail",
        logoutput => true,
}

The slight difference here is that unless relies on the exit code of egrep, whereas the -n test just looks for a non-empty string. This should be functionally the same in this case.

2
  • It seems that the logic is incorrect. Ideally what I need is that if the "install fail" message shows, it means that the package was installed, therefore it should not run the command.
    – Diden
    Commented Aug 2, 2013 at 18:02
  • Change onlyif to unless.
    – Cakemox
    Commented Aug 2, 2013 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .