From 618384cf08340b34a4eaf1022d200c1acb8161f4 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Wed, 19 Jan 2011 20:09:16 -0500 Subject: Support puppet client for FreeBSD Some pieces of the puzzle are missing for being able to manage puppet in FreeBSD. * Add a default puppet client config template for FreeBSD * In FreeBSD, puppet.conf is not in /etc/puppet/ so let's provide a value for this variable in init.pp. * The rc script for starting and stopping puppet is not located in /etc/rc.d so let's signify this to Service[puppet] Signed-off-by: Gabriel Filion --- files/client/puppet.conf.FreeBSD | 26 ++++++++++++++++++++++++++ manifests/freebsd.pp | 7 +++++++ manifests/init.pp | 7 +++++++ 3 files changed, 40 insertions(+) create mode 100644 files/client/puppet.conf.FreeBSD create mode 100644 manifests/freebsd.pp diff --git a/files/client/puppet.conf.FreeBSD b/files/client/puppet.conf.FreeBSD new file mode 100644 index 0000000..cd8bd2a --- /dev/null +++ b/files/client/puppet.conf.FreeBSD @@ -0,0 +1,26 @@ +[main] + logdir=/var/log/puppet + vardir=/var/puppet + rundir=/var/run/puppet + + ssldir=/usr/local/etc/puppet/ssl + + # Where 3rd party plugins and modules are installed + libdir = $vardir/lib + + templatedir=$vardir/templates + + # Turn plug-in synchronization on. + pluginsync = true + pluginsource = puppet://$server/plugins + factpath = $vardir/lib/facter + +[puppetd] + report=true + server=server.example.com + + # different run-interval, default= 30min + # e.g. run puppetd every 4 hours = 14400 + # runinterval = 14400 + + logdest=$logdir/puppet.log diff --git a/manifests/freebsd.pp b/manifests/freebsd.pp new file mode 100644 index 0000000..1fe28d0 --- /dev/null +++ b/manifests/freebsd.pp @@ -0,0 +1,7 @@ +class puppet::freebsd inherits puppet::base { + + Service['puppet'] { + path => '/usr/local/etc/rc.d', + } + +} diff --git a/manifests/init.pp b/manifests/init.pp index e9d9748..69d9b18 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,6 +19,13 @@ # class puppet { + $puppet_default_config = $kernel ? { + freebsd => '/usr/local/etc/puppet/puppet.conf', + default => '/etc/puppet/puppet.conf', + } + + if $puppet_config == '' { $puppet_config = $puppet_default_config } + case $kernel { linux: { case $operatingsystem { -- cgit v1.2.3 From b333a0ed2561256ff5a2af0cb0e46ea663ac647c Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 16 Jul 2011 16:39:16 -0400 Subject: Support FreeBSD for the puppet master The puppet master has one additional config file that needs to be placed in a different folder under FreeBSD. Signed-off-by: Gabriel Filion --- manifests/puppetmaster/base.pp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manifests/puppetmaster/base.pp b/manifests/puppetmaster/base.pp index 6ac1e0c..820e499 100644 --- a/manifests/puppetmaster/base.pp +++ b/manifests/puppetmaster/base.pp @@ -5,7 +5,14 @@ class puppet::puppetmaster::base inherits puppet::base { "puppet:///modules/puppet/master/puppet.conf" ], } - if !$puppet_fileserverconfig { $puppet_fileserverconfig = '/etc/puppet/fileserver.conf' } + # This is not in puppet::puppetmaster since we'd like for + # puppet::puppetmaster::cluster to work in FreeBSD too. + $puppet_default_config_dir = $operatingsystem ? { + freebsd => "/usr/local/etc/puppet", + default => "/etc/puppet", + } + + if !$puppet_fileserverconfig { $puppet_fileserverconfig = "${puppet_default_config_dir}/fileserver.conf" } file { "$puppet_fileserverconfig": source => [ "puppet:///modules/site-puppet/master/${fqdn}/fileserver.conf", -- cgit v1.2.3 From 2a13f8a56b2acac95c9f59f6957eb5ece386e76d Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 23 Aug 2011 16:11:16 -0400 Subject: FreeBSD: install packages via puppet itself The linux class installs puppet and facter via puppet itself. Chances are that they are already installed, since you need puppet before you can run puppet. _But_, it enables the $puppet_ensure_version and $facter_ensure_version features (forcing the installed version). So let's do the same in FreeBSD. Signed-off-by: Gabriel Filion --- manifests/freebsd.pp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/manifests/freebsd.pp b/manifests/freebsd.pp index 1fe28d0..3d0995d 100644 --- a/manifests/freebsd.pp +++ b/manifests/freebsd.pp @@ -1,7 +1,18 @@ class puppet::freebsd inherits puppet::base { - Service['puppet'] { - path => '/usr/local/etc/rc.d', - } + if !$puppet_ensure_version { $puppet_ensure_version = 'installed' } + package { 'puppet': + ensure => $puppet_ensure_version, + } + + if !$facter_ensure_version { $facter_ensure_version = 'installed' } + package { 'facter': + ensure => $facter_ensure_version, + } + + Service['puppet'] { + path => '/usr/local/etc/rc.d', + require => Package[puppet], + } } -- cgit v1.2.3 From 529e6ec7a0bfd2d82b0819b50cf2033ae3c91bfc Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 23 Aug 2011 16:29:38 -0400 Subject: Include the OS-specific class for FreeBSD The FreeBSD class was previously defined but not included by the puppet class in init.pp Signed-off-by: Gabriel Filion --- manifests/init.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/init.pp b/manifests/init.pp index 69d9b18..fb10773 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,6 +36,7 @@ class puppet { } } openbsd: { include puppet::openbsd } + freebsd: { include puppet::freebsd } default: { include puppet::base } } -- cgit v1.2.3 From 56528806115735c1717408989d6d39049574333b Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 23 Aug 2011 16:30:36 -0400 Subject: Fix ssldir value for FreeBSD config The default ssl directory in FreeBSD is /var/puppet/ssl, not /usr/local/etc/puppet/ssl With the previous value, puppet would refuse to run starting from the second run, stating that the certificates do not match. Signed-off-by: Gabriel Filion --- files/client/puppet.conf.FreeBSD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/client/puppet.conf.FreeBSD b/files/client/puppet.conf.FreeBSD index cd8bd2a..71bcf77 100644 --- a/files/client/puppet.conf.FreeBSD +++ b/files/client/puppet.conf.FreeBSD @@ -3,7 +3,7 @@ vardir=/var/puppet rundir=/var/run/puppet - ssldir=/usr/local/etc/puppet/ssl + ssldir=/var/puppet/ssl # Where 3rd party plugins and modules are installed libdir = $vardir/lib -- cgit v1.2.3 From 000165503f79e6214047ba2622bdabf4176a68a0 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 23 Aug 2011 16:53:14 -0400 Subject: Move $puppet_default_config_dir to the puppet class We'd like to use this variable in the 'puppet' class since we're defining the path to another config file, there. Since puppet::puppetmaster inherits the puppet class, the variable will be defined appropriately. Just to make sure we get the value from the right place, let's also use the qualified variable name. To avoid useless repetitions in the variable name, change the variable name from $puppet_default_config_dir to $default_config_dir. Signed-off-by: Gabriel Filion --- manifests/init.pp | 10 ++++++---- manifests/puppetmaster/base.pp | 11 ++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index fb10773..c05631a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,15 +19,17 @@ # class puppet { - $puppet_default_config = $kernel ? { - freebsd => '/usr/local/etc/puppet/puppet.conf', - default => '/etc/puppet/puppet.conf', + $default_config_dir = $operatingsystem ? { + freebsd => "/usr/local/etc/puppet", + default => "/etc/puppet", } + $puppet_default_config = "$default_config_dir/puppet.conf" + if $puppet_config == '' { $puppet_config = $puppet_default_config } case $kernel { - linux: { + linux: { case $operatingsystem { gentoo: { include puppet::gentoo } centos: { include puppet::centos } diff --git a/manifests/puppetmaster/base.pp b/manifests/puppetmaster/base.pp index 820e499..0000513 100644 --- a/manifests/puppetmaster/base.pp +++ b/manifests/puppetmaster/base.pp @@ -5,21 +5,14 @@ class puppet::puppetmaster::base inherits puppet::base { "puppet:///modules/puppet/master/puppet.conf" ], } - # This is not in puppet::puppetmaster since we'd like for - # puppet::puppetmaster::cluster to work in FreeBSD too. - $puppet_default_config_dir = $operatingsystem ? { - freebsd => "/usr/local/etc/puppet", - default => "/etc/puppet", - } - - if !$puppet_fileserverconfig { $puppet_fileserverconfig = "${puppet_default_config_dir}/fileserver.conf" } + if !$puppet_fileserverconfig { $puppet_fileserverconfig = "${puppet::default_config_dir}/fileserver.conf" } file { "$puppet_fileserverconfig": source => [ "puppet:///modules/site-puppet/master/${fqdn}/fileserver.conf", "puppet:///modules/site-puppet/master/fileserver.conf", "puppet:///modules/puppet/master/fileserver.conf" ], owner => root, group => puppet, mode => 640; - } + } if $puppetmaster_storeconfigs { include puppet::puppetmaster::storeconfigs -- cgit v1.2.3 From c0afea193ef40786fb61cbab24f6e9366f157264 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 23 Aug 2011 18:04:45 -0400 Subject: Add partial freebsd cron job support The puppet::cron::freebsd class is almost identical to the puppet::cron::openbsd one, but there is no cron job to remove, and the /etc/rc.conf mechanism doesn't exist yet for FreeBSD. Signed-off-by: Gabriel Filion --- manifests/cron.pp | 1 + manifests/cron/freebsd.pp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 manifests/cron/freebsd.pp diff --git a/manifests/cron.pp b/manifests/cron.pp index 693a430..9a632ff 100644 --- a/manifests/cron.pp +++ b/manifests/cron.pp @@ -5,6 +5,7 @@ class puppet::cron inherits puppet { linux: { include puppet::cron::linux } debian: { include puppet::cron::debian } openbsd: { include puppet::cron::openbsd } + freebsd: { include puppet::cron::freebsd } default: { include puppet::cron::base } } } diff --git a/manifests/cron/freebsd.pp b/manifests/cron/freebsd.pp new file mode 100644 index 0000000..5ff3419 --- /dev/null +++ b/manifests/cron/freebsd.pp @@ -0,0 +1,23 @@ +class puppet::cron::freebsd inherits puppet::freebsd { + + include puppet::cron::base + if $puppet_http_compression { $puppet_http_compression_str = '--http_compression' } + + if !$puppet_crontime { + $puppet_crontime_interval_minute = fqdn_rand(29) + $puppet_crontime_interval_minute2 = inline_template('<%= 30+puppet_crontime_interval_minute.to_i %>') + $puppet_crontime = "${puppet_crontime_interval_minute},${puppet_crontime_interval_minute2} * * * *" + } + + #TODO ensure that the service is disabled in /etc/rc.conf[.local] + + cron { 'puppetd_run': + command => "/usr/local/bin/puppet agent --onetime --no-daemonize --config=${puppet::puppet_config} --color false $puppet_http_compression_str | grep -E '(^err:|^alert:|^emerg:|^crit:)'", + user => 'root', + minute => split(regsubst($puppet_crontime,'^([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+)$','\1'),','), + hour => split(regsubst($puppet_crontime,'^([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+)$','\2'),','), + weekday => split(regsubst($puppet_crontime,'^([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+)$','\3'),','), + month => split(regsubst($puppet_crontime,'^([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+)$','\4'),','), + monthday => split(regsubst($puppet_crontime,'^([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+) ([\d,\-,*,/,\,]+)$','\5'),',') + } +} -- cgit v1.2.3 From 506767d73515f79e05057df928bf7baa94b0dfcc Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 8 Apr 2012 20:24:03 -0400 Subject: Fail when trying to ensure an installed version on FreeBSD The two package providers for FreeBSD are not able to ensure that a specific version of a package is installed because of how ports/pkg_add work. They can only ensure the version from the specified FreeBSD release is installed or absent. For more information, see: http://docs.puppetlabs.com/references/stable/type.html#features-4 To make the class easier to understand, let's not do something that users don't expect when they're requesting installation of a specific version. We'll explicitly fail and tell users why so that they can adjust how they use the class/module. Signed-off-by: Gabriel Filion --- manifests/freebsd.pp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/manifests/freebsd.pp b/manifests/freebsd.pp index 3d0995d..cdce989 100644 --- a/manifests/freebsd.pp +++ b/manifests/freebsd.pp @@ -1,11 +1,20 @@ class puppet::freebsd inherits puppet::base { - if !$puppet_ensure_version { $puppet_ensure_version = 'installed' } + case $puppet_ensure_version { + '': { $puppet_ensure_version = 'installed' } + 'removed','absent','installed', 'present': {} # those values are OK + default: { fail('Package providers for FreeBSD cannot ensure that a specific version is installed.') } + } + case $facter_ensure_version { + '': { $facter_ensure_version = 'installed' } + 'removed','absent','installed', 'present': {} # those values are OK + default: { fail('Package providers for FreeBSD cannot ensure that a specific version is installed.') } + } + package { 'puppet': ensure => $puppet_ensure_version, } - if !$facter_ensure_version { $facter_ensure_version = 'installed' } package { 'facter': ensure => $facter_ensure_version, } -- cgit v1.2.3