puppet lookup could not find directory environment

157 views
Skip to first unread message

dkoleary

unread,
Dec 5, 2017, 1:44:56 PM12/5/17
to Puppet Users
Hi;

I'm running open source puppet server ver 5.  So far, I've been exceedingly happy with the performance and maintainability of it.  I'm about to start a rewrite of a module and would like to verify some hiera data.  Quick google search shows what looks like it should be the perfect tool - problem is, it doesn't work.

On the puppet server, I run:

# puppet lookup fqdn
Error: Could not run: Could not find a directory environment named 'unconfigured' anywhere in the path: /etc/puppetlabs/code/environments. Does the directory exist?


I tried adding the environment with the same result:

# puppet lookup --environment production fqdn
Error: Could not run: Could not find a directory environment named 'unconfigured' anywhere in the path: /etc/puppetlabs/code/environments. Does the directory exist?

Puppet environments, in my setup, are established via an external node classifier.  I tried adding 'environment = production' to the user section of /etc/puppetlabs/puppet/puppet.conf but that didn't have any affect either.  Even with that, though, I would have thought specifying the environment on the command line would resolve that.

Has anyone seen this and know what I may have messed up and/or how to work around it?

Any hints/tips/suggestions greatly appreciated.

Doug O'Leary


Christopher Wood

unread,
Dec 5, 2017, 2:10:44 PM12/5/17
to puppet...@googlegroups.com
Twofold:

"fqdn" is usually a puppet fact, I suspect you wouldn't find that if you grepped your hiera data. Try these as root on any node:

facter fqdn
facter -p | less

If you do have a hiera key called "fqdn", you can try looking it up on any host which has your environments in the usual place and using the explain parameter to have it tell you what's wrong.

puppet lookup --node myhost.me.com --environment production --explain myclass::someparam
puppet lookup --node myhost.me.com --environment production --explain fqdn
puppet help lookup | less
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/ae431f1f-02de-4ad2-abdb-92ed5288ef15%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/ae431f1f-02de-4ad2-abdb-92ed5288ef15%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

dkoleary

unread,
Dec 5, 2017, 2:23:33 PM12/5/17
to Puppet Users


On Tuesday, December 5, 2017 at 1:10:44 PM UTC-6, Christopher Wood wrote:
Twofold:

"fqdn" is usually a puppet fact, I suspect you wouldn't find that if you grepped your hiera data. Try these as root on any node:

You are quite right.  My attempt to simplify the problem apparently went awry.
 

puppet lookup --node myhost.me.com --environment production --explain myclass::someparam
puppet lookup --node myhost.me.com --environment production --explain fqdn
puppet help lookup | less


I had tried variations of those all with the same result:

# puppet lookup --environment production --node cl1vinfconf2442.mydom.com --explain mpiossec:run_ossec

Error: Could not run: Could not find a directory environment named 'unconfigured' anywhere in the path: /etc/puppetlabs/code/environments. Does the directory exist?

 mpiossec is *definitely* a hiera data entry.

Thanks for the response.  I appreciate it.

Christopher Wood

unread,
Dec 5, 2017, 2:50:10 PM12/5/17
to puppet...@googlegroups.com
(inline)

On Tue, Dec 05, 2017 at 11:23:32AM -0800, dkoleary wrote:
> On Tuesday, December 5, 2017 at 1:10:44 PM UTC-6, Christopher Wood wrote:
>
> Twofold:
>
> "fqdn" is usually a puppet fact, I suspect you wouldn't find that if you
> grepped your hiera data. Try these as root on any node:
>
> You are quite right.  My attempt to simplify the problem apparently went
> awry.
>  
>
> puppet lookup --node [1]myhost.me.com --environment production --explain
> myclass::someparam
> puppet lookup --node [2]myhost.me.com --environment production --explain
> fqdn
> puppet help lookup | less
>
> I had tried variations of those all with the same result:
> # puppet lookup --environment production --node cl1vinfconf2442.mydom.com
> --explain mpiossec:run_ossec
> Error: Could not run: Could not find a directory environment named
> 'unconfigured' anywhere in the path: /etc/puppetlabs/code/environments.
> Does the directory exist?
>  mpiossec is *definitely* a hiera data entry.
> Thanks for the response.  I appreciate it.

Quoth your earlier post:

"Puppet environments, in my setup, are established via an external node classifier."

