Skip to content

Commit 9a8c690

Browse files
committed
Merge pull request voxpupuli#519 from 3flex/refactor-packages
Clean up package classes, allow installing mainline upstream packages
2 parents 178abdd + 3bdf63d commit 9a8c690

23 files changed

+148
-469
lines changed

README.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This module manages NGINX configuration.
1818
### Requirements
1919

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

2324
### Install and bootstrap an NGINX instance

manifests/init.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@
100100

101101
### START Package Configuration ###
102102
$package_ensure = present,
103-
$package_name = 'nginx',
103+
$package_name = $::nginx::params::package_name,
104104
$package_source = 'nginx',
105-
$manage_repo = true,
105+
$manage_repo = $::nginx::params::manage_repo,
106106
### END Package Configuration ###
107107

108108
### START Service Configuation ###
@@ -120,7 +120,7 @@
120120
$nginx_vhosts = {},
121121
$nginx_vhosts_defaults = {},
122122
### END Hiera Lookups ###
123-
) {
123+
) inherits ::nginx::params {
124124

125125
### DEPRECATION WARNING ###
126126
###

manifests/package.pp

+15-59
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#
1515
# This class file is not called directly
1616
class nginx::package(
17-
$package_name = 'nginx',
17+
$package_name = $::nginx::params::package_name,
1818
$package_source = 'nginx',
1919
$package_ensure = 'present',
20-
$manage_repo = true,
21-
) {
20+
$manage_repo = $::nginx::params::manage_repo,
21+
) inherits ::nginx::params {
2222

2323
anchor { 'nginx::package::begin': }
2424
anchor { 'nginx::package::end': }
@@ -27,6 +27,7 @@
2727
'redhat': {
2828
class { '::nginx::package::redhat':
2929
manage_repo => $manage_repo,
30+
package_source => $package_source,
3031
package_ensure => $package_ensure,
3132
package_name => $package_name,
3233
require => Anchor['nginx::package::begin'],
@@ -43,67 +44,22 @@
4344
before => Anchor['nginx::package::end'],
4445
}
4546
}
46-
'suse': {
47-
class { '::nginx::package::suse':
48-
package_name => $package_name,
49-
require => Anchor['nginx::package::begin'],
50-
before => Anchor['nginx::package::end'],
51-
}
52-
}
53-
'archlinux': {
54-
class { '::nginx::package::archlinux':
55-
require => Anchor['nginx::package::begin'],
56-
before => Anchor['nginx::package::end'],
57-
}
58-
}
5947
'Solaris': {
60-
class { '::nginx::package::solaris':
61-
package_name => $package_name,
62-
package_source => $package_source,
63-
package_ensure => $package_ensure,
64-
require => Anchor['nginx::package::begin'],
65-
before => Anchor['nginx::package::end'],
66-
}
67-
}
68-
'FreeBSD': {
69-
class { '::nginx::package::freebsd':
70-
package_name => $package_name,
71-
package_ensure => $package_ensure,
72-
require => Anchor['nginx::package::begin'],
73-
before => Anchor['nginx::package::end'],
74-
}
75-
}
76-
'Gentoo': {
77-
class { '::nginx::package::gentoo':
78-
package_name => $package_name,
79-
package_ensure => $package_ensure,
80-
require => Anchor['nginx::package::begin'],
81-
before => Anchor['nginx::package::end'],
48+
# $package_name needs to be specified. SFEnginx,CSWnginx depending on
49+
# where you get it.
50+
if $package_name == undef {
51+
fail('You must supply a value for $package_name on Solaris')
8252
}
83-
}
84-
'OpenBSD': {
85-
class { '::nginx::package::openbsd':
86-
package_name => $package_name,
87-
package_ensure => $package_ensure,
88-
require => Anchor['nginx::package::begin'],
89-
before => Anchor['nginx::package::end'],
53+
54+
package { 'nginx':
55+
ensure => $package_ensure,
56+
name => $package_name,
57+
source => $package_source,
9058
}
9159
}
9260
default: {
93-
case $::operatingsystem {
94-
'amazon': {
95-
# Amazon was added to osfamily RedHat in 1.7.2
96-
# https://github.com/puppetlabs/facter/commit/c12d3b6c557df695a7b2b009da099f6a93c7bd31#lib/facter/osfamily.rb
97-
warning("Module ${module_name} support for ${::operatingsystem} with facter < 1.7.2 is deprecated")
98-
warning("Please upgrade from facter ${::facterversion} to >= 1.7.2")
99-
class { '::nginx::package::redhat':
100-
require => Anchor['nginx::package::begin'],
101-
before => Anchor['nginx::package::end'],
102-
}
103-
}
104-
default: {
105-
fail("Module ${module_name} is not supported on ${::operatingsystem}")
106-
}
61+
package { 'nginx':
62+
ensure => $package_ensure,
10763
}
10864
}
10965
}

manifests/package/archlinux.pp

-25
This file was deleted.

manifests/package/debian.pp

+26-24
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,53 @@
2222

2323
$distro = downcase($::operatingsystem)
2424

25-
package { $package_name:
26-
ensure => $package_ensure,
27-
require => Anchor['nginx::apt_repo'],
25+
package { 'nginx':
26+
ensure => $package_ensure,
27+
name => $package_name,
2828
}
2929

30-
anchor { 'nginx::apt_repo' : }
31-
3230
if $manage_repo {
3331
include '::apt'
32+
Exec['apt_update'] -> Package['nginx']
3433

3534
case $package_source {
36-
'nginx': {
35+
'nginx', 'nginx-stable': {
3736
apt::source { 'nginx':
3837
location => "http://nginx.org/packages/${distro}",
3938
repos => 'nginx',
4039
key => '7BD9BF62',
4140
key_source => 'http://nginx.org/keys/nginx_signing.key',
42-
notify => Exec['apt_get_update_for_nginx'],
41+
}
42+
}
43+
'nginx-mainline': {
44+
apt::source { 'nginx':
45+
location => "http://nginx.org/packages/mainline/${distro}",
46+
repos => 'nginx',
47+
key => '7BD9BF62',
48+
key_source => 'http://nginx.org/keys/nginx_signing.key',
4349
}
4450
}
4551
'passenger': {
46-
ensure_resource('package', 'apt-transport-https', {'ensure' => 'present' })
47-
4852
apt::source { 'nginx':
49-
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
50-
repos => 'main',
51-
key => '561F9B9CAC40B2F7',
52-
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
53-
notify => Exec['apt_get_update_for_nginx'],
53+
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
54+
repos => 'main',
55+
key => '561F9B9CAC40B2F7',
56+
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
57+
required_packages => 'apt-transport-https ca-certificates',
5458
}
5559

5660
package { 'passenger':
5761
ensure => 'present',
58-
require => Anchor['nginx::apt_repo'],
62+
require => Exec['apt_update'],
63+
}
64+
65+
if $package_name != 'nginx-extras' {
66+
warning('You must set $package_name to "nginx-extras" to enable Passenger')
5967
}
6068
}
61-
default: {}
62-
}
63-
64-
exec { 'apt_get_update_for_nginx':
65-
command => '/usr/bin/apt-get update',
66-
timeout => 240,
67-
returns => [ 0, 100 ],
68-
refreshonly => true,
69-
before => Anchor['nginx::apt_repo'],
69+
default: {
70+
fail("\$package_source must be 'nginx-stable', 'nginx-mainline' or 'passenger'. It was set to '${package_source}'")
71+
}
7072
}
7173
}
7274
}

manifests/package/freebsd.pp

-12
This file was deleted.

manifests/package/gentoo.pp

-13
This file was deleted.

manifests/package/openbsd.pp

-12
This file was deleted.

manifests/package/redhat.pp

+27-38
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,51 @@
1717
$manage_repo = true,
1818
$package_ensure = 'present',
1919
$package_name = 'nginx',
20+
$package_source = 'nginx-stable',
2021
) {
2122

22-
if $::lsbmajdistrelease {
23-
$major_dist_release = $::lsbmajdistrelease
23+
#Install the CentOS-specific packages on that OS, otherwise assume it's a RHEL
24+
#clone and provide the Red Hat-specific package. This comes into play when not
25+
#on RHEL or CentOS and $manage_repo is set manually to 'true'.
26+
if $::operatingsystem == 'centos' {
27+
$_os = 'centos'
28+
} else {
29+
$_os = 'rhel'
2430
}
25-
else {
26-
$major_dist_release = $::operatingsystemmajrelease
27-
}
28-
29-
case $::operatingsystem {
30-
'fedora': {
31-
# nginx.org does not supply RPMs for fedora
32-
# fedora 18 provides 1.2.x packages
33-
# fedora 19 has 1.4.x packages are in
3431

35-
# fedora 18 users will need to supply their own nginx 1.4 rpms and/or repo
36-
if $::lsbmajdistrelease and $::lsbmajdistrelease < 19 {
37-
notice("${::operatingsystem} ${::lsbmajdistrelease} does not supply nginx >= 1.4 packages")
38-
}
39-
}
40-
default: {
41-
case $major_dist_release {
42-
5, 6, 7: {
43-
$os_rel = $major_dist_release
44-
}
45-
default: {
46-
# Amazon uses the year as the $::lsbmajdistrelease
47-
$os_rel = 6
32+
if $manage_repo {
33+
case $package_source {
34+
'nginx', 'nginx-stable': {
35+
yumrepo { 'nginx-release':
36+
baseurl => "http://nginx.org/packages/${_os}/${::operatingsystemmajrelease}/\$basearch/",
37+
descr => 'nginx repo',
38+
enabled => '1',
39+
gpgcheck => '1',
40+
priority => '1',
41+
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
42+
before => Package[$package_name],
4843
}
4944
}
50-
51-
# as of 2013-07-28
52-
# http://nginx.org/packages/centos appears to be identical to
53-
# http://nginx.org/packages/rhel
54-
# no other dedicated dirs exist for platforms under $::osfamily == redhat
55-
if $manage_repo {
45+
'nginx-mainline': {
5646
yumrepo { 'nginx-release':
57-
baseurl => "http://nginx.org/packages/rhel/${os_rel}/\$basearch/",
47+
baseurl => "http://nginx.org/packages/mainline/${_os}/${::operatingsystemmajrelease}/\$basearch/",
5848
descr => 'nginx repo',
5949
enabled => '1',
6050
gpgcheck => '1',
6151
priority => '1',
6252
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
6353
before => Package[$package_name],
6454
}
65-
66-
file { '/etc/yum.repos.d/nginx-release.repo':
67-
ensure => present,
68-
require => Yumrepo['nginx-release'],
69-
}
55+
}
56+
default: {
57+
fail("\$package_source must be 'nginx-stable' or 'nginx-mainline'. It was set to '${package_source}'")
7058
}
7159
}
7260
}
7361

74-
package { $package_name:
75-
ensure => $package_ensure,
62+
package { 'nginx':
63+
ensure => $package_ensure,
64+
name => $package_name,
7665
}
7766

7867
}

manifests/package/solaris.pp

-29
This file was deleted.

0 commit comments

Comments
 (0)