php Puppet:指定要安装的软件包版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11614413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Puppet : Specifying a version of a package to install
提问by JulienD
Apparently this is not possible, but I can't believe that I'm the only one who need it.
显然这是不可能的,但我不敢相信我是唯一需要它的人。
I want to specify the version of php to install because I'm working on an old project requiring php 5.2.
我想指定要安装的 php 版本,因为我正在处理一个需要 php 5.2 的旧项目。
Actually my VM is based on Oneiric with php 5.3
实际上我的 VM 是基于 Oneiric 和 php 5.3
Do you have any solution to do this ?
你有什么解决办法吗?
回答by opsmason
You can specify a version:
您可以指定一个版本:
package { 'php' :
ensure => '5.2' ,
}
However, if that version of PHP RPM/Deb/package isn't available in your upstream repo, then you'll want to either:
但是,如果该版本的 PHP RPM/Deb/package 在您的上游存储库中不可用,那么您需要:
- Find an alternate repo that has that package, and add it to your repo list
- Set up your own repo with the package
Install from your filesystem, by providing a path to the package:
package { 'php' : ensure => '5.2' , source => '/some/path/to/php-5.2.rpm' , }
- 找到具有该软件包的备用仓库,并将其添加到您的仓库列表中
- 使用软件包设置您自己的仓库
通过提供包的路径,从您的文件系统安装:
package { 'php' : ensure => '5.2' , source => '/some/path/to/php-5.2.rpm' , }
回答by StuartW
This is pretty close to how I use custom apt repositories in puppet with their gpg keys
这与我在 puppet 中使用自定义 apt 存储库的 gpg 密钥非常接近
# put downloaded pgp keys into modulename/files/pgp/
# this will copy them all into /tmp
file { '/tmp/pgp-keys':
ensure => directory,
recurse => true,
source => 'puppet:///modules/modulename/pgp',
}
# add any keys that you need
exec { 'apt-key add':
command => '/usr/bin/apt-key add /tmp/pgp-keys/number1.gpg.key &&/
/usr/bin/apt-key add /tmp/pgp-keys/number2.gpg.key',
subscribe => File['/tmp/pgp-keys'],
refreshonly => true,
}
# make sure you add your custom apt repository
file { 'cassandra.sources.list':
ensure => 'present',
path => '/etc/apt/sources.list.d/cassandra.sources.list',
source => 'puppet:///modules/modulename/cassandra.sources.list',
require => Exec['apt-key add'],
}
# update your package list
exec { 'apt-get update':
command => '/usr/bin/apt-get update',
require => File['cassandra.sources.list'],
}
# Install your specific package - I haven't actually used this yet,
# based on answer by opsmason
package { 'cassandra':
ensure => '1.2.0',
require => Exec['apt-get update'],
}

