Uploaded image for project: 'Hiera (moved to puppet.atlassian.net)'
  1. Hiera (moved to puppet.atlassian.net)
  2. HI-151

hiera_array() fails when used in class parameters

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Normal
    • Resolution: Duplicate
    • HI 1.3.0
    • None
    • None
    • None

    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

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support