Skip to content

Commit

Permalink
Merge pull request #2702 from nickanderson/ENT-10480/3.18.x
Browse files Browse the repository at this point in the history
ENT-10480: Added ability to extend without overriding filename patterns to copy during policy update (3.18)
  • Loading branch information
nickanderson authored Aug 18, 2023
2 parents 8fae0a2 + 245e6b7 commit 8944ffe
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
31 changes: 30 additions & 1 deletion MPF.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ For example:

- Introduced 3.19.0, 3.18.1

### Files considered for copy during policy updates
### Override files considered for copy during policy updates

The default update policy only copies files that match regular expressions
listed in ```def.input_name_patterns```.
Expand All @@ -482,6 +482,35 @@ embedded
[failsafe policy](https://github.com/cfengine/core/blob/master/libpromises/failsafe.cf) is
used and it decides which files should be copied.

### Extend files considered for copy during policy updates

The default update policy only copies files that match regular expressions
listed in `default:def.input_name_patterns`. The variable
`default:update_def.input_name_patterns` allows the definition of additional
filename patterns without having to maintain the full set of defaults.

This [augments file][Augments] additionally ensures that files ending in
`.tpl`, `.md`, and `.org` are also copied.

```json
{
"variables": {
"default:update_def.input_name_patterns_extra": {
"value": [ ".*\\.tpl", ".*\\.md", ".*\\.org" ],
"comment": "We use classic CFEngine templates suffixed with .tpl so they should be copied along with documentation."
}
}
}
```

**Note:** This filter does **not** apply to bootstrap operations. During
bootstrap the embedded
[failsafe policy](https://github.com/cfengine/core/blob/master/libpromises/failsafe.cf)
is used and it decides which files should be copied.

**History:**
- Introduced in CFEngine 3.23.0

### Configuring component management

The Masterfiles Policy Framework ships with policy to manage the components of CFEngine.
Expand Down
3 changes: 2 additions & 1 deletion cfe_internal/update/update_policy.cf
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ body file_select u_cf3_files
body file_select u_input_files
# @brief Select files by extension that we should include when updating inputs
{
leaf_name => { @(update_def.input_name_patterns) };
leaf_name => { @(update_def.input_name_patterns),
@(update_def.input_name_patterns_extra) };
file_result => "leaf_name";
}

Expand Down
5 changes: 5 additions & 0 deletions controls/update_def.cf.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ bundle common update_def
not(isvariable("input_name_patterns"))),
meta => { "defvar" };

"input_name_patterns_extra" -> { "ENT-10480" }
slist => {},
comment => "Additional filename patterns to copy during policy update.",
if => not( isvariable( "input_name_patterns_extra" ) );

# the permissions for your masterfiles files (not dirs), which will propagate to inputs
"masterfiles_perms_mode_not_dir" -> { "CFE-951" }
string => "0600",
Expand Down

0 comments on commit 8944ffe

Please sign in to comment.