hiera compatible refactoring

This commit is contained in:
Udo Waechter
2014-06-03 10:28:22 +02:00
parent d7d9a83dc8
commit 11001cb209
4 changed files with 31 additions and 38 deletions

View File

@@ -1,20 +1,16 @@
class puppet::facter ( class puppet::facter (
$ensure = 'present') { $ensure = 'present') {
$pkg_ens = $ensure ? {
'present' => 'latest',
default => $ensure,
}
package { 'facter': ensure => $ensure } package { 'facter': ensure => $ensure }
package { 'libaugeas-ruby': }
$ens_dir = $ensure ? { $ens_dir = $ensure ? {
'present' => 'directory', 'absent' => 'absent',
default => $ensure, default => 'directory',
} }
$facts_d = '/etc/facter/facts.d' $facts_d = '/etc/facter/facts.d'
File['/etc/facter'] -> File[$facts_d] File['/etc/facter'] -> File[$facts_d]
$pv_dir = $::puppet_vardir ? { $pv_dir = $::puppet_vardir ? {
'' => '/var/lib/puppet', '' => '/var/lib/puppet',
default => $::puppet_vardir default => $::puppet_vardir

View File

@@ -1,15 +1,16 @@
class puppet ( class puppet (
$ensure = 'present', $ensure = 'present',
$version = undef, $version = undef,
$pupppetlabs_apt = true,
$agent = true, $agent = true,
$server = false,
$facter_version = $ensure,
$puppetlabs_apt = true,
$agent_norunifloggedin = false, $agent_norunifloggedin = false,
$agent_daemonize = true, $agent_daemonize = true,
$agent_run_hour = '*/1', $agent_run_hour = '*/1',
$agent_run_minute = '10', $agent_run_minute = '10',
$agent_run_if_ipmatch = '', $agent_run_if_ipmatch = '',
$agent_maxsleep = '3200', $agent_maxsleep = '3200',
$server = false,
$server_dns_alt_names = undef, $server_dns_alt_names = undef,
$server_storeconfigs = false, $server_storeconfigs = false,
$server_storeconfigs_backend = undef, $server_storeconfigs_backend = undef,
@@ -17,7 +18,7 @@ class puppet (
$server_reports = 'store', $server_reports = 'store',
$server_passenger = true) { $server_passenger = true) {
if $puppetlabs_apt { if $puppetlabs_apt {
require 'puppet::puppetlabs_apt' class { 'puppet::puppetlabs_apt': before => Class['puppet::facter'] }
} }
if $version != undef { if $version != undef {
@@ -29,7 +30,15 @@ class puppet (
} }
class { 'puppet::facter': class { 'puppet::facter':
ensure => $ensure, ensure => $facter_version,
}
ini_setting { 'puppet-templatedir':
path => '/etc/puppet/puppet.conf',
section => 'main',
setting => 'templatedir',
value => '$confidr/templates',
ensure => 'absent';
} }
if $agent { if $agent {

View File

@@ -11,32 +11,21 @@ factsignore = .svn CVS .git
pluginsync=true pluginsync=true
factpath=$vardir/lib/facter factpath=$vardir/lib/facter
<% if (fqdn == scope.lookupvar("puppetmaster_server")) || (fqdn == scope.lookupvar("puppetmasterdev_server")) -%> <% if server == "true" -%>
#dbmigrate=true
#dbadapter=<%= scope.lookupvar('puppetmaster_dbtype') %>
#dbname=<%= scope.lookupvar('puppetmaster_dbname') %>
#dbserver=<%= scope.lookupvar('puppetmaster_dbhost') %>
#dbuser=<%= scope.lookupvar('puppetmaster_dbuser') %>
#dbpassword=<%= scope.lookupvar('puppetmaster_dbpassword') %>
[master] [master]
ssl_client_header = SSL_CLIENT_S_DN ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY ssl_client_verify_header = SSL_CLIENT_VERIFY
<% if scope.lookupvar('puppet::puppetmaster::dns_alt_names') -%> <% if scope['puppet::dns_alt_names'] -%>
dns_alt_names=<%= scope.lookupvar('puppet::puppetmaster::dns_alt_names') %> dns_alt_names=<%= scope['puppet::dns_alt_names'] %>
<% end -%> <% end -%>
<% if @reports -%> <% if scope['puppet::reports'] -%>
reports=<%= @reports %> reports=<%= scope['puppet::reports'] %>
<% end -%> <% end -%>
<% if scope.lookupvar('puppetmaster_reporturl') != false -%> basemodulepath=<%= scope['puppet::basemodulepath'] %>
reporturl=<%= scope.lookupvar('puppetmaster_reporturl') %> storeconfigs=<%= scope['puppet::storeconfigs'] %>
<% if scope['puppet::storeconfigs_backend'] -%>
storeconfigs_backend=<%= scope['puppet::storeconfigs_backend'] %>
<% end -%> <% end -%>
modulepath=<%= scope['puppet::puppetmaster::modulepath'] %>
storeconfigs=<%= scope['puppet::puppetmaster::storeconfigs'] %>
<% if scope['puppet::puppetmaster::storeconfigs_backend'] -%>
storeconfigs_backend=<%= scope['puppet::puppetmaster::storeconfigs_backend'] %>
<% end -%>
#rails_loglevel=info
<% end -%> <% end -%>
[agent] [agent]

View File

@@ -1,22 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# $Id: puppetd_run.sh.erb 4177 2011-04-05 08:02:08Z uwaechte $
# a wrapper script, to run puppetd after a random time # a wrapper script, to run puppetd after a random time
# this will be called by cron at the same time on each client, # this will be called by cron at the same time on each client,
# but should not call the master at the same time as the others. # but should not call the master at the same time as the others.
<% if norunifloggedin == true -%> <% if @norunifloggedin == true -%>
# not running if users are logged in # not running if users are logged in
[[ $(who|wc -l) -gt 0 ]] && exit 0 [[ $(who|wc -l) -gt 0 ]] && exit 0
<% end -%> <% end -%>
export FACTERLIB="<%= scope.lookupvar("factpath") %>" #export FACTERLIB="<%= scope.lookupvar("factpath") %>"
PATH="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" PATH="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
PUPPET=$(which puppet) PUPPET=$(which puppet)
[[ -e ${PUPPET} ]] || exit 1 [[ -e ${PUPPET} ]] || exit 1
PUPPET="${PUPPET}" PUPPET="${PUPPET}"
<% if run_if_ipmatch != "" -%> <% if @run_if_ipmatch != "" -%>
ISUNIIP=$(ifconfig |grep -c -e "<%= run_if_ipmatch %>") ISUNIIP=$(ifconfig |grep -c -e "<%= @run_if_ipmatch %>")
<% else -%> <% else -%>
ISUNIIP=1 ISUNIIP=1
<% end -%> <% end -%>
@@ -54,7 +53,7 @@ if [ ${ISUNIIP} -gt 0 ]; then
fi fi
fi fi
MAXSLEEP=<%= maxsleep %> #How many seconds to wait maximally MAXSLEEP=<%= @maxsleep %> #How many seconds to wait maximally
SLEEP=${RANDOM} SLEEP=${RANDOM}
I=${RANDOM} I=${RANDOM}