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

Topscope 'environment' can become nil when setting node parameters in a custom terminus

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 5.3.4
    • Fix Version/s: PUP 5.3.6, PUP 5.5.0
    • Component/s: Hiera & Lookup
    • Labels:
      None
    • Template:
      PUP Bug Template
    • Sub-team:
    • Team:
      Platform Core
    • Sprint:
      Platform Core KANBAN
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      In a custom Node terminus, it was possible to construct the Node object in a way where $::environment would be empty during catalog compilation, even though the Node object had the environment itself properly set. Catalog compilation now consults the node's environment directly when setting $::environment.
      Show
      In a custom Node terminus, it was possible to construct the Node object in a way where $::environment would be empty during catalog compilation, even though the Node object had the environment itself properly set. Catalog compilation now consults the node's environment directly when setting $::environment.
    • QA Risk Assessment:
      Manual

      Description

      Puppet Version: 5.3.4
      Puppet Server Version: 5.1.4
      OS Name/Version: RHEL7.4

      Summary: Catalogs fail to compile on puppet-server 5.1.5 when using puppet-agent 5.3.4. When puppet-agent is downgraded on puppet-server 5.1.5 compiles are successful. **

       

      Baseline/Working Example

      With puppet-agent 5.3.3 and puppet-server 5.1.5, I can successfully compile a catalog for my client.

      [root@puppet5 ~]# rpm -q puppet-agent puppetserver
      puppet-agent-5.3.3-1.el7.x86_64
      puppetserver-5.1.5-1.el7.noarch

      Client:

      [root@led ~]# rpm -q puppet-agent
      puppet-agent-5.3.4-1.el7.x86_64
      [root@led ~]# puppet agent -t --environment production --server puppet5.corp.com
      Info: Using configured environment 'production'
      Info: Retrieving pluginfacts
      Info: Retrieving plugin
      Info: Loading facts
      Info: Caching catalog for led
      Info: Unable to serialize catalog to json, retrying with pson
      Info: Applying configuration version 'c30a9ad'
      Notice: Applied catalog in 9.63 seconds

       

      Broken Example

      Upgrading the agent on the server will prevent the server from compiling a catalog.

      [root@puppet5 ~]# yum -y update puppet-agent
      ...
      [root@puppet5 ~]# rpm -q puppet-agent puppetserver
      puppet-agent-5.3.4-1.el7.x86_64
      puppetserver-5.1.5-1.el7.noarch
      [root@puppet5 ~]# systemctl restart puppetserver

       

      Client:

      [root@led ~]# puppet agent -t --environment production --server puppet5.corp.com
      Info: Using configured environment 'production'
      Info: Retrieving pluginfacts
      Info: Retrieving plugin
      Info: Retrieving locales
      Info: Loading facts
      Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Class[Eash::Client]: expects a value for parameter 'pem' (file: /etc/puppetlabs/code/environments/production/.site/profile/manifests/common.pp, line: 42, column: 21) on node led.corp.com
      Warning: Not using cache on failed catalog
      Error: Could not retrieve catalog; skipping run

       

      Why I think it's Hiera Related

      My hiera.yaml

      [puppet5 ~]$ cat /etc/puppetlabs/code/hiera.yaml
      # managed by puppet: modules/puppet/files/etc/puppetlabs/code/hiera.yaml/common.erb, called by: Class[Role::Infra::Puppet_server]
      ---
      :backends:
        - modularfiles
        - eyaml
        - yaml
       
      :hierarchy:
        - "host/%{::fqdn}"
        - "role/%{::role}"
        - "hostgroup/%{::hostgroup}"
        - "team/%{::team}"
        - "enclave/%{::enclave}"
        - common
       
      :yaml:
        :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
       
      :eyaml:
        :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
        :pkcs7_private_key: /etc/puppetlabs/keys/private_key.pkcs7.pem
        :pkcs7_public_key:  /etc/puppetlabs/keys/public_key.pkcs7.pem
        :extension: 'yaml'
       
      :merge_behavior: native

      Running puppet server in debug mode

      [root@puppet5 ~]# puppetserver foreground --debug
      ...
      2018-02-09 15:27:40,269 DEBUG [qtp194608888-66] [puppetserver] Puppet Lookup of 'telegraf::outputs'
        Searching for "telegraf::outputs"
          Global Data Provider (hiera configuration version 3)
            Using configuration "/etc/puppetlabs/code/hiera.yaml"
            Merge strategy hash
      ...
              Hierarchy entry "yaml"
                Merge strategy hash
                  Path "/etc/puppetlabs/code/environments//hieradata/host/led.corp.com.yaml"
                    Original path: "host/%{::fqdn}"
                    Path not found
                  Path "/etc/puppetlabs/code/environments//hieradata/role/infra::led.yaml"
                    Original path: "role/%{::role}"
                    Path not found
                  Path "/etc/puppetlabs/code/environments//hieradata/hostgroup/.yaml"
                    Original path: "hostgroup/%{::hostgroup}"
                    Path not found
                  Path "/etc/puppetlabs/code/environments//hieradata/team/infra.yaml"
                    Original path: "team/%{::team}"
                    Path not found
                  Path "/etc/puppetlabs/code/environments//hieradata/enclave/ccs.yaml"
                    Original path: "enclave/%{::enclave}"
                    Path not found
                  Path "/etc/puppetlabs/code/environments//hieradata/common.yaml"
                    Original path: "common"
                    Path not found
      ...
      2018-02-09 15:27:40,735 ERROR [qtp194608888-66] [puppetserver] Puppet Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Class[Dns::Client]: expects a value for parameter 'server' (file: /etc/puppetlabs/code/environments/production/.site/profile/manifests/common.pp, line: 42, column: 2
      1) on node led.corp.com
      ...

      As you can see the %{environment} variable is not expanded

       

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              melissa Melissa Stone
              Reporter:
              pyther Matthew Gyurgyik
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support