| With puppet 6 the agent can now store binary data in the catalog, but the puppetdb can not. Because the catalog needs to be UTF-8 encoded, binary data gets base64 encoded in the catalog. The value gets stored base64 encoded in the puppetdb database but the information that it is base64 encoded is not stored. That results in that binary values of exported resources are base64 encoded on importing. Here is an example:
$x = { 'y' => 'test'} |
# This is a really ugly hack to create ASCII-8BIT encoded data: |
inline_template('<% @x["y"] = "test".force_encoding("ASCII-8BIT") %>') |
$v = $x['y'] |
|
case $::fqdn { |
'node1': { |
@@file { '/tmp/test_export.txt': |
content => $v, |
} |
} |
'node2': { |
File <<| title == '/tmp/test_export.txt' |>> |
} |
} |
|
file { '/tmp/test_local.txt': |
content => $v, |
}
|
Running puppet on node2 results in:
> puppet agent --test --environment=rvlocal |
Info: Using configured environment 'rvlocal' |
Info: Retrieving pluginfacts |
Info: Retrieving plugin |
Info: Retrieving locales |
Info: Loading facts |
Info: Caching catalog for node2 |
Info: Applying configuration version 'rvlocal heads/production-0-gee541e2af' |
Notice: /Stage[main]/Main/File[/tmp/test_local.txt]/content: |
--- /tmp/test_local.txt 2019-10-10 17:14:19.736052885 +0200 |
+++ /tmp/puppet-file20191010-23720-m5tcm0 2019-10-10 17:14:30.928307399 +0200 |
@@ -0,0 +1 @@ |
+test |
\ No newline at end of file |
[..] |
Notice: /Stage[main]/Main/File[/tmp/test_export.txt]/content: |
--- /tmp/test_export.txt 2019-10-10 17:14:14.895942817 +0200 |
+++ /tmp/puppet-file20191010-23720-g3yyt1 2019-10-10 17:14:30.988308764 +0200 |
@@ -0,0 +1 @@ |
+dGVzdA== |
\ No newline at end of file |
[..]
|
The content of the /tmp/test_export.txt Resource should also be "test" and not test base64 encoded. |