在bash中为puppetmaster运行命令

我在2.7.11-1ubuntu2.3中尝试了以下内容。 并得到以下错误:err:无法检索远程服务器的目录:服务器上的错误400:无法匹配$(节点xxxx上的/etc/puppet/modules/php5/manifests/init.pp:90 pecl。

任何想法如何我可以运行命令?

在客户端,

傀儡代理 – testing

在主人

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, } 

您需要在命令参数中转义那些引号和variables; 他们正在被Puppet而不是bash评估。

但是,使用onlyif而不是依靠shell来检查输出是更清洁的:

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

这里的细微差别是, unless依赖egrep的退出代码,而-ntesting只是寻找一个非空string。 这种情况在function上应该是一样的。