From 28563dfb5d21f24a927ca04648b3761f5da7ddcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Oct 2022 00:37:09 +0200 Subject: Change how root readme is sources. --- files/root_readme | 30 +++++++++++++----------------- manifests/init.pp | 25 +++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/files/root_readme b/files/root_readme index aabf4df..6c648ce 100644 --- a/files/root_readme +++ b/files/root_readme @@ -1,17 +1,13 @@ - _______________________ -< Den som gör bestämmer > - ----------------------- -\ . . - \ / `. .' " - \ .---. < > < > .---. - \ | \ \ - ~ ~ - / / | - _____ ..-~ ~-..-~ - | | \~~~\.' `./~~~/ - --------- \__/ \__/ - .' O \ / / \ " - (_____, `._.' | } \/~~~/ - `----. / } | / \__/ - `-. | / | / `. ,~~| - ~-.__| /_ - ~ ^| /- _ `..-' - | / | / ~-. `-. _ _ _ - |_____| |_____| ~ - . _ _ _ _ _> + ___________________________________________________________________________________ +/ This file can be changed through two different parameters to ::cgit \ +| - root_readme_source, which corresponds to the source attribute of file resources | +| - root_readme_content, which corresponds to the content attribute | +\ The field root_readme_sha256 is also available, and does what you think it does. / + ----------------------------------------------------------------------------------- + \ + \ + oO)-. .-(Oo + /__ _\ /_ __\ + \ \( | ()~() | )/ / + \__|\ | (-___-) | /|__/ + ' '--' ==`-'== '--' ' diff --git a/manifests/init.pp b/manifests/init.pp index c4e5334..62cb2a3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,6 +3,9 @@ class cgit ( String $filterpath = '/usr/lib/cgit/extra-filters', String $root_title, String $root_desc, + String $root_readme_source = "puppet:///modules/${module_name}/root_readme", + Optional[String] $root_readme_content = undef, + Optional[String] $root_readme_sha256 = undef, String $about_filter, String $auth_filter, String $source_filter, @@ -45,9 +48,27 @@ class cgit ( source => 'puppet:///modules/cgit/logo_large.png', } - file { "${root}/root_readme": + $chksum = if $root_readme_sha256 != undef { + { + 'checksum' => 'sha256', + 'checksum_value' => $root_readme_sha256, + } + } else { + { } + } + + if $root_readme_content { + file { "${root}/root_readme": + ensure => file, + content => $root_readme_content, + * => $chksum, + } + } else { + file { "${root}/root_readme": ensure => file, - source => 'puppet:///modules/cgit/root_readme', + source => $root_readme_source, + * => $chksum, + } } file { dirname($filterpath): -- cgit v1.2.3