检测到对 Mixlib::ShellOut 的调用。在你的机器上执行命令是不安全的

Call to Mixlib::ShellOut detected. Executing commands on your machine is not safe

我的 Chef 食谱中有几个使用 Mixlib::ShellOut 的命令,例如

cmd = Mixlib::ShellOut.new(format('getent group %s', 'test'))
cmd.run_command

cmd = Mixlib::ShellOut.new(format('getent pasword %s', 'test'))
cmd.run_command

不幸的是,我的构建过程一直失败并出现以下错误,这主要是由于某些我无法更改的配置:

Call to Mixlib::ShellOut detected. Executing commands on your machine is not safe!

有办法解决这个问题吗?

您可以使用反引号。

`ls -ltr >> logs.txt 2>&1`