class demo (
  Array[Hash] $para5,
){
  file { '/etc/example.json’:
    ensure => file,
    content => to_json_pretty({
      section1 => {
        para1 => somevalue,
        para2 => somevalue,
        para3 => somevalue,
        para4 => somevalue,
        para5 => $para5,
      }, true),
    }
}

data/nodes/machine1.yaml
---
demo::para5:
  - para5a.1: somevalue
    para5a.2: somevalue
    para5a.3: somevalue
  - para5b.1: somevalue
    para5b.2: somevalue

data/nodes/machine2.yaml
---
demo::para5:
  - para5a.1: somevalue,
    para5a.2: somevalue,


> On 7. Dec 2021, at 23:02, David Pearson <[email protected]> wrote:
> 
> Hi Team,
> 
> I have a file resource within a manifest that uses content => to_json_pretty 
> to create a json config file on all nodes successfully. 
> 
> I need to improve the code so that a section of the config is unique per 
> server, but unsure on the best way to do this in the current format. In the 
> example below para5 would differ on each node. I would like to specify the 
> data in hiera for each node (hiera is already setup) and have a lookup within 
> the mainifest. 
> 
> Machine 1
>     file { '/etc/example.json':
>       content => to_json_pretty({
>         section1 => {
>           para1 => somevalue,
>           para2 => somevalue,
>           para3 => somevalue,
>           para4 => somevalue,
>           para5 => [
>             {
>               para5a.1 => somevalue,
>               para5a.2 => somevalue,
>               para5a.3 => somevalue,
>             },
>             {
>               para5b.1 => somevalue,
>               para5b.2 => somevalue,
>             },
>           ],
>       }, true),
>     }
> 
> Machine 2
> Machine 1
>     file { '/etc/example.json':
>       content => to_json_pretty({
>         section1 => {
>           para1 => somevalue,
>           para2 => somevalue,
>           para3 => somevalue,
>           para4 => somevalue,
>           para5 => [
>             {
>               para5a.1 => somevalue,
>               para5a.2 => somevalue,
>             }
>           ],
>       }, true),
>     }
> 
> Regards
> David
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/1bcb3540-fcb1-43c6-9beb-7771795603e4n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/puppet-users/1bcb3540-fcb1-43c6-9beb-7771795603e4n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/B99E4D74-87A2-4DDE-BA54-FF11291C13B5%40gmail.com.

Reply via email to