From bebb51d41cc5f259d48c443dcde24f5caa115d31 Mon Sep 17 00:00:00 2001 From: Will Farrington Date: Sun, 27 Oct 2013 19:54:11 -0700 Subject: [PATCH] Add boxen::env_script defined type --- manifests/config.pp | 8 ++------ manifests/env_script.pp | 31 +++++++++++++++++++++++++++++++ manifests/environment.pp | 11 ++++++++++- 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 manifests/env_script.pp diff --git a/manifests/config.pp b/manifests/config.pp index bcb9800..c073a1a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -42,12 +42,8 @@ mode => '0755', } - file { "${envdir}/config.sh": - content => template('boxen/config.sh.erb') - } - - file { "${envdir}/gh_creds.sh": - content => template('boxen/gh_creds.sh.erb') + file { ["${envdir}/config.sh", "${envdir}/gh_creds.sh"]: + ensure => absent, } group { 'puppet': diff --git a/manifests/env_script.pp b/manifests/env_script.pp new file mode 100644 index 0000000..f8fe5de --- /dev/null +++ b/manifests/env_script.pp @@ -0,0 +1,31 @@ +define boxen::env_script( + $ensure = 'present', + $scriptname = $name, + $priority = 'normal', + $source = undef, + $content = undef, +) { + + if $source == undef and $content == undef { + fail("One of source or content must not be undef!") + } + + $real_priority = $priority ? { + 'highest' => '10', + 'higher' => '30', + 'high' => '40', + 'normal' => '50', + 'low' => '60', + 'lower' => '70', + 'lowest' => '90', + } + + include boxen::config + + file { "${boxen::config::envdir}/${real_priority}_${scriptname}.sh": + ensure => $ensure, + source => $source, + content => $content, + } + +} diff --git a/manifests/environment.pp b/manifests/environment.pp index 710f712..591e37c 100644 --- a/manifests/environment.pp +++ b/manifests/environment.pp @@ -19,4 +19,13 @@ include boxen::sudoers include_projects_from_boxen_cli() -} \ No newline at end of file + + boxen::env_script { + 'config': + content => template('boxen/config.sh.erb'), + priority => 'highest' ; + 'gh_creds': + content => template('boxen/gh_creds.sh.erb'), + priority => 'higher' ; + } +}