question ... i'm working on a class to configure t...
# testing
j
question ... i'm working on a class to configure the PE server itself, the class contains this:
Copy code
pe_ini_setting { 'main strict_variables true' :
    path    => '/etc/puppetlabs/puppet/puppet.conf' ,
    section => 'main' ,
    setting => 'strict_variables' ,
    value   => true ,
  }
when i try to run a unit test against it, the "expected to compile a catalog" test is failing with
Unknown resource type: 'pe_node_group'
... is there a way to "mock up" the PE modules? (i'm assuming there's no way to access their source code repos, so they can't be added to
.fixtures.yml
)
FWIW i tried adding this to the spec file, before the
on_supported_os.each
loop starts:
Copy code
let(:pre_condition) do
    <<-PRE_CONDITION
    define pe_ini_setting {}
    class pe_nginx {}
    PRE_CONDITION
  end
same error
b
I highly recommend to to use the ini_setting module and non of the pe* forks. They are considered private
šŸ‘ 1
j
i was wondering about that as well ... is
pe_ini_setting
just a copy of
ini_setting
with a different name, to avoid namespace collisions with user-supplied code?
b
Yes
j
related ... how "safe" is it to
notify => Service['pe-puppetserver']
? will the agent block until the restart finishes, or will it cause an error if the server isn't available to accept the report at the end of the run?
b
That works fine
r
I think PE suggests you use that for some specific reason. but if you can't find the pe_node_group defined type then it suggests your .fixtures.yml is missing a class, and changing to ini_setting won't address that.
c
pe_ini_setting
and
pe_node_group
are both considered "internal API" modules. They haven't changed in a while, but also if the Eng. team needed to make a sudden change, they would be saddened to learn of use outside of the PE installer as they are not expecting that.
r
oh, been a while but PSE had us use those to configure it after install
c
The
puppetlabs/inifile
module should cover all use cases that
pe_ini_setting
would be used for and
puppetlabs/node_manager
covers
pe_node_group
. Those are the external-facing modules for managing these resources.
j
so i added
puppetlabs/node_manager
to the
Puppetfile
and installed it in the environment directory, then changed my
pe_node_group
declarations to just
node_group
... when i run
puppet agent -t
it's failing with
Unknown resource type: 'node_group'
... the
node_manager
docs mention an "update_classes job" but don't explain what that actually is or why somebody may want/need to run it ... is that something that needs to be done, and if so, why is this the first time i'm running into the problem? i've added modules to the environment "on the fly" without problems before
b
How did you install it?
j
puppet module install --target-dir xxx --version '1.1.0' puppetlabs-node_manager
b
Don't do that. Use the Puppetfile and deploy it via code manager
c
--target-dir xxx
seems like it is installing somewhere outside of the normal modulepath.
b
Code manager ensures that the cache is flushed and the new content is loaded into the JVM. And it places the files into the correct directory
j
the whole point is to NOT use code manager ... i shouldn't have to commit, push, and wait on code manager for every single one-line change in a piece of code
b
If you have code manager enabled, caching is also enabled in the puppetserver
j
it's being installed into the same directory that
puppet config print environmentpath
points to
b
If you manually deploy code, you will have to flush the cache. And during the next code manager deploy, it will overwrite your change
j
there will be no "next code manager deploy" because, as i've said, code manager is not being used on this particular server.
b
And how do you deploy your Puppetfile that you mentioned?
j
so i guess the question is, how does one "flush the cache"? is that what this "update-classes job" is? and if so, it seems like there should be a way to do this without installing the
node_manager
module.
c
environmentpath
is a location to add environments, not modules. And, if Code Manager is active, that location is also it's exclusive domain and it will pave over any changes (or raise fatal errors if it bumps into content owned by
root
that it cannot remove as
pe-puppet
)
b
Flushing the cache has nothing to do with this particular module. https://bastelfreak.de/scalingpuppetserver/#14
j
on this server, code manager is disabled and
environmentpath
points to my non-root user's
$HOME/environments/
directory. i have a script which clones the control repo into a directory under that (i.e.
$HOME/environments/production
), then parses the
Puppetfile
it finds there and either clones or `puppet module install`s modules under
$HOME/environments/production/modules/
as needed
b
Why? :D
This just sounds incredible complex and error prone and annoying to debug
j
because it's LESS annoying than being forced to commit, push, and wait several minutes for code manager to rebuild the entire environment, every time i need to make a one-line change.
this is a development PE server, where i'm prototyping changes before they get committed into the repos. our "real" PE servers are (or will be) using code manager.
b
It doesn't rebuild the whole env
It would only deploy the missing module
j
so back to my question ... is what you describe as "flushing the cache", the same thing as what the node_manager module's docs are calling the "update-classes job"?
b
And if this takes several minutes you have some other issues
c
Yep. My recommendation would be to handle this configuration outside of PE in a Bolt project. That's how peadm does it. Making PE manage its self this way is creating an oroborous and that carries risks that can be avoided with a different approach.
j
yeah ... lots of code
as for bolt ... that's something i've never used, and don't really have the time to learn right now.
r
how are you running unit tests btw? Puppetfile management concerns aside, I think you want to add this to .fixtures.yml too.
j
i know about adding it to the fixtures file ... first i want it to actually WORK, then i'll add it to the unit tests.
r
ah your description said it was unit tests that were failing, and they don't read the Puppetfile at all.
j
the unit test is failing because it's not building a catalog in the first place ... and when i try
puppet agent -t
, it fails with the "unknown resource type" error message ... sorry if that wasn't clear
and doing the "clear cache" request from @bastelfreak’s blog page doesn't change anything, it still fails with the same "unknown resource type" message
HOWEVER ... after doing
systemctl restart pe-puppetserver
, the
node_group
resources are working as expected ... so it's obvious that (1) i'm missing something when i rebuild an environment directory, and (2) the "clear cache" thing isn't it. i have a vague memory of
r10k
rebuilding something after installing all of the modules, i think i need to do a deep dive into it ... actually, i'm curious about what command line options
r10k
itself has, maybe i can have my script call that to do 95% of the work of building each new environment
but that'll be tomorrow, it's past time to stop for the day ... thanks everybody for your help and patience, i know some of my questions can be really weird sometimes.
r
code manager is just r10k with a wrapper which is just the same as your script. use of r10k should massively simplify things for you (or g10k if you want a go version of it, whatever)
c
Code Manager is much more than a r10k wrapper. Running r10k is like 25% of what it does. Most of the rest is atomically syncing deployments to multiple other services. This functionality is required to enable many modern PE features: Disaster Recovery, Orchestrator Plans, CD4PE, etc.
r
fair - but in this context i think it's relatively similar, it does more but for deployments of the environments from Puppetfile alone, it's nearly interchangeable.
if one doesn't want to run code manager because of the "everything else", one should at least run r10k itself for the environment deploys.
c
Even then, use Code Manager. It is the standard code deployment mechanism for PE. Based on support case activity, I can count the number of installations not using Code Manager on one hand after a bad fireworks accident. And those cases are usually drawn out because they involve edge cases that arise out of doing something that 99.98% of other users are not doing.
j
the reason i'm not using code manager is because i don't want to have to commit/push/wait on code manager for EVERY SINGLE ONE-LINE CHANGE in a file. for the past 8 years i've been using a script which uses
rsync
to copy the current module over that module in the current environment on the PE server. that takes about three seconds, as opposed to a minute and and a half when code manager is involved - and that's also not counting the whole "every single one line change shows up as a commit in the repo forever" (we've had issues with "squash commits" in the past, our policy is "merge commits only" now)