Vagrant 配置 - Puppet 安装 php 5.6

Vagrant provisioning - Puppet install php 5.6

我正在尝试在我的 Vagrant CentOS 6.5 机器上安装 PHP 5.6,但已经两天了,我无法让 Puppet 安装这个特定的 PHP 版本。我确实搜索了 SO 并用谷歌搜索但找不到任何有效的解决方案。这是我到目前为止的实验

yumrepo {
         "webtatic":
            descr          => "webtatic",
        baseurl            => "https://mirror.webtatic.com/yum/el6/webtatic-release.rpm",
            failovermethod => "priority",
            gpgcheck       => "0",
            enabled        => "1";
          } 



yumrepo {
         "webtatic":
            descr          => "epel-release",
        baseurl            => "https://mirror.webtatic.com/yum/el6/epel-release.rpm",
            failovermethod => "priority",
            gpgcheck       => "0",
            enabled        => "1";
          } 



package { 'php56w' :
  ensure => 'present'
}

在我的整个实验过程中,我在配置时收到了不同的错误消息:

==> default: Error: /Stage[main]/Main/Package[php56w]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install php56w' returned 1: Error: Nothing to do

==> default: Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install php56w' returned 1: Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel-release. Please verify its path and try again

我也试过使用example42/php模块

class { 'php':
  version => '5.6.10',
}

给我

==> default: Error: /Stage[main]/Php/Package[php]/ensure: change from absent to 5.6.10 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.6.10' returned 1: Error: Nothing to do
==> default:
==> default: Notice: /Stage[main]/Php/File[php.conf]: Dependency Package[php] has failures: true

安装特定 php 版本的正确方法是什么?

编辑:再看一眼,回购协议似乎不正确。

  1. 它使用 rpm 完整的镜像仓库 link,这不是必需的,我在任何方面都不是 yum 专家,但我查看了我的仓库文件,他们没有 link 转 rpm 文件,所以我改为 uk.repo.webtatic.com

  2. 为了安全起见,在 运行 安装 php 时对安装 yum 仓库提出要求,这样你就可以确定它会从额外的仓库中提取出来

我的人偶文件看起来像

class repo {
  yumrepo { "webtatic":
    descr          => "epel-release",
    baseurl        => "https://uk.repo.webtatic.com/yum/el6/$architecture",
    failovermethod => "priority",
    gpgcheck       => "0",
    enabled        => "1";
  } 
}

class php {
  package { "php56w": 
    ensure  => installed, 
    require => Yumrepo["webtatic"] }
}

include repo
include php

and php 5.6.12 get installed in this case:

fhenri@machine:/Volumes/WORK/project/phpbox$ vagrant ssh
Last login: Thu Aug 27 08:18:26 2015 from 172.16.42.1
Welcome to your Packer-built virtual machine.
[ariba@localhost ~]$ php -version
PHP 5.6.12 (cli) (built: Aug  9 2015 11:16:17)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

旧答案: 为什么不使用现有模块?

对于我的情况,我使用 https://forge.puppetlabs.com/example42/php/readme 模块,它允许您指定 php 版本:

class { 'php':
  version => '5.6.10',
}

它应该有效