Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
-
The agent should only use its remote environment during the configurer run, so it should only load features, etc from its pluginsync'ed libdir and never from the modulepath for its configured environment.
-
-
Coremunity
-
Platform Core KANBAN
-
Needs Assessment
-
Bug Fix
-
-
Needs Assessment
Description
Puppet loses track of the current environment when calling the autoloader to load/find:
- applications
- features
- parent providers that haven't been loaded yet, e.g. openbsd which is a parent of freebsd, where freebsd is loaded first because of its name.
- termini
Puppet then falls back to the configured environment (Puppet[:environment]), which may not match the current environment (Puppet.lookup(:current_environment)). For the agent specifically, it means we sometimes use the configured environment's modulepath which has a higher precedence than our libdir containing pluginsync'ed files. This is a problem, because when we include vendor_modules in the basemodulepath (see PUP-8582), we don't want that to have higher precedence that the libdir as the agent might load a type/provider that is incompatible with the type that the master used during compilation.
To reproduce, create the following files on the master:
[root@yhw77y0zn0j776u ~]# tree /etc/puppetlabs/code/environments/production/
|
/etc/puppetlabs/code/environments/production/
|
├── data
|
├── environment.conf
|
├── hiera.yaml
|
├── manifests
|
│ └── site.pp
|
└── modules
|
└── foo
|
└── lib
|
└── puppet
|
├── feature
|
│ └── foo.rb
|
├── provider
|
│ └── foo
|
│ └── foo.rb
|
└── type
|
└── foo.rb
|
|
10 directories, 6 files
|
[root@yhw77y0zn0j776u ~]# find /etc/puppetlabs/code/environments/production/{manifests,modules} -type f -print -exec cat {} \;
|
/etc/puppetlabs/code/environments/production/manifests/site.pp
|
foo { 'hi': }
|
/etc/puppetlabs/code/environments/production/modules/foo/lib/puppet/type/foo.rb
|
Puppet::Type.newtype(:foo) do
|
newparam(:name, namevar: true)
|
newproperty(:message)
|
end
|
/etc/puppetlabs/code/environments/production/modules/foo/lib/puppet/feature/foo.rb
|
Puppet.features.add(:foo, libs: ['pp'])
|
/etc/puppetlabs/code/environments/production/modules/foo/lib/puppet/provider/foo/foo.rb
|
Puppet::Type.type(:foo).provide(:foo) do
|
confine :feature => :foo
|
|
def message=(value)
|
puts value
|
end
|
|
def message
|
:absent
|
end
|
end
|
On the agent which must be one a different host, create a bogus feature:
$ tree ~/.puppetlabs/etc/code/environments/production/modules
|
/Users/josh/.puppetlabs/etc/code/environments/production/modules
|
└── foo
|
└── lib
|
└── puppet
|
└── feature
|
└── foo.rb
|
|
4 directories, 1 file
|
$ cat ~/.puppetlabs/etc/code/environments/production/modules/foo/lib/puppet/feature/foo.rb
|
BOOM!!
|
The agent run will fail, with the path to the bogus feature:
$ bx puppet agent -t
|
Info: Using configured environment 'production'
|
Info: Retrieving pluginfacts
|
Info: Retrieving plugin
|
Info: Retrieving locales
|
Info: Caching catalog for localhost
|
Error: Could not autoload puppet/feature/foo: /Users/josh/.puppetlabs/etc/code/environments/production/modules/foo/lib/puppet/feature/foo.rb:1: syntax error, unexpected end-of-input
|
Error: Failed to apply catalog: Could not autoload puppet/feature/foo: /Users/josh/.puppetlabs/etc/code/environments/production/modules/foo/lib/puppet/feature/foo.rb:1: syntax error, unexpected end-of-input
|