繁体   English   中英

人偶执行程序返回1而不是[0]

[英]puppet exec returned 1 instead of [0]

我正在尝试运行puppet来配置虚拟机。 执行失败的命令是Exec。

exec { 'configure openssl-arm': 
           logoutput => on_failure, 
           loglevel => verbose, 
           command => '/opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild', 
           cwd => '/opt/openssl-1.0.1g', 
           user => root, 
           environment => 'CC=arm-axis-linux-gnueabi-gcc' 
      }

我非常有信心这是一个木偶戏。

我试图运行的命令是通过exec 如果我不熟悉ssh,可以手动运行该命令。

木偶: err:/ Stage [main] // Exec [configure openssl-arm] / returns:从notrun更改为0失败:/opt/openssl-1.0.1g/Configure dist --prefix = / opt / openssl-1.0。 1g / armbuild在/tmp/vagrant-puppet-6/manifests/default.pp:36返回1,而不是[0]之一。

手册

local> vagrant ssh
vagrant@precise32 > sudu su
root@precise32 > export CC=arm-axis-linux-gnuabi-gcc
root@precise32 > /opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild
....
.... lots of output
....
root@precise32 > echo $?
0

须藤人偶适用

debug: /Schedule[hourly]: Skipping device resources because running on a host
debug: Exec[configure openssl-arm](provider=posix): Executing '/opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild'
debug: Executing '/opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild'
err: /Stage[main]//Exec[configure openssl-arm]/returns: change from notrun to 0 failed: /opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild returned 1 instead of one of [0] at /tmp/build.pp:1
debug: /Schedule[never]: Skipping device resources because running on a host
debug: /Schedule[weekly]: Skipping device resources because running on a host
debug: /Schedule[puppet]: Skipping device resources because running on a host
debug: Finishing transaction -613771238

无业游民的盒子 https://drive.google.com/file/d/0B7B7RIseycQkTGxXczRqVGdDVGs/edit?usp=sharing

听起来需要更多环境变量来运行您的脚本,而这些脚本在木偶运行期间不存在; 我曾经在Maven构建脚本中遇到过同样的问题。 编辑您的Exec命令以在build命令之前获取您的概要文件,因此最终的“脚本”运行如下所示:

#!/bin/bash
source $HOME/.bash_profile
export CC=arm-axis-linux-gnuabi-gcc
/opt/openssl-1.0.1g/Configure dist .......

因此,用人偶术语来说:

exec { 'configure openssl-arm': 
       command => 'source $HOME/.bash_profile; /opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild', 
       cwd => '/opt/openssl-1.0.1g', 
       user => root, 
       environment => 'CC=arm-axis-linux-gnueabi-gcc' 
  }

另外,不要忘记检查脚本返回的实际值。 也许它运行正常,但由于某些神秘的原因而返回非零值。 这不是我第一次使用Puppet部署软件包,并且由于错误地实现了“状态”命令,服务初始化脚本需要进行一些后期调整。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM