0

我有以下 exec 语句:

exec { 'enable-locale':                                                  
  command  => 'sed -i "/^#en_US.*/s/^#//" /etc/locale.gen',                 
  provider => shell,  # for grep                                            
  unless   => 'locale -a | grep -i en_US.utf8',                             
  path     => '/usr/bin',                                                   
}

返回以下错误:

错误:/Stage[main]/Qdii::Base/Exec[enable-locale]:无法评估:/bin/sh:1:grep:未找到

我觉得这很奇怪,因为相同的 shell 命令可以正常工作:

$ /bin/sh -c 'locale -a | grep -i en_US.utf8'
en_US.utf8
4

1 回答 1

0

令人困惑的是,虽然grep有时是内置的,但在 Ubuntu 中却不是。

/bin/sh -c 'which grep'
/bin/grep

解决方法是将/bin/路径添加到pathexec 语句的参数中。

于 2019-12-29T17:38:58.337 回答