This adds a "purge" parameter to the file resource. To do this, we have to add the API hooks so the file resource can query other resources in the graph to know if they are present, and as a result whether they should be excluded from the purge or not. This is useful for when we have a managed directory with some managed contents. If a managed file is removed from the directory, then it will be removed by the file (directory) resource if it has Purge set. Alternatively, you can use the Reverse meta param, which is sometimes preferable for this use case and sometimes not. This will be discussed elsewhere. This also adds a bunch of tests for this feature. This also makes a few somewhat related cleanups in the file code.
20 lines
371 B
Plaintext
20 lines
371 B
Plaintext
file "/tmp/some_dir/" {
|
|
state => "exists",
|
|
#source => "", # this default means empty directory
|
|
recurse => true,
|
|
purge => true,
|
|
}
|
|
|
|
file "/tmp/some_dir/fileA" {
|
|
state => "exists",
|
|
content => "i am fileA\n",
|
|
}
|
|
file "/tmp/some_dir/fileB" {
|
|
state => "exists",
|
|
content => "i am fileB\n",
|
|
}
|
|
file "/tmp/some_dir/fileC" {
|
|
state => "exists",
|
|
content => "i am fileC\n",
|
|
}
|