Skip to content

Clean up package classes, allow installing mainline upstream packages #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This module manages NGINX configuration.
### Requirements

* Puppet-2.7.0 or later
* Facter 1.7.0 or later
* Ruby-1.9.3 or later (Support for Ruby-1.8.7 is not guaranteed. YMMV).

### Install and bootstrap an NGINX instance
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@

### START Package Configuration ###
$package_ensure = present,
$package_name = 'nginx',
$package_name = $::nginx::params::package_name,
$package_source = 'nginx',
$manage_repo = true,
$manage_repo = $::nginx::params::manage_repo,
### END Package Configuration ###

### START Service Configuation ###
Expand All @@ -120,7 +120,7 @@
$nginx_vhosts = {},
$nginx_vhosts_defaults = {},
### END Hiera Lookups ###
) {
) inherits ::nginx::params {

### DEPRECATION WARNING ###
###
Expand Down
74 changes: 15 additions & 59 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#
# This class file is not called directly
class nginx::package(
$package_name = 'nginx',
$package_name = $::nginx::params::package_name,
$package_source = 'nginx',
$package_ensure = 'present',
$manage_repo = true,
) {
$manage_repo = $::nginx::params::manage_repo,
) inherits ::nginx::params {

anchor { 'nginx::package::begin': }
anchor { 'nginx::package::end': }
Expand All @@ -27,6 +27,7 @@
'redhat': {
class { '::nginx::package::redhat':
manage_repo => $manage_repo,
package_source => $package_source,
package_ensure => $package_ensure,
package_name => $package_name,
require => Anchor['nginx::package::begin'],
Expand All @@ -43,67 +44,22 @@
before => Anchor['nginx::package::end'],
}
}
'suse': {
class { '::nginx::package::suse':
package_name => $package_name,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
'archlinux': {
class { '::nginx::package::archlinux':
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
'Solaris': {
class { '::nginx::package::solaris':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
'FreeBSD': {
class { '::nginx::package::freebsd':
package_name => $package_name,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
'Gentoo': {
class { '::nginx::package::gentoo':
package_name => $package_name,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
# $package_name needs to be specified. SFEnginx,CSWnginx depending on
# where you get it.
if $package_name == undef {
fail('You must supply a value for $package_name on Solaris')
}
}
'OpenBSD': {
class { '::nginx::package::openbsd':
package_name => $package_name,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],

package { 'nginx':
ensure => $package_ensure,
name => $package_name,
source => $package_source,
}
}
default: {
case $::operatingsystem {
'amazon': {
# Amazon was added to osfamily RedHat in 1.7.2
# https://github.com/puppetlabs/facter/commit/c12d3b6c557df695a7b2b009da099f6a93c7bd31#lib/facter/osfamily.rb
warning("Module ${module_name} support for ${::operatingsystem} with facter < 1.7.2 is deprecated")
warning("Please upgrade from facter ${::facterversion} to >= 1.7.2")
class { '::nginx::package::redhat':
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
default: {
fail("Module ${module_name} is not supported on ${::operatingsystem}")
}
package { 'nginx':
ensure => $package_ensure,
}
}
}
Expand Down
25 changes: 0 additions & 25 deletions manifests/package/archlinux.pp

This file was deleted.

50 changes: 26 additions & 24 deletions manifests/package/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,53 @@

$distro = downcase($::operatingsystem)

package { $package_name:
ensure => $package_ensure,
require => Anchor['nginx::apt_repo'],
package { 'nginx':
ensure => $package_ensure,
name => $package_name,
}

anchor { 'nginx::apt_repo' : }

if $manage_repo {
include '::apt'
Exec['apt_update'] -> Package['nginx']

case $package_source {
'nginx': {
'nginx', 'nginx-stable': {
apt::source { 'nginx':
location => "http://nginx.org/packages/${distro}",
repos => 'nginx',
key => '7BD9BF62',
key_source => 'http://nginx.org/keys/nginx_signing.key',
notify => Exec['apt_get_update_for_nginx'],
}
}
'nginx-mainline': {
apt::source { 'nginx':
location => "http://nginx.org/packages/mainline/${distro}",
repos => 'nginx',
key => '7BD9BF62',
key_source => 'http://nginx.org/keys/nginx_signing.key',
}
}
'passenger': {
ensure_resource('package', 'apt-transport-https', {'ensure' => 'present' })

apt::source { 'nginx':
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
repos => 'main',
key => '561F9B9CAC40B2F7',
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
notify => Exec['apt_get_update_for_nginx'],
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
repos => 'main',
key => '561F9B9CAC40B2F7',
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
required_packages => 'apt-transport-https ca-certificates',
}

package { 'passenger':
ensure => 'present',
require => Anchor['nginx::apt_repo'],
require => Exec['apt_update'],
}

if $package_name != 'nginx-extras' {
warning('You must set $package_name to "nginx-extras" to enable Passenger')
}
}
default: {}
}

exec { 'apt_get_update_for_nginx':
command => '/usr/bin/apt-get update',
timeout => 240,
returns => [ 0, 100 ],
refreshonly => true,
before => Anchor['nginx::apt_repo'],
default: {
fail("\$package_source must be 'nginx-stable', 'nginx-mainline' or 'passenger'. It was set to '${package_source}'")
}
}
}
}
12 changes: 0 additions & 12 deletions manifests/package/freebsd.pp

This file was deleted.

13 changes: 0 additions & 13 deletions manifests/package/gentoo.pp

This file was deleted.

12 changes: 0 additions & 12 deletions manifests/package/openbsd.pp

This file was deleted.

65 changes: 27 additions & 38 deletions manifests/package/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,51 @@
$manage_repo = true,
$package_ensure = 'present',
$package_name = 'nginx',
$package_source = 'nginx-stable',
) {

if $::lsbmajdistrelease {
$major_dist_release = $::lsbmajdistrelease
#Install the CentOS-specific packages on that OS, otherwise assume it's a RHEL
#clone and provide the Red Hat-specific package. This comes into play when not
#on RHEL or CentOS and $manage_repo is set manually to 'true'.
if $::operatingsystem == 'centos' {
$_os = 'centos'
} else {
$_os = 'rhel'
}
else {
$major_dist_release = $::operatingsystemmajrelease
}

case $::operatingsystem {
'fedora': {
# nginx.org does not supply RPMs for fedora
# fedora 18 provides 1.2.x packages
# fedora 19 has 1.4.x packages are in

# fedora 18 users will need to supply their own nginx 1.4 rpms and/or repo
if $::lsbmajdistrelease and $::lsbmajdistrelease < 19 {
notice("${::operatingsystem} ${::lsbmajdistrelease} does not supply nginx >= 1.4 packages")
}
}
default: {
case $major_dist_release {
5, 6, 7: {
$os_rel = $major_dist_release
}
default: {
# Amazon uses the year as the $::lsbmajdistrelease
$os_rel = 6
if $manage_repo {
case $package_source {
'nginx', 'nginx-stable': {
yumrepo { 'nginx-release':
baseurl => "http://nginx.org/packages/${_os}/${::operatingsystemmajrelease}/\$basearch/",
descr => 'nginx repo',
enabled => '1',
gpgcheck => '1',
priority => '1',
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
before => Package[$package_name],
}
}

# as of 2013-07-28
# http://nginx.org/packages/centos appears to be identical to
# http://nginx.org/packages/rhel
# no other dedicated dirs exist for platforms under $::osfamily == redhat
if $manage_repo {
'nginx-mainline': {
yumrepo { 'nginx-release':
baseurl => "http://nginx.org/packages/rhel/${os_rel}/\$basearch/",
baseurl => "http://nginx.org/packages/mainline/${_os}/${::operatingsystemmajrelease}/\$basearch/",
descr => 'nginx repo',
enabled => '1',
gpgcheck => '1',
priority => '1',
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
before => Package[$package_name],
}

file { '/etc/yum.repos.d/nginx-release.repo':
ensure => present,
require => Yumrepo['nginx-release'],
}
}
default: {
fail("\$package_source must be 'nginx-stable' or 'nginx-mainline'. It was set to '${package_source}'")
}
}
}

package { $package_name:
ensure => $package_ensure,
package { 'nginx':
ensure => $package_ensure,
name => $package_name,
}

}
29 changes: 0 additions & 29 deletions manifests/package/solaris.pp

This file was deleted.

Loading