Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5924

The default hiera.yaml file does not include the '::' prefix for the environment variable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Template:

      Description

      At https://docs.puppetlabs.com/hiera/latest/configuring.html#format, there are two example configs. The default datadir on the webpage and in puppet-agent-1.3.2-1.el7.x86_64 is:

        :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"

      According to the example config, that should be:

        :datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata"

      These two datadir values result in completely different behavior when this is matched with puppetserver, specifically puppetserver-2.2.1-1.el7.noarch on CentOS7. It appears that hiera() lookups are ok but automatic parameter lookups fail.

      I realize this will most likely affect the puppet-agent project as well, but would like to confirm this in the Docs first.

      Sample code for reproduction:

      # site.pp
      node default {
        hiera_include('classes', [])
       
        $puppet_server = hiera('puppet::server')
        notify{"puppet::server in site manifest is '${puppet_server}'":}
      }
       
      # Relevant portion of modified evenup/puppet module's init.pp
      class puppet (
        Boolean                                      $agent             = true,
        Boolean                                      $server            = false,
        #...
      ) inherits puppet::params {
        notify{"puppet::server in class 'puppet' is '${puppet::server}'":}
        #...
      }
      

      With

      %{environment}

      , a lookup of hiera('puppet::server') in the site manifest and the value of $server in the puppet class (via APL) are different.

      [root@puppet controlrepo]# grep datadir /etc/puppetlabs/code/hiera.yaml
        :datadir: /etc/puppetlabs/code/environments/%{environment}/hiera
      [root@puppet controlrepo]# systemctl restart puppetserver && puppet agent -t --environment=hiera4 --noop | grep -i notify
      Notice: /Stage[main]/Puppet/Notify[puppet::server in class 'puppet' is 'false']/message: current_value absent, should be puppet::server in class 'puppet' is 'false' (noop)
      Notice: /Stage[main]/Main/Node[default]/Notify[puppet::server in site manifest is 'true']/message: current_value absent, should be puppet::server in site manifest is 'true' (noop)
      

      When using

      %{::environment}

      , a lookup of hiera('puppet::server') in the site manifest and the value of $server in the puppet class (via APL) are different.

      [root@puppet controlrepo]# grep datadir /etc/puppetlabs/code/hiera.yaml
        :datadir: /etc/puppetlabs/code/environments/%{::environment}/hiera
      [root@puppet controlrepo]# systemctl restart puppetserver && puppet agent -t --environment=hiera4 --noop | grep -i notify
      Notice: /Stage[main]/Puppet/Notify[puppet::server in class 'puppet' is 'true']/message: current_value absent, should be puppet::server in class 'puppet' is 'true' (noop)
      Notice: /Stage[main]/Main/Node[default]/Notify[puppet::server in site manifest is 'true']/message: current_value absent, should be puppet::server in site manifest is 'true' (noop)
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            rnelson0@gmail.com Rob Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support