我试图将FACTER参数传递给puppet apply
。这是我尝试的:
export FACTER_command="start"
puppet apply site.pp $FACTER_command
,在我的代码中,我有:
exec { 'some_exec':
command => '/bin/bash -c "/some/path/to/scripts.sh -t some_arg $::command"',
...
我得到此消息错误:
Error: '/bin/bash -c "/some/path/to/scripts.sh -t some_arg $::command"' returned 1 instead of one of [0]
Error: /Stage[main]/Standard/Exec[some_exec]/returns: change from 'notrun' to ['0'] failed: '/some/path/to/scripts.sh -t some_arg $::command"' returned 1 instead of one of [0]
有人对此有任何想法吗?
更新
class standard{
$param_test="/some/path/to/scripts.sh -t some_arg ${::command}"
file{'kick_servers':
ensure => 'file',
path => '/some/path/to/scripts.sh',
owner => 'some_user,
group => 'some_user',
mode => '0755',
notify => Exec['some_exec']
}
exec { 'some_exec':
command => '/bin/bash -c ${param_test}',
cwd => "$home_user_dir",
timeout => 1800
}
}
node default {
include standard
}
我得到这个错误
Error: '/bin/bash -c $param_test' returned 2 instead of one of [0]
Error: /Stage[main]/Standard/Exec[some_exec]/returns: change from 'notrun' to ['0'] failed: '/bin/bash -c $param_test' returned 2 instead of one of [0]
是。您至少有两个问题需要解决:
1/
您问题的直接原因是您在单引号中已包含$::command
,告诉puppet您的意思是字面字符串$::command
,当您实际想要事实的价值时。
2/
您不应将$FACTER_command
作为参数传递给puppet apply
;您只需要将其导出为环境变量(您已经做到了)。
so:
将puppet apply
更改为:
puppet apply site.pp
将您的Exec更改为:
exec { 'some_exec':
command => "/bin/bash -c '/some/path/to/scripts.sh -t some_arg ${::command}'",
...
}