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

puppet plugin download fails if agent specified environment doesn't exist on the agent

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.16.0
    • None
    • Bug Fix
    • Calling `puppet plugin download --environment <env>` failed if the environment directory didn't exist locally, which it typically won't when running the command on a host different from the host running puppetserver.
    • Needs Assessment

    Description

      Add a dev environment to /etc/puppetlabs/code/environments/dev on the puppetserver.
      On a different host, the agent run will succeed, but plugin download will fail:

      $ puppet agent -t -E dev
      Info: Using configured environment 'dev'
      Info: Retrieving pluginfacts
      Info: Retrieving plugin
      Info: Retrieving locales
      Info: Caching catalog for XXX
      Info: Applying configuration version '1582303430'
      $  bx puppet plugin download  -E dev
      bundler: failed to load command: puppet (/Users/josh/work/puppet/.bundle/ruby/2.3.0/bin/puppet)
      Puppet::Environments::EnvironmentNotFound: Could not find a directory environment named 'dev' anywhere in the path: /Users/josh/.puppetlabs/etc/code/environments. Does the directory exist?
        /Users/josh/work/puppet/lib/puppet/environments.rb:40:in `get!'
        /Users/josh/work/puppet/lib/puppet/application_support.rb:34:in `push_application_context'
        /Users/josh/work/puppet/lib/puppet/application.rb:370:in `run'
        /Users/josh/work/puppet/lib/puppet/util/command_line.rb:143:in `run'
        /Users/josh/work/puppet/lib/puppet/util/command_line.rb:77:in `execute'
        /Users/josh/work/puppet/bin/puppet:5:in `<top (required)>'
        /Users/josh/work/puppet/.bundle/ruby/2.3.0/bin/puppet:22:in `load'
        /Users/josh/work/puppet/.bundle/ruby/2.3.0/bin/puppet:22:in `<top (required)>'
      

      The problem is the plugin application needs to specify that the environment is not required to exist locally:

      diff --git a/lib/puppet/application/plugin.rb b/lib/puppet/application/plugin.rb
      index 2d0402e43f..06beb9eabf 100644
      --- a/lib/puppet/application/plugin.rb
      +++ b/lib/puppet/application/plugin.rb
      @@ -1,3 +1,4 @@
       require 'puppet/application/face_base'
       class Puppet::Application::Plugin < Puppet::Application::FaceBase
      +  environment_mode :not_required
       end
      

      Attachments

        Activity

          People

            josh Josh Cooper
            josh Josh Cooper
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support