未能将论点传递给傀儡应用事实

failing to pass argument to puppet apply with facts

我正在尝试将 factor 参数传递给 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;您只需要将其导出为环境变量(您已经这样做了)。

所以:

puppet apply更改为:

puppet apply site.pp 

将您的主管更改为:

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