From 0b254c1c8f7fa8f25222a71d1ce9218ba8516672 Mon Sep 17 00:00:00 2001 From: Adam Henry Lewenberg <adamhl@stanford.edu> Date: Thu, 16 Nov 2017 12:28:36 -0800 Subject: [PATCH] some work out_of_date --- NEWS | 3 + manifests/out_of_date/client.pp | 67 ++++++++++++------- manifests/out_of_date/client/dev.pp | 10 +++ manifests/out_of_date/client/disabled.pp | 16 +++++ .../etc/out-of-date/client.conf.erb | 6 +- 5 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 manifests/out_of_date/client/dev.pp create mode 100644 manifests/out_of_date/client/disabled.pp rename files/out-of-date/etc/out-of-date/client.conf => templates/out_of_date/etc/out-of-date/client.conf.erb (72%) diff --git a/NEWS b/NEWS index 43e523d..21b0136 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ unreleased (207x-xx-xx) + [out_of_date] Add some parameters to the interface to make it easier + to point at different out-of-date servers. [adamhl] + [ssh] Change interface parameter. The parameter base::ssh::extra_gssapi_only_users has been renamed to base::ssh::extra_skip_duo_users to more accurately reflect what this diff --git a/manifests/out_of_date/client.pp b/manifests/out_of_date/client.pp index 4d9917a..cfbbedb 100644 --- a/manifests/out_of_date/client.pp +++ b/manifests/out_of_date/client.pp @@ -1,38 +1,59 @@ # Set up the out_of_date client, which reports package status to the server. -class base::out_of_date::client { +# $platform: should be one 'production' or 'development'. + +class base::out_of_date::client ( + $ensure = 'present', + $platform = 'production', + $ood_server_override = undef, +){ + if ($ensure == 'present') { + # PRESENT + + # Determine the server to use. + if ($ood_server_override) { + $ood_server = $ood_server_override + } else { + case $platform { + 'production': { $ood_server = 'frankoz1.stanford.edu' } + 'development': { $ood_server = 'frankoz1.stanford.edu' } + default: { fail("unrecognized platform") } + } + } + package { 'stanford-outofdate-client': ensure => installed, } file { - '/etc/out-of-date': - ensure => directory, - owner => root, - group => root; - '/etc/out-of-date/client.conf': - source => 'puppet:///modules/base/out-of-date/etc/out-of-date/client.conf', - require => Package['stanford-outofdate-client']; + '/etc/out-of-date': + ensure => directory, + owner => root, + group => root; + '/etc/out-of-date/client.conf': + content => template('base/out_of_date/etc/out-of-date/client.conf.erb'), + require => Package['stanford-outofdate-client']; } - if $::lsbdistcodename == 'lenny' { - file { '/etc/cron.hourly/out-of-date': ensure => absent } - } else { - file { '/etc/cron.hourly/out-of-date': - source => 'puppet:///modules/base/out-of-date/etc/cron.hourly/out-of-date'; - } + file { '/etc/cron.hourly/out-of-date': + source => 'puppet:///modules/base/out-of-date/etc/cron.hourly/out-of-date', } -} + } else { + # ABSENT -# disable ood-client by removing its cron job. -class base::out_of_date::client::disabled inherits base::out_of_date::client { - File['/etc/cron.hourly/out-of-date'] { - ensure => absent + package { 'stanford-outofdate-client': + ensure => absent, } -} -class base::out_of_date::client::dev inherits base::out_of_date::client { - File['/etc/out-of-date/client.conf'] { - source => 'puppet:///modules/base/out-of-date/etc/out-of-date/client-dev.conf' + file { '/etc/cron.hourly/out-of-date': + ensure => absent + } + + file { + '/etc/out-of-date': + ensure => absent; + '/etc/out-of-date/client.conf': + ensure => absent; } + } } diff --git a/manifests/out_of_date/client/dev.pp b/manifests/out_of_date/client/dev.pp new file mode 100644 index 0000000..ee1c670 --- /dev/null +++ b/manifests/out_of_date/client/dev.pp @@ -0,0 +1,10 @@ +# DEPRECATED! +# +# Use instead base::out_of_date::client with the parameter 'platform' set +# to 'development'. + +class base::out_of_date::client::dev { + class { 'base::out_of_date::client': + platform => 'development', + } +} diff --git a/manifests/out_of_date/client/disabled.pp b/manifests/out_of_date/client/disabled.pp new file mode 100644 index 0000000..1326323 --- /dev/null +++ b/manifests/out_of_date/client/disabled.pp @@ -0,0 +1,16 @@ +# disable ood-client by removing its cron job. + +# DEPRECATED! +# +# Use instead base::out_of_date::client with the parameter 'ensure' set to +# absent. + +class base::out_of_date::client::disabled { + # File['/etc/cron.hourly/out-of-date'] { + # ensure => absent + # } + + class { 'base::out_of_date::client': + ensure => absent, + } +} diff --git a/files/out-of-date/etc/out-of-date/client.conf b/templates/out_of_date/etc/out-of-date/client.conf.erb similarity index 72% rename from files/out-of-date/etc/out-of-date/client.conf rename to templates/out_of_date/etc/out-of-date/client.conf.erb index b39e5ab..faba7f3 100644 --- a/files/out-of-date/etc/out-of-date/client.conf +++ b/templates/out_of_date/etc/out-of-date/client.conf.erb @@ -1,11 +1,13 @@ -# Out-of-date Package Management +############################################################################## +### Out-Of-Date Package Management +############################################################################## # Upper bound of the random number generator; default is 12, you probably # won't want to change this too often. $RANDOM_HOURS = 12; # What server is collecting this information? -$COLLECT_SERVER = 'frankoz2.stanford.edu'; +$COLLECT_SERVER = '<%= @ood_server %>'; # Should we download and locally cache packages to-be-installed, if possible? $CACHE_PACKAGES = 0; -- GitLab