没有通过傀儡的论证适用于事实

时间:2017-12-11 10:14:10

标签: scripting puppet 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 个答案:

答案 0 :(得分:2)

是。您至少需要解决两个问题:

1 /

问题的直接原因是你在单引号中包含了$::command,告诉Puppet你的意思是文字字符串$::command,当你真正想要那个事实的价值时。

2 /

您不应将$FACTER_command作为参数传递给puppet apply;你只需要将它作为环境变量导出(你已经做过)。

所以:

puppet apply更改为:

puppet apply site.pp 

将您的执行人员更改为:

exec { 'some_exec':
  command => "/bin/bash -c '/some/path/to/scripts.sh -t some_arg ${::command}'",
  ...
}