-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a606525
Showing
30 changed files
with
1,008 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
source ENV['GEM_SOURCE'] || 'https://rubygems.org' | ||
|
||
puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3'] | ||
gem 'metadata-json-lint' | ||
gem 'puppet', puppetversion | ||
gem 'puppetlabs_spec_helper', '>= 1.0.0' | ||
gem 'puppet-lint', '>= 1.0.0' | ||
gem 'facter', '>= 1.7.0' | ||
gem 'rspec-puppet' | ||
|
||
# rspec must be v2 for ruby 1.8.7 | ||
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' | ||
gem 'rspec', '~> 2.0' | ||
gem 'rake', '~> 10.0' | ||
else | ||
# rubocop requires ruby >= 1.9 | ||
gem 'rubocop' | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# mirror_repos | ||
|
||
#### Table of Contents | ||
|
||
1. [Description](#description) | ||
2. [Setup - The basics of getting started with mirror_repos](#setup) | ||
* [Beginning with mirror_repos](#beginning-with-mirror_repos) | ||
3. [Usage - Configuration options and additional functionality](#examples) | ||
4. [Reference - An under-the-hood peek at what the module is doing and how](#reference) | ||
5. [Limitations - OS compatibility, etc.](#limitations) | ||
6. [Development - Guide for contributing to the module](#development) | ||
|
||
## Description | ||
|
||
`puppetlabs-apache` module if you want to manage vhost within this module. | ||
apache module create a http proxy with fqdn of the hostname. | ||
|
||
This module copy all available rpms from given repo_source using reposync and | ||
then create repository using createrepo from all rpms. | ||
|
||
## Setup | ||
|
||
Repo configuration should be a Hash in following format | ||
`mirror_repos::repos:` must be followed by `OS-ARCH` and then | ||
name of the repo and configuration of repo | ||
|
||
### Beginning with mirror_repos | ||
|
||
This module copy a bash script `update-repos` to /usr/sbin. | ||
This script runs every night to sync remote repos. | ||
This script has many options, to know more do `/usr/sbin/update-repos -h`. | ||
|
||
#### Examples | ||
|
||
##### | ||
|
||
It is highly recommended to define repos in Hiera. | ||
``` | ||
mirror_repos::config_dir: '/etc/repos' | ||
mirror_repos::repos_dir: '/n/repos' | ||
mirror_repos::repos: | ||
centos7-x86_64: | ||
base: | ||
baseurl: 'http://mirrors.tripadvisor.com/centos/7/os/x86_64/' | ||
gpgkey: 'http://mirrors.tripadvisor.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7' | ||
enabled: 1 | ||
centos6-x86_64: | ||
base: | ||
baseurl: 'http://mirror.centos.org/centos-6/6/os/x86_64/' | ||
enabled: 0 | ||
``` | ||
|
||
## Reference | ||
|
||
#### Parameters | ||
|
||
The following parameters are available in the `mirror_repos` class. | ||
|
||
##### `packages` | ||
|
||
Data type: `Array` | ||
|
||
|
||
|
||
Default value: $mirror_repos::params::packages | ||
|
||
##### `repos` | ||
|
||
Data type: `Hash` | ||
|
||
|
||
|
||
Default value: $mirror_repos::params::repos | ||
|
||
##### `vhosts` | ||
|
||
Data type: `Hash` | ||
|
||
|
||
Default value: $mirror_repos::params::vhosts | ||
|
||
##### `config_dir` | ||
|
||
Data type: `String` | ||
|
||
|
||
Default value: $mirror_repos::params::config_dir | ||
|
||
##### `repos_dir` | ||
|
||
Data type: `String` | ||
|
||
|
||
Default value: $mirror_repos::params::repos_dir | ||
|
||
##### `manage_vhost` | ||
|
||
Data type: `Boolean` | ||
|
||
|
||
Default value: $mirror_repos::params::manage_vhost | ||
|
||
|
||
### mirror_repos::apache | ||
|
||
The mirror_repos::apache class. | ||
|
||
### mirror_repos::config | ||
|
||
== Class mirror_repos::config | ||
|
||
This class is called from mirror_repos | ||
|
||
### mirror_repos::install | ||
|
||
The mirror_repos::install class. | ||
|
||
### mirror_repos::params | ||
|
||
The mirror_repos::params class. | ||
|
||
## Limitations | ||
|
||
This Module is tested on RedHat7 and CentOS7. | ||
|
||
## Development | ||
|
||
For contributing Fork this module and open PR. | ||
|
||
Authors | ||
------- | ||
|
||
Bhanu Prasad G <[email protected]> | ||
|
||
Copyright | ||
--------- | ||
Copyright [2018] [Bhanu Prasad G] | ||
|
||
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. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
require 'metadata-json-lint/rake_task' | ||
|
||
if RUBY_VERSION >= '1.9' | ||
require 'rubocop/rake_task' | ||
RuboCop::RakeTask.new | ||
end | ||
|
||
PuppetLint.configuration.send('disable_80chars') | ||
PuppetLint.configuration.relative = true | ||
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp'] | ||
|
||
desc 'Validate manifests, templates, and ruby files' | ||
task :validate do | ||
Dir['manifests/**/*.pp'].each do |manifest| | ||
sh "puppet parser validate --noop #{manifest}" | ||
end | ||
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| | ||
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures} | ||
end | ||
Dir['templates/**/*.erb'].each do |template| | ||
sh "erb -P -x -T '-' #{template} | ruby -c" | ||
end | ||
end | ||
|
||
desc 'Run metadata_lint, lint, validate, and spec tests.' | ||
task :test do | ||
[:metadata_lint, :lint, :validate, :spec].each do |test| | ||
Rake::Task[test].invoke | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# The baseline for module testing used by Puppet Labs is that each manifest | ||
# should have a corresponding test manifest that declares that class or defined | ||
# type. | ||
# | ||
# Tests are then run by using puppet apply --noop (to check for compilation | ||
# errors and view a log of events) or by fully applying the test in a virtual | ||
# environment (to compare the resulting system state to the desired state). | ||
# | ||
# Learn more about module testing here: | ||
# https://docs.puppet.com/guides/tests_smoke.html | ||
# | ||
include ::mirror_repos |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class mirror_repos::apache { | ||
if $mirror_repos::manage_vhost { | ||
include ::apache | ||
include ::apache::mod::proxy | ||
|
||
if $mirror_repos::vhosts == {} { | ||
apache::vhost { $::fqdn: | ||
port => '80', | ||
docroot => $mirror_repos::repos_dir, | ||
} | ||
} | ||
else { | ||
create_resources('apache::vhost',$mirror_repos::vhosts) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# == Class mirror_repos::config | ||
# | ||
# This class is called from mirror_repos | ||
# | ||
class mirror_repos::config { | ||
#just replicate yum.repos.d | ||
file { [ $mirror_repos::config_dir, $mirror_repos::repos_dir ]: | ||
ensure => directory, | ||
} | ||
#create a dir for each OS and then a file for each repo under that OS | ||
$mirror_repos::repos.each |String $os_name , $repos_os | { | ||
$os = regsubst($os_name, '[-]', '_', 'G') | ||
file {"${mirror_repos::config_dir}/${os}.conf": | ||
ensure => 'file', | ||
mode => '0644', | ||
content => template('mirror_repos/repo.conf.erb'), | ||
} | ||
} | ||
$oses = keys($mirror_repos::repos) | ||
#copy file to update repos to localhost | ||
file { '/usr/sbin/update-repos': | ||
ensure => file, | ||
mode => '0755', | ||
content => template('mirror_repos/update-repos.sh.erb'), | ||
} | ||
#run cron every night to update repos | ||
cron { 'update-repos': | ||
command => '/usr/sbin/update-repos', | ||
user => 'root', | ||
hour => 1, | ||
minute => 0, | ||
require => File['/usr/sbin/update-repos'], | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Class: mirror_repos | ||
# =========================== | ||
# | ||
# Full description of class mirror_repos here. | ||
# | ||
# Parameters | ||
# ---------- | ||
# | ||
# * `mirror_repos::vhost` | ||
# create apache vhost with this name. Default is FQDN | ||
# | ||
# Variables | ||
# ---------- | ||
# | ||
# * `mirror_repos::config_dir` | ||
# Where to deploy the repo configuration files. | ||
# Default is `/etc/mirror.repos.d` | ||
# | ||
# * `mirror_repos::repos_dir` | ||
# Where to store the mirrorred repos | ||
# Default is `/repos` | ||
# | ||
# * `mirror_repos::repos` | ||
# repositories to mirror | ||
# Default is empty | ||
# | ||
# Examples | ||
# #### | ||
# -------- | ||
# | ||
# @example | ||
# class { 'mirror_repos': | ||
# config_dir => '/etc/repos_conf', | ||
# } | ||
# | ||
# | ||
class mirror_repos ( | ||
Array $packages = $mirror_repos::params::packages, | ||
Hash $repos = $mirror_repos::params::repos, | ||
Hash $vhosts = $mirror_repos::params::vhosts, | ||
String $config_dir = $mirror_repos::params::config_dir, | ||
String $repos_dir = $mirror_repos::params::repos_dir, | ||
Boolean $manage_vhost = $mirror_repos::params::manage_vhost, | ||
) inherits mirror_repos::params { | ||
|
||
class { '::mirror_repos::install': } | ||
-> class { '::mirror_repos::config': } | ||
-> class { '::mirror_repos::apache': } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class mirror_repos::install { | ||
package { $mirror_repos::packages: | ||
ensure => present, | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class mirror_repos::params { | ||
case $::osfamily { | ||
'RedHat': { | ||
$packages = ['createrepo', 'yum-utils'] | ||
$manage_vhost = true | ||
$vhosts = {} | ||
$config_dir = '/etc/mirror.repos.d' | ||
$repos_dir = '/repos' | ||
$repos = {} | ||
} | ||
default: { | ||
fail("${::operatingsystem} not supported") | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "bp85-mirror_repos", | ||
"version": "0.1.0", | ||
"author": "bp85", | ||
"summary": "Mirror yum repositories to local + and create yum repos from those", | ||
"license": "Apache-2.0", | ||
"source": "https://github.com/bp85/puppet-mirror_repos", | ||
"project_page": "https://github.com/bp85/puppet-mirror_repos", | ||
"issues_url": "https://github.com/bp85/puppet-mirror_repos/issues", | ||
"dependencies": [ | ||
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}, | ||
{"name":"puppetlabs-apache","version_requirement":">=1.11.0"} | ||
], | ||
"data_provider": null | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
source ENV['GEM_SOURCE'] || 'https://rubygems.org' | ||
|
||
puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3'] | ||
gem 'metadata-json-lint' | ||
gem 'puppet', puppetversion | ||
gem 'puppetlabs_spec_helper', '>= 1.0.0' | ||
gem 'puppet-lint', '>= 1.0.0' | ||
gem 'facter', '>= 1.7.0' | ||
gem 'rspec-puppet' | ||
|
||
# rspec must be v2 for ruby 1.8.7 | ||
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' | ||
gem 'rspec', '~> 2.0' | ||
gem 'rake', '~> 10.0' | ||
else | ||
# rubocop requires ruby >= 1.9 | ||
gem 'rubocop' | ||
end |
Oops, something went wrong.