0

我已经存储了 Linux 产品的安装程序,我需要使用应答文件进行安装。到目前为止,我有以下代码:

class installpackage {
    file { 'MyInstallerFile':
            path => '/tmp/MyInstallerFile',
            ensure => present,
            owner => 'root',
            group => 'root',
            mode => '777',
            source => 'puppet:///extra_files/MyInstallerFile',
    }
    file { 'answer_file':
            path => '/tmp/answer_file',
            ensure => present,
            owner => 'root',
            group => 'root',
            mode => '777',
            source => 'puppet:///extra_file/answer_file',
    }

   exec { "install":
cwd => '/tmp',
             command => '/tmp/MyInstallerFile --answer /tmp/answer_file',
            logoutput => true,
           require => File['MyInstallerFile', 'answer_file'],
   }
}

但是,当我尝试运行它时,会出现一堆错误:

Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Caching catalog for puppetagent.example.com
Info: Applying configuration version '1370899438'
Notice: /Stage[main]/Installpackage/Exec[install]/returns: couldn't find HOME environment variable to expand path
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     while executing
Notice: /Stage[main]/Installpackage/Exec[install]/returns: "file normalize ~"
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     (procedure "::InstallJammer::HomeDir" line 2)
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     invoked from within
Notice: /Stage[main]/Installpackage/Exec[install]/returns: "::InstallJammer::HomeDir"
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     (procedure "::InstallJammer::CommonInit" line 183)
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     invoked from within
Notice: /Stage[main]/Installpackage/Exec[install]/returns: "::InstallJammer::CommonInit"
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     (procedure "::InstallJammer::InitInstall" line 19)
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     invoked from within
Notice: /Stage[main]/Installpackage/Exec[install]/returns: "::InstallJammer::InitInstall"
Notice: /Stage[main]/Installpackage/Exec[install]/returns:     (file "/installkitvfs/main.tcl" line 71313)
Error: /tmp/MyInstallerFile --answer /tmp/answer_file returned 1 instead of one of [0]
Error: /Stage[main]/Installpackage/Exec[install]/returns: change from notrun to 0 failed: MyInstallerFile --answer /tmp/answer_file returned 1 instead of one of [0]
Notice: Finished catalog run in 5.31 seconds

我做错了怎么办?

4

4 回答 4

0

问题似乎是机器的映像方式,解决 Exec 问题的一种解决方案是在命令前面添加“sudo”。当然,这仅限于 Linux 环境。

另一个解决方案,可能是更好的主意是创建您需要的 Debian 安装程序包。这简化了管理和推出新版本,而不是通过卸载例程。

于 2013-08-08T15:15:59.770 回答
0

尝试在命令行上显式设置 $HOME 变量:

exec { "install":
    ...
    command => 'HOME=/path/to/somewhere /tmp/MyInstallerFile --answer /tmp/answer_file',
    ...
}
于 2013-06-16T12:09:43.207 回答
0

你必须做这样的事情。

   $path => $::path,   
   $cwd  => '/location/of/your/installer'

$::path 是对默认环境变量的引用。您可以像这样在数组中设置其他路径。

    $path => [$::path,'/additional/path/to/other/directory'],
    $cwd  => '/location/of/your/installer',
于 2014-08-19T19:05:07.920 回答
0

默认情况下,Puppet 以root用户身份运行。

我认为您的$HOME环境变量不是由root设置的。

作为一项测试,您可以suroot找出echo $HOME是否是这种情况。

于 2013-06-11T03:55:20.173 回答