Uploaded image for project: 'Hiera'
  1. Hiera
  2. HI-151

hiera_array() fails when used in class parameters

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Duplicate
    • Affects Version/s: HI 1.3.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
    • Template:

      Description

      Given this hiera config:

      bash-4.1# cat /etc/puppet/hiera.yaml 
      ---
       
      :backends:
          - yaml
       
      :hierarchy:
          - one
          - two
       
      :yaml:
          :datadir: '/etc/puppet/hieradata'
       
      :merge_behavior: deeper
       
      ...
      

      and this values:

      bash-4.1# cat /etc/puppet/hieradata/{one,two}.yaml
      ---
       
      foo::message: one
       
      ...
      ---
       
      foo::message: two
       
      ...
      

      if I run this code:

      bash-4.1# cat fail.pp 
      class foo ( $message = hiera_array('foo::message') ) { notify { $message: } }
      include ::foo
      

      it produces unexpected output:

      bash-4.1# puppet apply fail.pp 
      Notice: Compiled catalog for 435d243ccf29.ofi.softonic.lan in environment production in 0.48 seconds
      Notice: one
      Notice: /Stage[main]/Foo/Notify[one]/message: defined 'message' as 'one'
      Notice: Finished catalog run in 0.05 seconds
      

      whereas if I run this other code:

      bash-4.1# cat win.pp           
      class foo {
        $message = hiera_array('foo::message')
        notify { $message: }
      }
      include ::foo
      

      It produces the expected output:

      bash-4.1# puppet apply win.pp 
      Notice: Compiled catalog for 435d243ccf29.ofi.softonic.lan in environment production in 0.35 seconds
      Notice: one
      Notice: /Stage[main]/Foo/Notify[one]/message: defined 'message' as 'one'
      Notice: two
      Notice: /Stage[main]/Foo/Notify[two]/message: defined 'message' as 'two'
      Notice: Finished catalog run in 0.07 seconds
      

      Shouldn't it be the same output in both situations?

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  h0tbird Marc Villacorta
                  Reporter:
                  h0tbird Marc Villacorta
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support