-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #11142: filetemplate technique posthook
- Loading branch information
Showing
16 changed files
with
810 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
techniques/fileDistribution/fileTemplate/1.0/tests/loadVars.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"displayName": "Variable (string)", | ||
"enabled": true, | ||
"longDescription": "", | ||
"parameters": { | ||
"section": { | ||
"name": "sections", | ||
"sections": [ | ||
{ | ||
"section": { | ||
"name": "Variable definition", | ||
"vars": [ | ||
{ | ||
"var": { | ||
"name": "GENERIC_VARIABLE_CONTENT", | ||
"value": "Alice" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "GENERIC_VARIABLE_NAME", | ||
"value": "nom1" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"section": { | ||
"name": "Variable definition", | ||
"vars": [ | ||
{ | ||
"var": { | ||
"name": "GENERIC_VARIABLE_CONTENT", | ||
"value": "1 chemin de la rue" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "GENERIC_VARIABLE_NAME", | ||
"value": "adresse1" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"section": { | ||
"name": "Variable definition", | ||
"vars": [ | ||
{ | ||
"var": { | ||
"name": "GENERIC_VARIABLE_CONTENT", | ||
"value": "Bob" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "GENERIC_VARIABLE_NAME", | ||
"value": "nom2" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"shortDescription": "", | ||
"techniqueName": "genericVariableDefinition", | ||
"techniqueVersion": "2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{{vars.generic_variable_definition.nom1}}} habite {{{vars.generic_variable_definition.adresse1}}} |
12 changes: 12 additions & 0 deletions
12
...ileDistribution/fileTemplate/1.0/tests/test_error_fileTemplate/test_error_fileTemplate.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/local/bin/ncf -f | ||
bundle agent init { | ||
vars: | ||
"gen_files" slist => {"test1.conf", "test2.conf", "posthooktest", "persistentPosthooktest"}; | ||
"src_files" slist => {"template1", "_tmp_test2_conf.tpl"}; | ||
"other_files" slist => {"/tmp/aDirectory"}; | ||
|
||
methods: | ||
"any" usebundle => command_execution("rm -f /tmp/${gen_files}"); | ||
"any" usebundle => command_execution("rm -f /var/rudder/templates/${src_files}"); | ||
"any" usebundle => command_execution("rm -Rf ${other_files}"); | ||
} |
116 changes: 116 additions & 0 deletions
116
...eDistribution/fileTemplate/1.0/tests/test_error_fileTemplate/test_error_fileTemplate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"displayName": "File content (from remote template) (1,1) (3,1)", | ||
"enabled": true, | ||
"longDescription": "", | ||
"parameters": { | ||
"section": { | ||
"name": "sections", | ||
"sections": [ | ||
{ | ||
"section": { | ||
"name": "Apply template", | ||
"sections": [ | ||
{ | ||
"section": { | ||
"name": "Load Template from a file or text input", | ||
"sections": [ | ||
{ | ||
"section": { | ||
"name": "Expand template" | ||
} | ||
}, | ||
{ | ||
"section": { | ||
"name": "Posthook" | ||
} | ||
}, | ||
{ | ||
"section": { | ||
"name": "Put permissions" | ||
} | ||
}, | ||
{ | ||
"section": { | ||
"name": "Templates directory permissions" | ||
} | ||
}, | ||
{ | ||
"section": { | ||
"name": "Templates location" | ||
} | ||
} | ||
], | ||
"vars": [ | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_AGENT_DESTINATION_PATH", | ||
"value": "/tmp/test3.conf" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_GROUP_OWNER", | ||
"value": "root" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_OWNER", | ||
"value": "root" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_PERMISSIONS", | ||
"value": "700" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_PERSISTENT_POST_HOOK", | ||
"value": "false" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_RAW_OR_NOT", | ||
"value": "File" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_RAW_TEMPLATE", | ||
"value": "" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_TEMPLATE", | ||
"value": "lmqoivuqiuvh" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_TEMPLATE_POST_HOOK_COMMAND", | ||
"value": "" | ||
} | ||
}, | ||
{ | ||
"var": { | ||
"name": "FILE_TEMPLATE_TEMPLATE_TYPE", | ||
"value": "mustache" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"shortDescription": "", | ||
"techniqueName": "fileTemplate", | ||
"techniqueVersion": "1.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
...tribution/fileTemplate/1.0/tests/test_error_fileTemplate/test_error_fileTemplate.metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[{ | ||
"inits": ["test_error_fileTemplate.cf"], | ||
"directives": ["test_error_fileTemplate.json", "loadVars.json"], | ||
"checks": ["test_error_fileTemplate.rb"], | ||
"sharedFiles":["template1"], | ||
"compliance": 66.67 | ||
}] |
11 changes: 11 additions & 0 deletions
11
...ileDistribution/fileTemplate/1.0/tests/test_error_fileTemplate/test_error_fileTemplate.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require "spec_helper" | ||
# Test with an inexistent template file, should failed | ||
describe file("/var/rudder/tmp/templates") do | ||
it { should be_directory } | ||
it { should be_mode 750 } | ||
it { should be_owned_by "root" } | ||
end | ||
|
||
describe command("rudder agent run -r") do | ||
its(:stdout) { should match /^R: @@fileTemplate@@result_error@@.*?@@.*?@@.*?@@Load Template from a file or text input@@\/tmp\/test3.conf@@.*?The copy of the file.*?from the policy server to .*? could not be repaired$/m} | ||
end |
3 changes: 3 additions & 0 deletions
3
techniques/fileDistribution/fileTemplate/1.0/tests/test_fileTemplate/test_fileTemplate.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/local/bin/ncf -f | ||
bundle agent init { | ||
} |
Oops, something went wrong.