Puppet:指定要安装的软件包版本

31

显然这是不可能的,但我无法相信只有我需要它。

我想指定安装的php版本,因为我正在处理一个需要php 5.2的旧项目。

实际上,我的虚拟机基于Oneiric和php 5.3。

你有任何解决方法吗?

2个回答

51

您可以指定一个版本:

package { 'php' :
  ensure => '5.2' ,
}

然而,如果您的上游仓库中没有那个版本的PHP RPM/Deb/package,则需要执行以下操作之一:

  1. 查找具有该软件包的备用仓库,并将其添加到您的仓库列表中
  2. 使用该软件包设置自己的仓库
  3. 通过提供软件包路径从文件系统安装:

    package { 'php' :
      ensure => '5.2' ,
      source => '/some/path/to/php-5.2.rpm' ,
    }
    

我尝试了更改我的偏好/源列表的解决方案,但在下载archive.debian的公钥时遇到了问题 :s - JulienD
@opsmason:版本值需要是字符串吗?你能指定它为 ensure => 5.2 吗? - greenpool
@greenpool:版本号是一个字符串。以 httpd-2.4.29 为例:2.4.29 不是浮点数,而是一个字符串! - opsmason

7

这与我在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'],
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接