Initial commit.

This commit is contained in:
Dan Prince 2014-05-27 10:35:34 -04:00
commit 4a2ba4e24c
6 changed files with 177 additions and 0 deletions

10
Modulefile Normal file
View File

@ -0,0 +1,10 @@
name 'openstackci-puppet-yum'
version '0.1.0'
source 'http://git.openstack.org/cgit/openstack-infra/puppet-yum/'
author 'Dan Prince'
license 'Apache License 2.0'
summary 'Create lightweight Yum repositories'
description 'Puppet module to help manage/create lightweight Yum repositories'
project_page 'https://launchpad.net/openstack-infra'
dependency 'puppetlabs-apache', '>= 0.0.4'

16
README Normal file
View File

@ -0,0 +1,16 @@
puppet-yum
A module to help manage lightweight Yum mirrors
Example:
# A lightweight Fedora 20 x86_64 updates binary only mirror
# Mirror URL paths are provided to follow the normal Fedora mirroring
# conventions to allow for easy baseurl configuration
yum::repo { 'f20-x86_64-updates-testing':
description => 'Fedora 20 - x86_64 - Updates Testing',
mirrorlist => 'https://mirrors.fedoraproject.org/metalink?repo=updates-tes
cron_hour => 0,
cron_minute => 15,
url_path => 'fedora/updates/testing/20/x86_64/',
}

32
manifests/init.pp Normal file
View File

@ -0,0 +1,32 @@
# Copyright 2014 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class: yum
#
class yum (
$repos_dir = '/srv/yum_repos/'
) {
package { ['yum-utils', 'createrepo']:
ensure => 'present'
}
file { $repos_dir:
ensure => directory,
mode => '0755',
owner => 'root',
group => 'root'
}
}

30
manifests/mirror.pp Normal file
View File

@ -0,0 +1,30 @@
# Copyright 2014 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class: yum::mirror
#
class yum::mirror (
$vhost_name = $::fqdn,
) {
include yum
include apache
apache::vhost { $vhost_name:
port => 80,
docroot => $yum::repos_dir,
template => 'yum/vhost.erb',
}
}

64
manifests/repo.pp Normal file
View File

@ -0,0 +1,64 @@
# Copyright 2014 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class: yum::repo
#
define yum::repo (
$description = '',
$url_path = false,
$enabled = 0,
$gpgcheck = 0,
$baseurl = absent,
$mirrorlist = absent,
$cron_hour = 2,
$cron_minute = 0,
) {
include 'yum'
yumrepo { $name:
name => $name,
descr => $description,
enabled => $enabled,
gpgcheck => $gpgcheck,
baseurl => $baseurl,
mirrorlist => $mirrorlist
}
cron { "reposync ${name}":
command => "/usr/bin/reposync -r ${name} -p ${yum::repos_dir}; /usr/bin/createrepo -c /tmp/${name} ${yum::repos_dir}/${name}",
hour => $cron_hour,
minute => $cron_minute
}
if $url_path {
# here we softlink to the actual createrepo dir created above so
# that the normal mirror locations can be preserved as provided
exec { "create ${url_path} url path dir":
path => '/usr/local/bin:/usr/bin:/bin/',
command => "mkdir -p $(dirname '${yum::repos_dir}/${url_path}')",
unless => "test -d $(dirname '${yum::repos_dir}/${url_path}')",
before => File["${name} repo softlink"],
}
file { "${name} repo softlink":
ensure => 'link',
path => "${yum::repos_dir}/${url_path}",
target => "${yum::repos_dir}/${name}"
}
}
}

25
templates/vhost.erb Normal file
View File

@ -0,0 +1,25 @@
# ************************************
# Managed by Puppet
# ************************************
NameVirtualHost <%= vhost_name %>:<%= port %>
<VirtualHost <%= vhost_name %>:<%= port %>>
ServerName <%= srvname %>
<% if serveraliases.is_a? Array -%>
<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif serveraliases != '' -%>
<%= " ServerAlias #{serveraliases}" %>
<% end -%>
DocumentRoot <%= docroot %>
<Directory <%= docroot %>>
Options <%= options %>
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/<%= name %>_error.log
LogLevel warn
CustomLog /var/log/httpd/<%= name %>_access.log combined
ServerSignature Off
</VirtualHost>