Created
September 29, 2016 16:51
-
-
Save smbambling/e47c33a9330ec8f4a8385b9e40b62bc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Overview: Configure the Master Mirror for a site | |
# | |
# == Requirements: N/A | |
# | |
# == Monitoring: Apache | |
# | |
# == Notes: | |
# | |
# The repositories will be pulled down based off a hash for all crons. | |
# | |
#--- | |
#profile::mirror::master::repos: | |
# centos: | |
# source: 'mirrors.kernel.org::centos' - source to copy from | |
# includes: '' - string (or array) to be included | |
# excludes: '' - string (or array) to be excluded | |
# cron_hour: '' - The hour for the cron to run to stagger downloading things | |
# cron_minute: '' - The minute(s) you want to run | |
# | |
class profile::mirror::master ( | |
Boolean $monitoring = hiera("${name}::monitoring", true), | |
String $mirror_domain = hiera('profile::mirror::master::mirror_domain', "mirror.${::domain}"), | |
String $docroot = hiera('profile::mirror::master::docroot', '/opt/mirror/pub/'), | |
String $log_directory = hiera('profile::mirror::master::log_directory', '/var/log/mirror/'), | |
String $working_dir = hiera('profile::mirror::master::working_dir', '/opt/company/bin'), | |
String $syncer = hiera('profile::mirror::master::syncer', 'syncer'), | |
$rsync_repos = hiera_hash('profile::mirror::master::rsync_repos'), | |
$lftp_repos = hiera_hash('profile::mirror::master::lftp_repos'), | |
$reposync_repos = hiera_hash('profile::mirror::master::reposync_repos'), | |
) { | |
# Monitoring | |
if $monitoring { | |
profile::sensu::profile::checks {$name: | |
profile_name => $name, | |
} | |
} | |
file { '/opt/mirror/': | |
ensure => directory, | |
} -> | |
file { $docroot: | |
ensure => directory, | |
owner => $syncer, | |
group => $syncer, | |
} | |
file { $log_directory: | |
ensure => directory, | |
owner => $syncer, | |
group => $syncer, | |
} | |
# Ensuring packages necessary are present | |
package { 'lftp': | |
ensure => present, | |
} | |
ensure_resource('package', 'yum-utils', {'ensure' => 'present'}) | |
ensure_resource('package', 'createrepo', {'ensure' => 'present'}) | |
# Ensuring apache configuration for directory listing | |
apache::vhost { $mirror_domain: | |
servername => $mirror_domain, | |
serveraliases => [ $mirror_domain, 'mirror.companyx.net' ], | |
port => 80, | |
docroot => $docroot, | |
docroot_owner => $syncer, | |
docroot_group => $syncer, | |
directories => [ | |
{ | |
'path' => $docroot, | |
'options' => 'Indexes FollowSymLinks MultiViews', | |
'allowoverride' => 'None', | |
}, | |
], | |
require => File[$docroot], | |
} | |
# REPOSYNC Management | |
$reposync_repos.each| String $repository, Hash $repo_value|{ | |
#Cron configuration | |
$descr = $repo_value['descr'] | |
yumrepo { $repository: | |
name => $repository, | |
descr => "$descr - Disabled: Used w/ Reposync", | |
baseurl => $repo_value['baseurl'], | |
enabled => false, | |
gpgcheck => $repo_value['gpgcheck'], | |
gpgkey => $repo_value['gpgkey'], | |
includepkgs => $repo_value['includes'], | |
exclude => $repo_value['excludes'], | |
} | |
file { $repository: | |
path => "${working_dir}/${repository}_mirror.sh", | |
owner => $syncer, | |
group => $syncer, | |
mode => '0750', | |
content => template('profile/mirror/reposync_repo.erb'), | |
} | |
cron { $repository: | |
command => "${working_dir}/${repository}_mirror.sh", | |
user => $syncer, | |
hour => $repo_value['cron_hour'], | |
minute => $repo_value['cron_minute'], | |
} | |
} | |
# RSYNC Management | |
$rsync_repos.each |String $repository, Hash $repo_value|{ | |
# Cron configuration | |
file { $repository: | |
path => "${working_dir}/${repository}_mirror.sh", | |
owner => $syncer, | |
group => $syncer, | |
mode => '0750', | |
content => template('profile/mirror/rsync_repo.erb'), | |
} | |
cron { $repository: | |
command => "${working_dir}/${repository}_mirror.sh", | |
user => $syncer, | |
hour => $repo_value['cron_hour'], | |
minute => $repo_value['cron_minute'], | |
} | |
} | |
# LFTP Management | |
$lftp_repos.each |String $repository, Hash $repo_value|{ | |
# Cron configuration | |
file { $repository: | |
path => "${working_dir}/${repository}_mirror.sh", | |
owner => $syncer, | |
group => $syncer, | |
mode => '0750', | |
content => template('profile/mirror/lftp_repo.erb'), | |
} | |
cron { $repository: | |
command => "${working_dir}/${repository}_mirror.sh", | |
user => $syncer, | |
hour => $repo_value['cron_hour'], | |
minute => $repo_value['cron_minute'], | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment