From 0fc013377b07b4ffb4195243d36911438c5b9b4d Mon Sep 17 00:00:00 2001 From: Michael Chapman Date: Thu, 14 Aug 2014 01:05:08 +1000 Subject: [PATCH] Add hash based repository management This patch adds support for managing repos for major distros, separated by osfamily at the top level and operatingsystem below that. Since redhat, fedora and centos can all install from rdo, which is the only current option, the fedora and centos classes simply wrap around the redhat one. This may change in the future if any of them change (for example if RHOS support is added and redhat is now different to fedora) Change-Id: I5b18f393999d6f70757a2dfd9b12da049d6b64e1 --- .fixtures.yml | 3 + Rakefile | 4 +- examples/redhat_repo.yaml | 33 ++++ files/RPM-GPG-KEY-EPEL-6 | 29 +++ files/RPM-GPG-KEY-EPEL-7 | 29 +++ files/RPM-GPG-KEY-RDO-Havana | 52 +++++ files/RPM-GPG-KEY-RDO-Juno | 52 +++++ .../parser/functions/validate_yum_hash.rb | 59 ++++++ manifests/repo/debian/debian.pp | 59 ++++++ manifests/repo/debian/params.pp | 18 ++ manifests/repo/debian/ubuntu.pp | 54 +++++ manifests/repo/redhat/params.pp | 32 +++ manifests/repo/redhat/redhat.pp | 134 +++++++++++++ ...penstack_extras_repo_debian_debian_spec.rb | 132 +++++++++++++ ...penstack_extras_repo_debian_ubuntu_spec.rb | 114 +++++++++++ ...penstack_extras_repo_redhat_redhat_spec.rb | 187 ++++++++++++++++++ 16 files changed, 990 insertions(+), 1 deletion(-) create mode 100644 examples/redhat_repo.yaml create mode 100644 files/RPM-GPG-KEY-EPEL-6 create mode 100644 files/RPM-GPG-KEY-EPEL-7 create mode 100644 files/RPM-GPG-KEY-RDO-Havana create mode 100644 files/RPM-GPG-KEY-RDO-Juno create mode 100644 lib/puppet/parser/functions/validate_yum_hash.rb create mode 100644 manifests/repo/debian/debian.pp create mode 100644 manifests/repo/debian/params.pp create mode 100644 manifests/repo/debian/ubuntu.pp create mode 100644 manifests/repo/redhat/params.pp create mode 100644 manifests/repo/redhat/redhat.pp create mode 100644 spec/classes/openstack_extras_repo_debian_debian_spec.rb create mode 100644 spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb create mode 100644 spec/classes/openstack_extras_repo_redhat_redhat_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index eff67f4..5c237af 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,3 +1,6 @@ fixtures: + repositories: + 'apt' : 'git://github.com/puppetlabs/puppetlabs-apt' + 'stdlib' : 'git://github.com/puppetlabs/puppetlabs-stdlib' symlinks: 'openstack_extras': "#{source_dir}" diff --git a/Rakefile b/Rakefile index 67e846c..0097908 100644 --- a/Rakefile +++ b/Rakefile @@ -4,4 +4,6 @@ require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] +PuppetLint.configuration.send('disable_double_quoted_strings') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "examples/**/*.pp", "vendor/**/*.pp"] diff --git a/examples/redhat_repo.yaml b/examples/redhat_repo.yaml new file mode 100644 index 0000000..d542b99 --- /dev/null +++ b/examples/redhat_repo.yaml @@ -0,0 +1,33 @@ +# This is an example of how to define your own repos in hiera +# in addition to RDO when using the redhat repo class +# assuming you have included the class somewhere +# +# This is taken from the aptira hiera data files in +# puppet_openstack_builder and may go out of date. +# +# Set up repositories using openstack_extras +openstack_extras::repo::redhat::redhat::repo_hash: + 'CentOS-Base': + 'descr': 'CentOS-$releasever - Base' + 'baseurl': "%{hiera('yum_base_mirror')}/$releasever/os/$basearch/" + 'CentOS-Updates': + 'descr': 'CentOS-$releasever - Updates' + 'baseurl': "%{hiera('yum_base_mirror')}/$releasever/updates/$basearch/" + 'CentOS-Extras': + 'descr': 'CentOS-$releasever - Extras' + 'baseurl': "%{hiera('yum_base_mirror')}/$releasever/extras/$basearch/" + 'epel': + 'descr': 'Extra Packages for Enterprise Linux 6 - $basearch' + 'baseurl': "%{hiera('yum_epel_mirror')}/$releasever/$basearch/" + 'gpgkey': 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6' + 'failovermethod': 'priority' + +openstack_extras::repo::redhat::redhat::repo_defaults: + 'proxy': "http://%{hiera('proxy_host')}:%{hiera('proxy_port')}" + +openstack_extras::repo::redhat::redhat::gpgkey_hash: + '/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6': + 'source': 'puppet:///modules/openstack_extras/RPM-GPG-KEY-EPEL-6' + +openstack_extras::repo::redhat::redhat::purge_unmanaged: true +openstack_extras::repo::redhat::redhat::package_require: true diff --git a/files/RPM-GPG-KEY-EPEL-6 b/files/RPM-GPG-KEY-EPEL-6 new file mode 100644 index 0000000..7a20304 --- /dev/null +++ b/files/RPM-GPG-KEY-EPEL-6 @@ -0,0 +1,29 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.5 (GNU/Linux) + +mQINBEvSKUIBEADLGnUj24ZVKW7liFN/JA5CgtzlNnKs7sBg7fVbNWryiE3URbn1 +JXvrdwHtkKyY96/ifZ1Ld3lE2gOF61bGZ2CWwJNee76Sp9Z+isP8RQXbG5jwj/4B +M9HK7phktqFVJ8VbY2jfTjcfxRvGM8YBwXF8hx0CDZURAjvf1xRSQJ7iAo58qcHn +XtxOAvQmAbR9z6Q/h/D+Y/PhoIJp1OV4VNHCbCs9M7HUVBpgC53PDcTUQuwcgeY6 +pQgo9eT1eLNSZVrJ5Bctivl1UcD6P6CIGkkeT2gNhqindRPngUXGXW7Qzoefe+fV +QqJSm7Tq2q9oqVZ46J964waCRItRySpuW5dxZO34WM6wsw2BP2MlACbH4l3luqtp +Xo3Bvfnk+HAFH3HcMuwdaulxv7zYKXCfNoSfgrpEfo2Ex4Im/I3WdtwME/Gbnwdq +3VJzgAxLVFhczDHwNkjmIdPAlNJ9/ixRjip4dgZtW8VcBCrNoL+LhDrIfjvnLdRu +vBHy9P3sCF7FZycaHlMWP6RiLtH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L-7 new file mode 100644 index 0000000..f205ede --- /dev/null +++ b/files/RPM-GPG-KEY-EPEL-7 @@ -0,0 +1,29 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.11 (GNU/Linux) + +mQINBFKuaIQBEAC1UphXwMqCAarPUH/ZsOFslabeTVO2pDk5YnO96f+rgZB7xArB +OSeQk7B90iqSJ85/c72OAn4OXYvT63gfCeXpJs5M7emXkPsNQWWSju99lW+AqSNm +jYWhmRlLRGl0OO7gIwj776dIXvcMNFlzSPj00N2xAqjMbjlnV2n2abAE5gq6VpqP +vFXVyfrVa/ualogDVmf6h2t4Rdpifq8qTHsHFU3xpCz+T6/dGWKGQ42ZQfTaLnDM +jToAsmY0AyevkIbX6iZVtzGvanYpPcWW4X0RDPcpqfFNZk643xI4lsZ+Y2Er9Yu5 +S/8x0ly+tmmIokaE0wwbdUu740YTZjCesroYWiRg5zuQ2xfKxJoV5E+Eh+tYwGDJ +n6HfWhRgnudRRwvuJ45ztYVtKulKw8QQpd2STWrcQQDJaRWmnMooX/PATTjCBExB +9dkz38Druvk7IkHMtsIqlkAOQMdsX1d3Tov6BE2XDjIG0zFxLduJGbVwc/6rIc95 +T055j36Ez0HrjxdpTGOOHxRqMK5m9flFbaxxtDnS7w77WqzW7HjFrD0VeTx2vnjj +GqchHEQpfDpFOzb8LTFhgYidyRNUflQY35WLOzLNV+pV3eQ3Jg11UFwelSNLqfQf +uFRGc+zcwkNjHh5yPvm9odR1BIfqJ6sKGPGbtPNXo7ERMRypWyRz0zi0twARAQAB +tChGZWRvcmEgRVBFTCAoNykgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iQI4BBMB +AgAiBQJSrmiEAhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBqL66iNSxk +5cfGD/4spqpsTjtDM7qpytKLHKruZtvuWiqt5RfvT9ww9GUUFMZ4ZZGX4nUXg49q +ixDLayWR8ddG/s5kyOi3C0uX/6inzaYyRg+Bh70brqKUK14F1BrrPi29eaKfG+Gu +MFtXdBG2a7OtPmw3yuKmq9Epv6B0mP6E5KSdvSRSqJWtGcA6wRS/wDzXJENHp5re +9Ism3CYydpy0GLRA5wo4fPB5uLdUhLEUDvh2KK//fMjja3o0L+SNz8N0aDZyn5Ax +CU9RB3EHcTecFgoy5umRj99BZrebR1NO+4gBrivIfdvD4fJNfNBHXwhSH9ACGCNv +HnXVjHQF9iHWApKkRIeh8Fr2n5dtfJEF7SEX8GbX7FbsWo29kXMrVgNqHNyDnfAB +VoPubgQdtJZJkVZAkaHrMu8AytwT62Q4eNqmJI1aWbZQNI5jWYqc6RKuCK6/F99q +thFT9gJO17+yRuL6Uv2/vgzVR1RGdwVLKwlUjGPAjYflpCQwWMAASxiv9uPyYPHc +ErSrbRG0wjIfAR3vus1OSOx3xZHZpXFfmQTsDP7zVROLzV98R3JwFAxJ4/xqeON4 +vCPFU6OsT3lWQ8w7il5ohY95wmujfr6lk89kEzJdOTzcn7DBbUru33CQMGKZ3Evt +RjsC7FDbL017qxS+ZVA/HGkyfiu4cpgV8VUnbql5eAZ+1Ll6Dw== +=hdPa +-----END PGP PUBLIC KEY BLOCK----- diff --git a/files/RPM-GPG-KEY-RDO-Havana b/files/RPM-GPG-KEY-RDO-Havana new file mode 100644 index 0000000..59a2a5a --- /dev/null +++ b/files/RPM-GPG-KEY-RDO-Havana @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.11 (GNU/Linux) + +mQINBFHvxL0BEADUX2nizL2nXQDR+c4msIcBdvXx67Q9MUXgPzaTWIB9EPxrnJVb +hrZva6JKKrt9djG3k7qeUdy7qwMT6OwZ5LswmcVKEQ91+sgO9GazUSmdZIb+e9ag +vmEnkPgeUCI7UlmNqpoPjfvn5msgcJGFGyLHoNGONs88Jo8TWkc145d+P2UJC6Kx +hNAHNIntE40eebA/mHW8NWySMQy9UPLYqw1TEawv5PTDGViaM08gEhvH1lEMOpD9 +nI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Wo1I9066K7nRfZ7PNYB3/lhDkPy0E2ha79SUnWUjlGnswzsNtSt8GxRETAEAv5jo +m9Jbep62jxl3M+f8Z817452dwaUoNNSrfTUKP5FMO95gkHS7sWG2t7X+K5c9/vX5 +GTv3SLQMbHivrRm0yCzFfQpQfAkYAZNahiLp/89RKwyySiQeDzeeqy581U7uLxwA +Uu/QXZH0k3RIZGI/JdOQ3Yk09wzh5SQeOcUs51Jk/O34wu+LrKwFvSgkP1Ld7hqB +j4A8LKn/tJDESOomPlljb8D/sfFb7K7g+sO8GY5Z8RiJKxQT8NXpw+st7QIa2XGV +5i2uhhbPVFaPly8bwtLstoaF84hokOSv4/cMfRbsUIQJMaxtcMwqf9H+eOas0uKh +D3gDZODEve5hYEabTFbVUrJ8N61qyVm3s1kbYBS4q1pM8pPzOnSqKsGnahHDpwhD +vXXbLsOsskZR629yTT/ZbPXMExPUnczhuGzEkCj2tDYF6n63nHSZmClPToXKxkPP +KIaHfraZoe+pO1XjRRSrT+Ax68FlnxoJqLBcuIWpzylnLpXldYqtVXFgXBy9bQ1A +WRhdyg== +=3A9V +-----END PGP PUBLIC KEY BLOCK----- diff --git a/files/RPM-GPG-KEY-RDO-Juno b/files/RPM-GPG-KEY-RDO-Juno new file mode 100644 index 0000000..17970c6 --- /dev/null +++ b/files/RPM-GPG-KEY-RDO-Juno @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1 + +mQINBFQaEA4BEADNjmFy/gNt+j/3Npji2Yae9RJedb1jvuulTC3udfyRsqiZP47c +jRFQ6GmqTGqRdn2tLAaWZiwS6hcCtRjqa1K275DnL1jWEd+YFNrggQsd5atbuikm ++TYz/sMVYrSicawCzQnc2lYOJyF45tpfNy5u1Hwfne6Mt66BHUAFoCnSgzQ5b4Wo +mvr9znJSE+vySHVOQxPcaZIpN4jRYi4thUlAn09LM1i9i/1APD6wuOz9xSe9ZkTz +SZVPbPcztOc0JJ53CAoPjhjZJaWJ6Jv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hLcQ+Ec4f1IJn0uZUPI2aS0isshqBG +INQJCeiTsrJtatlG5kM6tmpRZnhjN6ybaLjPOdfqZV9oInnSrw75JLQvGFkW8pGc +co/7njvZEoGTgYKh610EE1DO3Bv5XVUhnstfu+Zzn4WSH2KbbdonUPYcsdKNjmdo +oyhgVyzR4K2cwxp4r4gEe8O8YiNRJ3b9/41Dfn6pu/DVdjGolr9hokDKPYbrnXw0 +ZpcDlYT0INA/9r1V37nTXZ0CiOLm0ZHkreG5dn67bWYnFj7j3qUTsjpBFZ2Z5mmC +BDProaNYsTQS0Oyb26d4xaYDAXpga/LAsHs+qZBxVP1ExBEvMJ2Piu9Vr4Pn/euv +uw1aZtXZ1R7Sky6ksek4mgpmyIlEY3s8PLZuHX4LNlc8FKXmrXbAyIIlfUv0oeZV +m+0ImNUeTgmA/HPIHHhamaiT4emBLpdf+ddZMaQFITo8kaY1eCIH7xaBdIsDMQrS +1nkiCWreksxfyQS7mD3+sW8BFFFrlbFIgz/EXu+JfCP4jdbKaIsyzQuihWZVgDoK +tqA= +=vBYB +-----END PGP PUBLIC KEY BLOCK----- diff --git a/lib/puppet/parser/functions/validate_yum_hash.rb b/lib/puppet/parser/functions/validate_yum_hash.rb new file mode 100644 index 0000000..ea5cc77 --- /dev/null +++ b/lib/puppet/parser/functions/validate_yum_hash.rb @@ -0,0 +1,59 @@ +module Puppet::Parser::Functions + + yumrepo_arguments = [ + 'name', + 'ensure', + 'baseurl', + 'cost', + 'descr', + 'enabled', + 'enablegroups', + 'exclude', + 'failovermethod', + 'gpgcheck', + 'gpgkey', + 'http_caching', + 'include', + 'includepkgs', + 'keepalive', + 'metadata_expire', + 'metalink', + 'mirrorlist', + 'priority', + 'protect', + 'provider', + 'proxy', + 'proxy_password', + 'proxy_username', + 'repo_gpgcheck', + 's3_enabled', + 'skip_if_unavailable', + 'sslcacert', + 'sslclientcert', + 'sslclientkey', + 'sslverify', + 'target', + 'timeout' + ] + + newfunction(:validate_yum_hash) do |args| + if args.size > 1 + raise Puppet::Error, "validate_yum_hash takes only a single argument, #{args.size} provided" + end + arg = args[0] + + if not arg.kind_of?(Hash) + raise Puppet::Error, "non-hash argument provided to validate_yum_hash" + end + + if arg.size > 0 + arg.each do |title, params| + params.each do |param, value| + if ! yumrepo_arguments.include?(param) + raise Puppet::Error, "Parameter #{param} is not valid for the yumrepo type" + end + end + end + end + end +end diff --git a/manifests/repo/debian/debian.pp b/manifests/repo/debian/debian.pp new file mode 100644 index 0000000..2204dc8 --- /dev/null +++ b/manifests/repo/debian/debian.pp @@ -0,0 +1,59 @@ +# == Class: openstack_extras::repo::debian::debian +# +# This repo sets up apt sources for use with the debian +# osfamily and debian operatingsystem +# +# === Parameters: +# +# [*release*] +# (optional) The OpenStack release to add a +# Debian Wheezy apt source for. +# Defaults to 'icehouse' +# +# [*manage_whz*] +# (optional) Whether or not to add the default +# Debian Wheezy APT source +# Defaults to true +# +# [*source_hash*] +# (optional) A hash of apt::source resources to +# create and manage +# Defaults to {} +# +# [*source_defaults*] +# (optional) A hash of defaults to use for all apt::source +# resources created by this class +# Defaults to {} +# +# [*package_require*] +# (optional) Whether or not to run 'apt-get update' before +# installing any packages. +# Defaults to false +# +class openstack_extras::repo::debian::debian( + $release = $::openstack_extras::repo::debian::params::release, + $manage_whz = true, + $source_hash = {}, + $source_defaults = {}, + $package_require = false +) inherits openstack_extras::repo::debian::params { + if $manage_whz { + apt::source { $::openstack_extras::repo::debian::params::whz_name: + location => $::openstack_extras::repo::debian::params::whz_location, + release => $release, + repos => $::openstack_extras::repo::debian::params::whz_repos, + required_packages => $::openstack_extras::repo::debian::params::whz_required_packages + } -> + apt::source { "${::openstack_extras::repo::debian::params::whz_name}_backports": + location => $::openstack_extras::repo::debian::params::whz_location, + release => "${release}-backports", + repos => $::openstack_extras::repo::debian::params::whz_repos, + } + } + + create_resources('apt::source', $source_hash, $source_defaults) + + if $package_require { + Exec['apt_update'] -> Package<||> + } +} diff --git a/manifests/repo/debian/params.pp b/manifests/repo/debian/params.pp new file mode 100644 index 0000000..7373227 --- /dev/null +++ b/manifests/repo/debian/params.pp @@ -0,0 +1,18 @@ +# == Class: openstack_extras::repo::debian::params +# +# This repo sets defaults for the debian osfamily +# +class openstack_extras::repo::debian::params +{ + $release = 'icehouse' + + $uca_name = 'ubuntu-cloud-archive' + $uca_location = 'http://ubuntu-cloud.archive.canonical.com/ubuntu' + $uca_repos = 'main' + $uca_required_packages = 'ubuntu-cloud-keyring' + + $whz_name = 'debian_wheezy' + $whz_location = 'http://archive.gplhost.com/debian' + $whz_repos = 'main' + $whz_required_packages = 'gplhost-archive-keyring' +} diff --git a/manifests/repo/debian/ubuntu.pp b/manifests/repo/debian/ubuntu.pp new file mode 100644 index 0000000..41726b7 --- /dev/null +++ b/manifests/repo/debian/ubuntu.pp @@ -0,0 +1,54 @@ +# == Class: openstack_extras::repo::debian::ubuntu +# +# This repo sets up apt sources for use with the debian +# osfamily and ubuntu operatingsystem +# +# === Parameters: +# +# [*release*] +# (optional) The OpenStack release to add an +# Ubuntu Cloud Archive APT source for. +# Defaults to 'icehouse' +# +# [*manage_uca*] +# (optional) Whether or not to add the default +# Ubuntu Cloud Archive APT source +# Defaults to true +# +# [*source_hash*] +# (optional) A hash of apt::source resources to +# create and manage +# Defaults to {} +# +# [*source_defaults*] +# (optional) A hash of defaults to use for all apt::source +# resources created by this class +# Defaults to {} +# +# [*package_require*] +# (optional) Whether or not to run 'apt-get update' before +# installing any packages. +# Defaults to false +# +class openstack_extras::repo::debian::ubuntu( + $release = $::openstack_extras::repo::debian::params::release, + $manage_uca = true, + $source_hash = {}, + $source_defaults = {}, + $package_require = false +) inherits openstack_extras::repo::debian::params { + if $manage_uca { + apt::source { $::openstack_extras::repo::debian::params::uca_name: + location => $::openstack_extras::repo::debian::params::uca_location, + release => "${::lsbdistcodename}-updates/${release}", + repos => $::openstack_extras::repo::debian::params::uca_repos, + required_packages => $::openstack_extras::repo::debian::params::uca_required_packages + } + } + + create_resources('apt::source', $source_hash, $source_defaults) + + if $package_require { + Exec['apt_update'] -> Package<||> + } +} diff --git a/manifests/repo/redhat/params.pp b/manifests/repo/redhat/params.pp new file mode 100644 index 0000000..ece8e62 --- /dev/null +++ b/manifests/repo/redhat/params.pp @@ -0,0 +1,32 @@ +# == Class: openstack_extras::repo::redhat::params +# +# This repo sets defaults for use with the redhat +# osfamily repo classes. +# +class openstack_extras::repo::redhat::params +{ + $release = 'juno' + + $repo_defaults = { 'enabled' => '1', + 'gpgcheck' => '1', + 'notify' => "Exec[yum_refresh]", + 'mirrorlist' => 'absent', + 'require' => "Anchor[openstack_extras_redhat]" + } + + $gpgkey_defaults = { 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'before' => "Anchor[openstack_extras_redhat]" + } + + case $::operatingsystem { + centos, redhat, scientific, slc: { $dist = 'epel' } + fedora: { $dist = 'fedora' } + default: { + warning('Unrecognised operatingsystem') + } + } + + $rdo_priority = 98 +} diff --git a/manifests/repo/redhat/redhat.pp b/manifests/repo/redhat/redhat.pp new file mode 100644 index 0000000..303e7e2 --- /dev/null +++ b/manifests/repo/redhat/redhat.pp @@ -0,0 +1,134 @@ +# == Class: openstack_extras::repo::redhat::redhat +# +# This repo sets up yum repos for use with the redhat +# osfamily and redhat operatingsystem. +# +# === Parameters: +# +# [*release*] +# (optional) The openstack release to use if managing rdo +# Defaults to $::openstack_extras::repo::redhat::params::release +# +# [*manage_rdo*] +# (optional) Whether to create a predefined yumrepo resource +# for the RDO OpenStack repository provided by RedHat +# Defaults to true +# +# [*repo_hash*] +# (optional) A hash of yumrepo resources that will be passed to +# create_resource. See examples folder for some useful examples. +# Defaults to {} +# +# [*repo_defaults*] +# (optional) The defaults for the yumrepo resources that will be +# created using create_resource. +# Defaults to $::openstack_extras::repo::redhat::params::repo_defaults +# +# [*gpgkey_hash*] +# (optional) A hash of file resources that will be passed to +# create_resource. See examples folder for some useful examples. +# Defaults to {} +# +# [*gpgkey_defaults*] +# (optional) The default resource attributes to +# create gpgkeys with. +# Defaults to $::openstack_extras::repo::redhat::params::gpgkey_defaults +# +# [*purge_unmanaged*] +# (optional) Purge the yum.repos.d directory of +# all repositories not managed by Puppet +# Defaults to false +# +# [*package_require*] +# (optional) Set all packages to require all +# yumrepos be set. +# Defaults to false +# +class openstack_extras::repo::redhat::redhat( + $release = $::openstack_extras::repo::redhat::params::release, + $manage_rdo = true, + $manage_epel = true, + $repo_hash = {}, + $repo_defaults = {}, + $gpgkey_hash = {}, + $gpgkey_defaults = {}, + $purge_unmanaged = false, + $package_require = false +) inherits openstack_extras::repo::redhat::params { + + validate_string($release) + validate_bool($manage_rdo) + validate_bool($manage_epel) + validate_hash($repo_hash) + validate_hash($repo_defaults) + validate_hash($gpgkey_hash) + validate_hash($gpgkey_defaults) + validate_bool($purge_unmanaged) + validate_bool($package_require) + + $_repo_defaults = merge($::openstack_extras::repo::redhat::params::repo_defaults, $repo_defaults) + $_gpgkey_defaults = merge($::openstack_extras::repo::redhat::params::gpgkey_defaults, $gpgkey_defaults) + + anchor { 'openstack_extras_redhat': } + + if $manage_rdo { + $release_cap = capitalize($release) + $_dist = $::openstack_extras::repo::redhat::params::dist + + $rdo_hash = { 'rdo-release' => { + 'baseurl' => "http://repos.fedorapeople.org/repos/openstack/openstack-${release}/${_dist}-${::operatingsystemmajrelease}/", + 'descr' => "OpenStack ${release_cap} Repository", + 'priority' => $::openstack_extras::repo::redhat::params::rdo_priority, + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-${release_cap}", + } + } + + $rdokey_hash = { "/etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-${release_cap}" => { + 'source' => "puppet:///modules/openstack_extras/RPM-GPG-KEY-RDO-${release_cap}" + } + } + + create_resources('file', $rdokey_hash, $_gpgkey_defaults) + create_resources('yumrepo', $rdo_hash, $_repo_defaults) + } + + if $manage_epel { + if ($::osfamily == 'RedHat' and + $::operatingsystem != 'Fedora') + { + $epel_hash = { 'epel' => { + 'baseurl' => "https://download.fedoraproject.org/pub/epel/${::operatingsystemmajrelease}/\$basearch", + 'descr' => "Extra Packages for Enterprise Linux ${::operatingsystemmajrelease} - \$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}", + 'failovermethod' => 'priority' + } + } + + $epelkey_hash = { "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}" => { + 'source' => "puppet:///modules/openstack_extras/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}" + } + } + + create_resources('file', $epelkey_hash, $_gpgkey_defaults) + create_resources('yumrepo', $epel_hash, $_repo_defaults) + } + } + + validate_yum_hash($repo_hash) + create_resources('yumrepo', $repo_hash, $_repo_defaults) + create_resources('file', $gpgkey_hash, $_gpgkey_defaults) + + if ((versioncmp($::puppetversion, '3.5') > 0) and $purge_unmanaged) { + resources { 'yumrepo': purge => true } + } + + if $package_require { + Yumrepo<||> -> Package<||> + } + + exec { 'yum_refresh': + command => '/usr/bin/yum clean all', + refreshonly => true, + } -> Package <||> +} + diff --git a/spec/classes/openstack_extras_repo_debian_debian_spec.rb b/spec/classes/openstack_extras_repo_debian_debian_spec.rb new file mode 100644 index 0000000..e38fff2 --- /dev/null +++ b/spec/classes/openstack_extras_repo_debian_debian_spec.rb @@ -0,0 +1,132 @@ +require 'spec_helper' + +describe 'openstack_extras::repo::debian::debian' do + let :class_params do + { + :manage_whz => true, + :source_hash => {}, + :source_defaults => {}, + :package_require => false + } + end + + let :paramclass_defaults do + { + :release => 'icehouse' + } + end + + let :default_params do + class_params.merge!(paramclass_defaults) + end + + context 'on Debian platforms' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :lsbdistid => 'Debian' + } + end + + describe 'with default parameters' do + let :params do + {}.merge!(default_params) + end + + it { should contain_apt__source('debian_wheezy').with( + :location => 'http://archive.gplhost.com/debian', + :release => 'icehouse', + :repos => 'main', + :required_packages => 'gplhost-archive-keyring' + )} + + it { should contain_apt__source('debian_wheezy_backports').with( + :location => 'http://archive.gplhost.com/debian', + :release => 'icehouse-backports', + :repos => 'main' + )} + + end + + describe 'with overridden release' do + let :params do + default_params.merge!({ :release => 'juno' }) + end + + it { should contain_apt__source('debian_wheezy').with( + :location => 'http://archive.gplhost.com/debian', + :release => 'juno', + :repos => 'main', + :required_packages => 'gplhost-archive-keyring' + )} + + it { should contain_apt__source('debian_wheezy_backports').with( + :location => 'http://archive.gplhost.com/debian', + :release => 'juno-backports', + :repos => 'main' + )} + + end + + describe 'with overridden source hash' do + let :params do + default_params.merge!({ :source_hash => { + 'debian_unstable' => { + 'location' => 'http://mymirror/debian/', + 'repos' => 'main', + 'release' => 'unstable' + }, + 'puppetlabs' => { + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'release' => 'wheezy', + 'key' => '4BD6EC30', + 'key_server' => 'pgp.mit.edu' + } + } + }) + end + + it { should contain_apt__source('debian_unstable').with( + :location => 'http://mymirror/debian/', + :release => 'unstable', + :repos => 'main' + )} + + it { should contain_apt__source('puppetlabs').with( + :location => 'http://apt.puppetlabs.com', + :repos => 'main', + :release => 'wheezy', + :key => '4BD6EC30', + :key_server => 'pgp.mit.edu' + )} + + end + + describe 'with overridden source default' do + let :params do + default_params.merge!({ :source_defaults => { + 'include_src' => 'true' + } + }) + end + + it { should contain_apt__source('debian_wheezy').with( + :location => 'http://archive.gplhost.com/debian', + :release => 'icehouse', + :repos => 'main', + :required_packages => 'gplhost-archive-keyring', + :include_src => 'true' + )} + + it { should contain_apt__source('debian_wheezy_backports').with( + :location => 'http://archive.gplhost.com/debian', + :release => 'icehouse-backports', + :repos => 'main', + :include_src => 'true' + )} + + end + end +end diff --git a/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb b/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb new file mode 100644 index 0000000..f62fa01 --- /dev/null +++ b/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb @@ -0,0 +1,114 @@ +require 'spec_helper' + +describe 'openstack_extras::repo::debian::ubuntu' do + let :class_params do + { + :manage_uca => true, + :source_hash => {}, + :source_defaults => {}, + :package_require => false + } + end + + let :paramclass_defaults do + { + :release => 'icehouse' + } + end + + let :default_params do + class_params.merge!(paramclass_defaults) + end + + context 'on Debian platforms' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu', + :lsbdistcodename => 'trusty' + } + end + + describe 'with default parameters' do + let :params do + {}.merge!(default_params) + end + + it { should contain_apt__source('ubuntu-cloud-archive').with( + :location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu', + :release => 'trusty-updates/icehouse', + :repos => 'main', + :required_packages => 'ubuntu-cloud-keyring' + )} + + end + + describe 'with overridden release' do + let :params do + default_params.merge!({ :release => 'juno' }) + end + + it { should contain_apt__source('ubuntu-cloud-archive').with( + :location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu', + :release => 'trusty-updates/juno', + :repos => 'main', + :required_packages => 'ubuntu-cloud-keyring' + )} + + end + + describe 'with overridden source hash' do + let :params do + default_params.merge!({ :source_hash => { + 'local_mirror' => { + 'location' => 'http://mymirror/ubuntu/', + 'repos' => 'main', + 'release' => 'trusty' + }, + 'puppetlabs' => { + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'release' => 'trusty', + 'key' => '4BD6EC30', + 'key_server' => 'pgp.mit.edu' + } + } + }) + end + + it { should contain_apt__source('local_mirror').with( + :location => 'http://mymirror/ubuntu/', + :release => 'trusty', + :repos => 'main' + )} + + it { should contain_apt__source('puppetlabs').with( + :location => 'http://apt.puppetlabs.com', + :release => 'trusty', + :repos => 'main', + :key => '4BD6EC30', + :key_server => 'pgp.mit.edu' + )} + + end + + describe 'with overridden source default' do + let :params do + default_params.merge!({ :source_defaults => { + 'include_src' => 'true' + } + }) + end + + it { should contain_apt__source('ubuntu-cloud-archive').with( + :include_src => 'true', + :location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu', + :release => 'trusty-updates/icehouse', + :repos => 'main', + :required_packages => 'ubuntu-cloud-keyring' + )} + + end + end +end diff --git a/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb b/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb new file mode 100644 index 0000000..b4dd6a8 --- /dev/null +++ b/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb @@ -0,0 +1,187 @@ +require 'spec_helper' + +describe 'openstack_extras::repo::redhat::redhat' do + let :class_params do + { + :manage_rdo => true, + :manage_epel => true, + :repo_hash => {}, + :gpgkey_hash => {}, + :purge_unmanaged => false, + :package_require => false + } + end + + let :paramclass_defaults do + { + :release => 'icehouse', + :repo_defaults => { 'enabled' => '1', + 'gpgcheck' => '1', + 'notify' => "Exec[yum_refresh]", + 'mirrorlist' => 'absent', + 'require' => "Anchor[openstack_extras_redhat]" + }, + :gpgkey_defaults => { 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'before' => "Anchor[openstack_extras_redhat]" + } + } + end + + let :default_params do + class_params.merge!(paramclass_defaults) + end + + context 'on RedHat platforms' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6.5', + :operatingsystemmajrelease => '6' + } + end + + describe 'with default parameters' do + let :params do + {}.merge!(default_params) + end + + it { should contain_yumrepo('rdo-release').with( + :baseurl => "http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/", + :descr => "OpenStack Icehouse Repository", + :priority => 98, + :gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse", + :enabled => '1', + :gpgcheck => '1', + :mirrorlist => 'absent', + :require => "Anchor[openstack_extras_redhat]", + :notify => "Exec[yum_refresh]" + )} + + it { should contain_yumrepo('epel').with( + :baseurl => 'https://download.fedoraproject.org/pub/epel/6/$basearch', + :descr => 'Extra Packages for Enterprise Linux 6 - $basearch', + :gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + :failovermethod => 'priority', + :enabled => '1', + :gpgcheck => '1', + :mirrorlist => 'absent', + :require => "Anchor[openstack_extras_redhat]", + :notify => "Exec[yum_refresh]" + )} + + it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse').with( + :source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-RDO-Icehouse", + :owner => 'root', + :group => 'root', + :mode => '0644', + :before => "Anchor[openstack_extras_redhat]" + )} + + end + + describe 'with overridden release' do + let :params do + default_params.merge!({ :release => 'juno' }) + end + + it { should contain_yumrepo('rdo-release').with( + :baseurl => "http://repos.fedorapeople.org/repos/openstack/openstack-juno/epel-6/", + :descr => "OpenStack Juno Repository", + :gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Juno" + )} + + it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Juno').with( + :source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-RDO-Juno" + )} + end + + describe 'with overridden repo hash' do + let :params do + default_params.merge!({ :repo_hash => { + 'CentOS-Base' => { + 'baseurl' => 'http://mymirror/$releasever/os/$basearch/', + 'descr' => 'CentOS-$releasever - Base', + 'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6' + }, + 'CentOS-Updates' => { + 'baseurl' => 'http://mymirror/$releasever/updates/$basearch/', + 'descr' => 'CentOS-$releasever - Updates', + 'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6', + } + } + }) + end + + it { should contain_yumrepo('CentOS-Base').with( + :baseurl => "http://mymirror/$releasever/os/$basearch/", + :descr => "CentOS-$releasever - Base", + :enabled => '1', + :gpgcheck => '1', + :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6', + :mirrorlist => 'absent', + :require => "Anchor[openstack_extras_redhat]", + :notify => "Exec[yum_refresh]" + )} + + it { should contain_yumrepo('CentOS-Updates').with( + :baseurl => "http://mymirror/$releasever/updates/$basearch/", + :descr => "CentOS-$releasever - Updates", + :enabled => '1', + :gpgcheck => '1', + :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6', + :mirrorlist => 'absent', + :require => "Anchor[openstack_extras_redhat]", + :notify => "Exec[yum_refresh]" + )} + + end + + describe 'with overridden repo default' do + let :params do + default_params.merge!({ :repo_defaults => { + 'proxy' => 'http://my.proxy.com:8000' + } + }) + end + + it { should contain_yumrepo('rdo-release').with( + :baseurl => "http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/", + :descr => "OpenStack Icehouse Repository", + :gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse", + :proxy => "http://my.proxy.com:8000" + )} + end + + describe 'with overridden gpgkey default' do + let :params do + default_params.merge!({ :gpgkey_defaults => { + 'owner' => 'steve' + } + }) + end + + it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse').with( + :owner => "steve" + )} + end + + describe 'with epel management disabled' do + let :params do + default_params.merge!({ :manage_epel => false }) + end + + it { should_not contain_yumrepo('epel') } + end + + describe 'with rdo management disabled' do + let :params do + default_params.merge!({ :manage_rdo => false }) + end + + it { should_not contain_yumrepo('rdo-release') } + end + end +end