Skip to content

Commit

Permalink
Merge 3bb763f into e1fa7ac
Browse files Browse the repository at this point in the history
  • Loading branch information
petems committed Dec 9, 2016
2 parents e1fa7ac + 3bb763f commit 61ef451
Show file tree
Hide file tree
Showing 16 changed files with 283 additions and 225 deletions.
45 changes: 39 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Install and configure a basic mrepo installation

Override default values and enable redhat network support for use in other classes

class { 'mrepo::params':
class { 'mrepo':
selinux => true,
rhn => true,
rhn_username => 'user',
Expand All @@ -29,10 +29,10 @@ Or using Hiera for parameters (same example)
class { 'mrepo': }

Hiera:
mrepo::params::selinux: true
mrepo::params::rhn: true
mrepo::params::rhn_username: user
mrepo::params::rhn_password: pass
mrepo::selinux: true
mrepo::rhn: true
mrepo::rhn_username: user
mrepo::rhn_password: pass

Mirror multiple centos 5 repositories

Expand Down Expand Up @@ -86,7 +86,7 @@ Mirror multiple rhel channels

## Usage ##

If you need to customize the mrepo default settings, include the mrepo::params
If you need to customize the mrepo default settings, include the mrepo
class and include the appropriate variables. Else, you should be able to use
the mrepo::repo by itself to instantiate repositories.

Expand Down Expand Up @@ -162,6 +162,39 @@ page](https://github.com/dagwieers/mrepo/blob/master/docs/usage.txt).

## Caveats ##

### Params Pattern ###

This module was previously using a pattern

It now follows the params pattern, where parameters are set in the params
class as default, inherited, then overwritten as needed when calling the base class.

#### Before:

Using classes

```puppet
class { '::mrepo::params':
selinux => true,
rhn => true,
rhn_username => 'user',
rhn_password => 'pass',
}
```


After:

```puppet
class { '::mrepo':
selinux => true,
rhn => true,
rhn_username => 'user',
rhn_password => 'pass',
}
```


### SELinux ###

Default SELinux policy prevents the httpd context from manipulating loopback
Expand Down
4 changes: 1 addition & 3 deletions examples/rhn.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class { '::mrepo::params':
class { '::mrepo':
rhn => true,
rhn_username => 'test',
rhn_password => 'test',
}

include ::mrepo::rhn
3 changes: 1 addition & 2 deletions examples/selinux.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class { '::mrepo::params':
class { '::mrepo':
selinux => true,
}
include ::mrepo::selinux
1 change: 0 additions & 1 deletion manifests/exports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# Copyright 2012 Puppet Labs, unless otherwise noted
#
class mrepo::exports($clients) {
include ::mrepo::params

$file_path = '/usr/local/sbin/export-mrepo'

Expand Down
188 changes: 169 additions & 19 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,101 @@
# outside of puppet and only want dependencies to be installed, then include
# this class.
#
# Parameters:
# [*src_root*]
# The path to store the mrepo mirror data.
# Default: /var/mrepo
#
# == Parameters
# [*www_root*]
# The path of the mrepo html document root.
# Default: /var/www/mrepo
#
# repo_hash = undef (Default)
# Hash with repo definitions to create
# These can also be provided via Hiera
# [*www_ip*]
# Which IP address to use when www_ip_based is set.
# Default: $::ipaddress
#
# Other optional parameters can be found in the mrepo::params class
# [*www_ip_based*]
# Whether to use IP-based virtual hosts or not.
# Default: false
#
# [*user*]
# The account to use for mirroring the files.
# Default: apache
#
# [*group*]
# The group to use for mirroring the files.
# Default: apache
#
# [*source*]
# The package source.
# Default: package
# Values: git, package
#
# [*ensure_src*]
# Ensure value for the package source.
# Note that with source set to 'git', setting ensure_src to 'latest'
# may cause module-removed source files (e.g. httpd mrepo.conf) to be restored
# Default: latest
# Values: latest, present, absent
#
# [*selinux*]
# Whether to update the selinux context for the mrepo document root.
# Default: the selinux fact.
# Values: true, false
#
# [*rhn*]
# Whether to install RedHat dependencies or not. Defaults to false.
# Default: false
# Values: true, false
#
# [*rhn_config*]
# Whether to install RedHat dependencies for RHN on RHEL. Defaults to false.
# Note: Irrelevant (assumed true) for CentOS servers with rhn=true.
# Default: false
# Values: true, false
#
# [*rhn_username*]
# The Redhat Network username. Must be set if the param rhn is true.
#
# [*rhn_password*]
# The Redhat Network password. Must be set if the param rhn is true.
#
# [*rhnget_cleanup*]
# Clean up packages that are not on the sending side?
# Default: undef
# Values: undef, true, false
#
# [*rhnget_download_all*]
# Download older versions of packages?
# Default: undef
# Values: undef, true, false
#
# [*genid_command*]
# The base command to use to generate a systemid for RHN (mrepo::repo::rhn).
# Default: /usr/bin/gensystemid
#
# [*mailto*]
# The email recipient for mrepo updates. Defaults to unset, meaning no email will be sent.
#
# [*mailfrom*]
# The email sender for mrepo updates. Defaults to unset, meaning mrepo will use its default of `mrepo@`_fqdn_.
#
# [*smtpserver*]
# The SMTP server to use for sending update emails. Defaults to unset, meaning mrepo will use its default of `localhost`.
#
# == Examples
#
# node default {
# class { "mrepo":
# src_root => '/srv/mrepo',
# www_root => '/srv/www/mrepo',
# user => 'www-user',
# source => 'package',
# rhn => true,
# rhn_username => 'user',
# rhn_password => 'pass',
# }
# }
#
# == Examples
#
Expand All @@ -28,29 +115,92 @@
#
# Copyright 2011 Puppet Labs, unless otherwise noted
#
class mrepo {
class mrepo (
$src_root = $::mrepo::params::src_root,
$www_root = $::mrepo::params::www_root,
$www_servername = $::mrepo::params::www_servername,
$www_ip = $::mrepo::params::www_ip,
$www_ip_based = $::mrepo::params::www_ip_based,
$user = $::mrepo::params::user,
$group = $::mrepo::params::group,
$source = $::mrepo::params::source,
$ensure_src = $::mrepo::params::ensure_src,
$selinux = $::mrepo::params::selinux,
$rhn = $::mrepo::params::rhn,
$rhn_config = $::mrepo::params::rhn_config,
$rhn_username = $::mrepo::params::rhn_username,
$rhn_password = $::mrepo::params::rhn_password,
$rhnget_cleanup = $::mrepo::params::rhnget_cleanup,
$rhnget_download_all = $::mrepo::params::rhnget_download_all,
$genid_command = $::mrepo::params::genid_command,
$mailto = $::mrepo::params::mailto,
$mailfrom = $::mrepo::params::mailfrom,
$smtpserver = $::mrepo::params::smtpserver,
$git_proto = $::mrepo::params::git_proto,
$descriptions = $::mrepo::params::descriptions,
$http_proxy = $::mrepo::params::http_proxy,
$https_proxy = $::mrepo::params::https_proxy,
$priority = $::mrepo::params::priority,
$port = $::mrepo::params::port,
$selinux_context = $::mrepo::params::selinux_context,
) inherits ::mrepo::params {

validate_re($source, '^git$|^package$')
validate_re($git_proto, '^git$|^https$')
validate_re($priority, '^\d+$')
validate_re($port, '^\d+$')
validate_bool($rhn)
validate_hash($descriptions)

assert_private('You can no longer refer to the mrepo::params class directly, see https://github.com/voxpupuli/puppet-mrepo#caveats for more details')

if $mailto {
validate_email_address($mailto)
}
if $mailfrom {
validate_email_address($mailfrom)
}

if $rhn {
validate_re($rhn_username, '.+')
validate_re($rhn_password, '.+')
}

if $rhnget_cleanup != undef {
validate_bool($rhnget_cleanup)
}
if $rhnget_download_all != undef {
validate_bool($rhnget_download_all)
}

# Validate selinux usage. If manually set, validate as a bool and use that value.
# If undefined and selinux is present and not disabled, use selinux.
case $mrepo::selinux {
undef: {
case $::selinux {
'enforcing', 'permissive': {
$use_selinux = true
}
'disabled', default: {
$use_selinux = false
}
}
}
default: {
validate_bool($selinux)
$use_selinux = $selinux
}
}

include ::mrepo::package
include ::mrepo::rhn
include ::mrepo::webservice
include ::mrepo::selinux

anchor { 'mrepo::begin':
before => Class['mrepo::package'],
}

Class['mrepo::params'] -> Class['mrepo::package']
Class['mrepo::package'] -> Class['mrepo::webservice']
Class['mrepo::package'] -> Class['mrepo::rhn']
Class['mrepo::package'] -> Class['mrepo::selinux']
Class['mrepo::webservice'] -> Class['mrepo::selinux']

anchor { 'mrepo::end':
require => [
Class['mrepo::package'],
Class['mrepo::webservice'],
Class['mrepo::selinux'],
Class['mrepo::rhn'],
],
}
}

4 changes: 2 additions & 2 deletions manifests/iso.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Downloads isos
define mrepo::iso($source_url, $repo) {

include ::mrepo::params
include ::mrepo

$target_file = "${mrepo::params::src_root}/iso/${name}"
$target_file = "${mrepo::src_root}/iso/${name}"

staging::file { $name:
source => "${source_url}/${name}",
Expand Down
31 changes: 15 additions & 16 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# == Parameters
#
# Optional parameters can be found in the mrepo::params class
# None
#
# == Examples
#
Expand All @@ -18,13 +18,12 @@
#
class mrepo::package {

include ::mrepo::params
$user = $mrepo::user
$group = $mrepo::group
$source = $mrepo::source
$proto = $mrepo::git_proto
$ensure = $mrepo::ensure_src

$user = $mrepo::params::user
$group = $mrepo::params::group
$source = $mrepo::params::source
$proto = $mrepo::params::git_proto
$ensure = $mrepo::params::ensure_src
case $source {
'git': {
vcsrepo { '/usr/src/mrepo':
Expand Down Expand Up @@ -54,15 +53,15 @@

# mrepo.conf template params
#
$src_root = $mrepo::params::src_root
$www_root = $mrepo::params::www_root
$rhn_username = $mrepo::params::rhn_username
$rhn_password = $mrepo::params::rhn_password
$rhnget_cleanup = $mrepo::params::rhnget_cleanup
$rhnget_download_all = $mrepo::params::rhnget_download_all
$mailto = $mrepo::params::mailto
$http_proxy = $mrepo::params::http_proxy
$https_proxy = $mrepo::params::https_proxy
$src_root = $mrepo::src_root
$www_root = $mrepo::www_root
$rhn_username = $mrepo::rhn_username
$rhn_password = $mrepo::rhn_password
$rhnget_cleanup = $mrepo::rhnget_cleanup
$rhnget_download_all = $mrepo::rhnget_download_all
$mailto = $mrepo::mailto
$http_proxy = $mrepo::http_proxy
$https_proxy = $mrepo::https_proxy

file { '/etc/mrepo.conf':
ensure => present,
Expand Down

0 comments on commit 61ef451

Please sign in to comment.