What does the ENC return for that node? The ENC is listed under the "external_nodes" parameter in /etc/puppetlabs/puppet/puppet.conf, you should be able to run it at the console like "/usr/bin/myenc nodename" sort of thing.

The output makes me suspect that the environment is listed as "unconfigured" in your ENC output. Here I typically leave out the --environment parameter, so "puppet lookup" must be consulting the ENC at some point or I'd never find anything. I presume there is no /etc/puppetlabs/code/environments/unconfigured.

I notice you are missing a colon in your hiera key, should that be "mpiossec::run_ossec"? The class::param delimiter is two colons.

Editorially, it's quite nifty once you get it going, keep at it.

>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [3]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [4]https://groups.google.com/d/msgid/puppet-users/818f86f2-027a-487a-a457-593d35944206%40googlegroups.com.
> For more options, visit [5]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. http://myhost.me.com/
> 2. http://myhost.me.com/
> 3. mailto:puppet-users...@googlegroups.com
> 4. https://groups.google.com/d/msgid/puppet-users/818f86f2-027a-487a-a457-593d35944206%40googlegroups.com?utm_medium=email&utm_source=footer
> 5. https://groups.google.com/d/optout

dkoleary

unread,
Dec 5, 2017, 3:33:45 PM12/5/17
to Puppet Users
Enter code here...

Well, at least I've already checked all the things you're asking about.  While the problem is frustrating, I do hate proving I'm a complete idiot to the internet :)

On Tuesday, December 5, 2017 at 1:50:10 PM UTC-6, Christopher Wood wrote:
Quoth your earlier post:

[[snip]]


What does the ENC return for that node? The ENC is listed under the "external_nodes" parameter in /etc/puppetlabs/puppet/puppet.conf, you should be able to run it at the console like "/usr/bin/myenc nodename" sort of thing.

 cl1vinfconf2442 is my puppet server.  The enc output looks like:

# enc cl1vinfconf2442.mydom.com
---
classes
:
 
- roles::mpipsrv
environment
: production
parameters
:
  env
: prd
  dc
: cl1
  gw
: 10.168.65.254
  dmz
: false
  auth
: ldap
  grp
: NULL


I notice you are missing a colon in your hiera key, should that be "mpiossec::run_ossec"? The class::param delimiter is two colons.

Also quite correct.  My earlier attempts at that did have the two colons.  To verify that it still returns the same:

# puppet lookup --environment production --node cl1vinfconf2442.mydom.com --explain mpiossec::run_ossec
Error: Could not run: Could not find a directory environment named 'unconfigured' anywhere in the path: /etc/puppetlabs/code/environments. Does the directory exist?

You are again correct that there is no /etc/puppetlabs/code/environments/unconfigured.  Just to see what would happen, I did create a soft-link from unconfigured to production.  I didn't get the error anymore... just didn't get anything at all.

Now that I think of it, I ran those tests looking for fqdn.. let's try mpiossec::run_ossec:  ... Hey, would you look at that

# puppet lookup --node cl1vinfconf2442.mydom.com mpiossec::run_ossec
--- true

I'm beginning to suspect I know what's going on.  The ENC will return an environment of 'unconfigured' for any node it doesn't know about.  It's basically a catch-all that never gets used because in order to get that far a node has to have a cert which it won't get without being in the same database that the enc queries.  

so maybe ;puppet lookup' is getting the unconfigured from the enc and freaking before iet gets to the environment switch... I could probably confirm that by tracing the pid but, if an unconfigured env will get this working, I'm happy.

...

Partially working as it turns out.  it's still not accepting any puppet environment change.  Any rate, this will get me started.  thanks for the responses.

Doug O'Leary

dkoleary

unread,
Dec 5, 2017, 4:33:47 PM12/5/17
to Puppet Users
And resolved... that was ugly.

Turns out the ENC was returning an unconfigured node because it couldn't access the mysql db when running 'puppet lookup'  I ran that trace I was talking about and a painful bout of pouring through trace later, I saw several references to not being able to access the DB.  More looking, I finally saw that it was not using the puppet user's or root's .my.cnf file.  I created one where it said it was looking and I get some valid output:

# puppet lookup --node a_dmz_host.mydom.com mpisshd::sshd_config_source
--- sshd_config.dmz

I'm curious to find out what user that's running as if it can't find the .my.cnf for the only two users on the box... but, not curious enough to search for it any further.  

Thanks again for the Chris.  I appreciate it.

Doug O'Leary


Reply all
Reply to author
Forward
0 new messages