https://puppet.com/docs/puppet/6.17/lang_data_sensitive.htmlYou need to "unwrap" the sensitive data in order to consume the original data in a function
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/b8b44d0a3859790edae6d420ab256d629df227a1.camel%40opentext.com.
The following snippet redacts the content from log output but stores the cleartext in the resulting
file, thus doing what you are looking for
```
file { "${home}/.meraki_env":
ensure => file,
owner => $user,
group => $group,
content => Sensitive("export MERAKI_DASHBOARD_API_KEY=${dashboard_api_key}"),
mode => '0600',
}
```
The issue you're running into is due to the sensitive value being interpolated:content => "${foo}\n"If you reference the Sensitive variable directly, then it will work as expected:content => $foo
This issue and some possible solutions have been discussed in https://tickets.puppetlabs.com/browse/PUP-10092. For example, Henrik suggested a `rewrap` function https://tickets.puppetlabs.com/browse/PUP-10093.
Am Mittwoch, den 09.09.2020, 08:59 -0700 schrieb Josh Cooper:The issue you're running into is due to the sensitive value being interpolated:content => "${foo}\n"If you reference the Sensitive variable directly, then it will work as expected:content => $fooOK, thanks a lot. But then I'd loose the trailing "\n".
And it's also quite counterintuitive, isn't it?
Think "exec", where it's sometimes needed to provide a password as part of the command. One would have to define $password as String instead of Sensitive and then wrap the whole command in a Sensitive() call (as Mattias suggested).
This issue and some possible solutions have been discussed in https://tickets.puppetlabs.com/browse/PUP-10092. For example, Henrik suggested a `rewrap` function https://tickets.puppetlabs.com/browse/PUP-10093.Reg. the solution(s) discussed in there: Wouldn't the addition of a string concatenation operator (+) solve the problem right away (to make it content => $foo + "\n")?