puppet-vault_lookup icon indicating copy to clipboard operation
puppet-vault_lookup copied to clipboard

Simplify module usage by wrapping deferred objects

Open deric opened this issue 9 months ago • 2 comments

Simplify module usage by a wrapper function.

Instead of

$d = Deferred('vault_lookup::lookup', ['secret/test', 'https://vault.hostname:8200'])

use

$d = vault_lookup::kv('secret/test')

where appropriate Vault server can be retrieved from Hiera:

---
vault_lookup::server: 'https://vault.hostname:8200'

the code becomes:

$d = vault_lookup::kv('secret/test', {'vault_addr' => 'https://vault.hostname:8200'})

Additionally there's a vault_lookup::fmt() function for deferred formating:

vault_lookup::fmt('password=%<pass>s', {'pass' => $d })

deric avatar Feb 19 '25 19:02 deric

This looks pretty good if it works!

tskirvin avatar Feb 26 '25 17:02 tskirvin

@tskirvin It does work :smiley: Just the fmt function seems to be limited to Puppet >=8 - somehow deferred unwrap doesn't work well with Puppet 7.

deric avatar Feb 26 '25 18:02 deric