From f3dd6dec3e4b6d082eacd608eccc6a519d5bb198 Mon Sep 17 00:00:00 2001 From: Daniel van der Ende Date: Mon, 4 Jan 2016 12:45:16 +0100 Subject: [PATCH] Added ability to configure custom (local) repository for installing rpm package --- manifests/init.pp | 93 ++++++++++++++++++++++++-------------------- manifests/install.pp | 36 ++++++++++------- manifests/repo.pp | 38 ++++++++++++++++-- 3 files changed, 106 insertions(+), 61 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 78ca700..07a811e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -13,53 +13,56 @@ # class { 'zookeeper': } # class zookeeper( - $id = '1', - $datastore = '/var/lib/zookeeper', + $id = '1', + $datastore = '/var/lib/zookeeper', # datalogstore used to put transaction logs in separate location than snapshots - $datalogstore = undef, - $initialize_datastore = false, + $datalogstore = undef, + $initialize_datastore = false, # fact from which we get public ip address - $client_ip = $::ipaddress, - $client_port = 2181, - $election_port = 2888, - $leader_port = 3888, - $log_dir = '/var/log/zookeeper', - $cfg_dir = '/etc/zookeeper/conf', - $user = 'zookeeper', - $group = 'zookeeper', - $java_bin = '/usr/bin/java', - $java_opts = '', - $pid_dir = '/var/run/zookeeper', - $pid_file = '$PIDDIR/zookeeper.pid', - $zoo_main = 'org.apache.zookeeper.server.quorum.QuorumPeerMain', + $client_ip = $::ipaddress, + $client_port = 2181, + $election_port = 2888, + $leader_port = 3888, + $log_dir = '/var/log/zookeeper', + $cfg_dir = '/etc/zookeeper/conf', + $user = 'zookeeper', + $group = 'zookeeper', + $java_bin = '/usr/bin/java', + $java_opts = '', + $pid_dir = '/var/run/zookeeper', + $pid_file = '$PIDDIR/zookeeper.pid', + $zoo_main = 'org.apache.zookeeper.server.quorum.QuorumPeerMain', $log4j_prop = 'INFO,ROLLINGFILE', - $cleanup_sh = '/usr/share/zookeeper/bin/zkCleanup.sh', - $servers = [], - $observers = [], - $ensure = present, - $snap_count = 10000, + $cleanup_sh = '/usr/share/zookeeper/bin/zkCleanup.sh', + $servers = [], + $observers = [], + $ensure = present, + $snap_count = 10000, # since zookeeper 3.4, for earlier version cron task might be used - $snap_retain_count = 3, - # interval in hours, purging enabled when >= 1 - $purge_interval = 0, + $snap_retain_count = 3, + # interval in hours, purging enabled when > = 1 + $purge_interval = 0, # log4j properties - $rollingfile_threshold = 'ERROR', - $tracefile_threshold = 'TRACE', - $max_allowed_connections = 10, - $peer_type = 'UNSET', - $start_with = 'init.d', - $ensure_cron = true, - $service_package = 'zookeeperd', - $service_name = 'zookeeper', - $packages = ['zookeeper'], - $repo = undef, - $cdhver = undef, - $install_java = false, - $java_package = undef, - $min_session_timeout = undef, - $max_session_timeout = undef, - $manage_service = true, - $manage_systemd = true, + $rollingfile_threshold = 'ERROR', + $tracefile_threshold = 'TRACE', + $max_allowed_connections = 10, + $peer_type = 'UNSET', + $start_with = 'init.d', + $ensure_cron = true, + $service_package = 'zookeeperd', + $service_name = 'zookeeper', + $packages = ['zookeeper'], + $repo = undef, + $cdhver = undef, + $install_java = false, + $java_package = undef, + $min_session_timeout = undef, + $max_session_timeout = undef, + $manage_service = true, + $manage_systemd = true, + $reponame = undef, + $repourl = undef, + $repodescr = undef ) { validate_array($packages) @@ -80,7 +83,11 @@ repo_source => $repo, cdhver => $cdhver, install_java => $install_java, - java_package => $java_package + java_package => $java_package, + reponame => $reponame, + repourl => $repourl, + repodescr => $repodescr + }-> class { 'zookeeper::config': id => $id, diff --git a/manifests/install.pp b/manifests/install.pp index 5467144..d5d2edc 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -10,19 +10,22 @@ # Should not be included directly # class zookeeper::install( - $ensure = present, - $snap_retain_count = 3, - $cleanup_sh = '/usr/lib/zookeeper/bin/zkCleanup.sh', - $datastore = '/var/lib/zookeeper', - $user = 'zookeeper', - $start_with = 'init.d', - $ensure_cron = true, - $service_package = 'zookeeperd', - $packages = ['zookeeper'], - $repo_source = undef, - $cdhver = cdhver, - $install_java = false, - $java_package = undef + $ensure = present, + $snap_retain_count = 3, + $cleanup_sh = '/usr/lib/zookeeper/bin/zkCleanup.sh', + $datastore = '/var/lib/zookeeper', + $user = 'zookeeper', + $start_with = 'init.d', + $ensure_cron = true, + $service_package = 'zookeeperd', + $packages = ['zookeeper'], + $repo_source = undef, + $cdhver = cdhver, + $install_java = false, + $java_package = undef, + $reponame = undef, + $repourl = undef, + $repodescr = undef ) { anchor { 'zookeeper::install::begin': } anchor { 'zookeeper::install::end': } @@ -48,8 +51,11 @@ 'RedHat': { class { 'zookeeper::repo': - source => $repo_source, - cdhver => $cdhver, + source => $repo_source, + cdhver => $cdhver, + reponame => $reponame, + repourl => $repourl, + repodescr => $repodescr } class { 'zookeeper::os::redhat': diff --git a/manifests/repo.pp b/manifests/repo.pp index 255d466..af25d98 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -4,9 +4,12 @@ # class zookeeper::repo( - $source = undef, - $cdhver = undef, - $ensure = present, + $source = undef, + $cdhver = undef, + $ensure = present, + $reponame = undef, + $repourl = undef, + $repodescr = undef ) { if $source { @@ -76,6 +79,35 @@ } } } + 'custom':{ + if $repodescr == undef or $repourl == undef or $reponame == undef { + fail("Invalid parameter settings for custom repo") + } + $osrel = $::operatingsystemmajrelease + case $osrel { + '6', '7': { + # parameter ensure is not supported before Puppet 3.5 + if versioncmp($::puppetversion, '3.5.0') >= 0 { + yumrepo { $reponame: + ensure => $ensure, + descr => $repodescr, + baseurl => $repourl, + enabled => 1, + sslverify => 0, + gpgcheck => 0 + } + } else { + yumrepo { $reponame: + descr => $repodescr, + baseurl => $repourl, + enabled => 1, + sslverify => 0, + gpgcheck => 0 + } + } + } + } + } default: { fail("\"${module_name}\" provides no repository information for yum repository \"${source}\"") }