gpt4 book ai didi

linux - puppet exec 返回 1 而不是 [0]

转载 作者:太空狗 更新时间:2023-10-29 12:32:06 25 4
gpt4 key购买 nike

我正在尝试运行 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'
}

我非常有信心这更像是一个 puppet 问题。

我尝试运行的命令是通过exec。如果我输入 vagrant ssh,我可以手动运行命令。

puppet :错误:/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 在/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

sudo puppet 申请

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

Vagrant 盒子 https://drive.google.com/file/d/0B7B7RIseycQkTGxXczRqVGdDVGs/edit?usp=sharing

最佳答案

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

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

所以,用 puppet 术语来说:

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 部署包,由于“状态”命令执行不当,服务初始化脚本需要进行一些后期调整。

关于linux - puppet exec 返回 1 而不是 [0],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23747998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com