https://github.com/puppetlabs/bolt/issues/1835 The Bolt team is interested in adding a plan_hierarchy key to Hiera's config that specifies the hierarchy to use when calling lookup in a plan outside of an apply block. This would allow users to use their existing Hiera config with Bolt without encountering unnecessary errors and would make it clear that different hierarchies are used in a plan outside of an apply block vs. inside an apply block. This is necessary because per-node data and interpolations do not make sense outside of an apply block because plans don't execute per-node, and other common interpolations like environment and facts are also nonsensical in that context. However, these values do make sense inside apply blocks and are currently supported. Having a new plan_hierarchy hierarchy for plans outside of apply blocks lets users specify what data to use in that context.
Did you consider a second instance of hiera/lookup with a separate hiera.yaml file for plans, and then just using one or the other depending on context when doing lookups? You would then get the global/env/module + default layers for free for the plan specific hiera instance. Either name the file plan_hiera.yaml or have something like a relative path ./plan/hiera.yaml to where the regular hiera.yaml is.
I think that would reduce the complexities in implementing this.