Puppet Nginx 安装 CentOs

Puppet Nginx Install CentOs

有人能告诉我为什么这不起作用吗?此代码在 Ubuntu 服务器上运行良好,但在 CentOS 上崩溃。我是运行人偶版3.7.2.

node default {
  package { 'httpd':
    ensure => 'absent'
  }

  package { 'nginx':
    ensure => 'installed',
    require => Package['httpd'],
  }
}

我收到这个错误:

Error: Execution of '/bin/yum -d 0 -e 0 -y list nginx' returned 1: Error: No matching Packages to list
Error: /Stage[main]/Main/Node[default]/Package[nginx]/ensure: change from absent to present failed: Execution of '/bin/yum -d 0 -e 0 -y list nginx' returned 1: Error: No matching Packages to list

nginx 不在默认的 CentOS 软件库中;它需要 epel。在你安装这个包之前,你需要 require epel-release:

package { 'epel-release':
  ensure => 'installed',
}

package { 'nginx':
  ensure  => 'installed',
  require => [Package['httpd'], Package['epel-release']],
}

顺便问一下,您安装的 nginx 是否特别要求在 安装 之前 不存在 httpd?您应该能够删除 httpd 元参数依赖项。