Skip to content

Commit

Permalink
Add header to settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wbclark committed Jul 22, 2021
1 parent fad0c8d commit 90bd343
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
20 changes: 19 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,28 @@
ensure_newline => true,
}

include pulpcore::header_strings

$header_content = pulpcore::generate_header_content(
[
$pulpcore::header_strings::warning_header,
$pulpcore::header_strings::installer_header,
$pulpcore::header_strings::explanation,
],
80,
'#',
)

concat::fragment { 'header':
target => 'pulpcore settings',
content => inline_template("<% scope['pulpcore::config::header_content'].each do |line| -%><%= line %><% end -%>"),
order => '01',
}

concat::fragment { 'base':
target => 'pulpcore settings',
content => template('pulpcore/settings.py.erb'),
order => '01',
order => '02',
}

file { $pulpcore::user_home:
Expand Down
31 changes: 31 additions & 0 deletions manifests/header_strings.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @summary Re-usable, overridable strings for file headers
#
# @param custom_installer_name
# Override installer_name in headers from "Puppet" to e.g. "foreman-installer"
#
# @param custom_settings_explanation
# Custom string providing further instructions to the user in settings.py header
class pulpcore::header_strings(
Optional[String] $custom_installer_name = undef,
Optional[String] $custom_settings_explanation = undef,
) {
if $custom_installer_name {
$installer_name = $custom_installer_name
} else {
$installer_name = 'Puppet'
}

if $custom_settings_explanation {
$explanation = $custom_settings_explanation
} else {
$explanation = @("EXPLANATION"/L)
Not only are your edits likely to be overwritten, there is also a strong possibility \
of breaking your system if you change configuration here without making required \
changes elsewhere. Refer to the documentation you used to install Pulpcore to \
determine the safe and persistent way to modify the configuration.
| - EXPLANATION
}

$installer_header = "File managed by ${installer_name}.\nModule: ${module_name}"
$warning_header = '!!! WARNING: DO NOT EDIT THIS FILE !!!'
}

0 comments on commit 90bd343

Please sign in to comment.