我想要用 puppet 运行以下命令:
sb2-init rasp /home/ubuntu/raspberry_pi_development/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
在 Puppet 中:
exec { "initSB2":
command => "sb2-init rasp /home/ubuntu/raspberry_pi_development/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc" ,
cwd => "/home/vagrant/raspberry_pi_development/rootfs",
path => "/home/vagrant/raspberry_pi_development/scratchbox2/bin",
user => 'vagrant',
logoutput => true,
}
sb2-init 命令位于“/home/vagrant/raspberry_pi_development/scratchbox2/bin”目录中,我想在“/home/vagrant/raspberry_pi_development/scratchbox2/bin”文件夹中执行该命令。
当我执行这个 puppet-manifest 时我得到:
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 6
sename: command not found
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 6
sename: command not found
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 8
sename: command not found
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 8
=: unary operator expected
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 2
readlink: command not found
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 2
dirname: command not found
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 2
readlink: command not found
notice: /Stage[main]//Exec[initSB2]/returns: /home/vagrant/raspberry_pi_development/scratchbox2/bin/sb2-init: line 2
/share/scratchbox2/scripts/sb2-parse-sb2-init-args: No such file or directory
notice: /Stage[main]//Exec[initSB2]/returns: Error: no target given
err: /Stage[main]//Exec[initSB2]/returns: change from notrun to 0 failed: /bin/sh -c "sb2-init rasp /home/ubuntu/ras
ry_pi_development/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc" returned 1
ead of one of [0] at /tmp/vagrant-puppet-1/manifests/devbox.pp:332
当我在 shell 中手动输入此命令时它有效,但在 puppet 中却无效!
问题是什么?
问候迈克尔
答案1
我认为这实际上与 Puppet 没有任何关系 - 命令输出实际上来自脚本,而不是 Puppet(从外观上看,缺少包和脚本语法都存在问题,但如果看不到脚本,就无法说)。
我会手动运行该命令(例如通过 SSH)并检查输出。修复潜在问题后,重新运行 Puppet 命令,一切都会成功。