Skip to main content
 首页 » 编程设计

python之无法使用 Puppet 为 Python 3 设置安装目录

2024年10月25日32JustinYoung

我继承了一堆 Puppet 脚本,正在更新它们。我的脚本之一用于安装 Python。我想将它安装到 C:/bin/Python34。但是,每次我运行 Puppet 脚本时,它都会安装到 C:/Python34。如果我手动运行安装程序,我会看到这是默认安装位置,所以看起来我没有正确覆盖脚本中的目录。

我的代码如下:

class python( $installer = 'python-3.4.2.msi' ) 
{ 
    package 
    { 
        'Python3': 
        ensure => 'installed', 
        source => "\\\\myApp.server\\Python\\${installer}", 
        install_options => { 'INSTALLDIR' => 'C:\bin\Python34' }, 
    } 
} 

不幸的是,当我在运行脚本时运行 --debug 选项时似乎没有出现任何错误:

Debug: Prefetching windows resources for package 
Debug: Executing 'msiexec.exe /qn /norestart /i \\myApp.server\Python\python-3.4.2.msi INSTALLDIR=C:\bin\Python34' 
Notice: /Stage[main]/Python/Package[Python3]/ensure: created 
Debug: /Package[Python3]: The container Class[Python] will propagate my refresh event 
Debug: Class[Python]: The container Stage[main] will propagate my refresh event 
Debug: Finishing transaction 53869152 
Debug: Storing state 
Debug: Stored state in 0.01 seconds 
Notice: Finished catalog run in 39.22 seconds 
Debug: Using settings: adding file resource 'rrddir': 'File[C:/ProgramData/PuppetLabs/puppet/var/rrd]{:path=>"C:/ProgramData/PuppetLabs/puppet/var/rrd", :mode=>"750", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}' 
Debug: Finishing transaction 48943728 
Debug: Received report to process from bgtmnwl-659gxw1.peroot.com 
Debug: Processing report from bgtmnwl-659gxw1.peroot.com with processor Puppet::Reports::Store 

此代码似乎适用于其他软件,但不适用于 Python。我正在以管理员身份运行命令提示符。

Python 的安装程序有什么不同吗?为什么 Puppet 不能为 Python 3 设置安装目录?

请您参考如下方法:

Puppet 使用 msiexec 安装 python。要设置安装目录,请提供 TARGETDIR 而不是 INSTALLDIR。请点击链接了解更多explanation .