Fresh install of foreman 1.17 on CentOS7 with puppet agent 5.5.1 (puppet server 5.3) doesn't display puppet environments and won't fetch new classes

Problem:
I have just completed fresh install of puppet5 and foreman on a brand new node. Some portions of foreman seem to work with puppet (initial import of classes). However importing environment seems to flow OK, and then… I see no environment listed and prompt to add new environment is being displayed. It seems like foreman does create those environments as attempting to manually create one with the same name fails.

Importing classes worked the first time, but subsequent runs do not pick up new classes from the environment.

Expected outcome:

I should be able to see all the environments puppet has. I should be able to [re]import classes updating their list accordingly.

Foreman and Proxy versions:

1.17

Foreman and Proxy plugin versions:

N/A

Other relevant data:
N/A

Can you share more details on what’s in the new environment / classes that aren’t being seen? For the record:

  • Foreman won’t import defines so check what’s actually in the .pp files - if it’s all defines, then you won’t see that module offered for import at all
  • Foreman will ignore empty environments (after accounting for defines, so it may look empty to Foreman, even if it’s not to you)
  • Foreman will ignore anything listed in the ~foreman/config/ignored_environments.yml file (nothing by default, but check it).

If you definitely have a class not a define, and Foreman’s not seeing it, then the proxy logs on your Puppet proxy are going to be the next step.

the part about defines makes sense. however I have just gone ahead and created /etc/puppetlabs/code/environments/production/modules/mymodule/manifests/init.pp:
class mymodule{
file {’/tmp/mymodule’:
ensure => ‘present’,
content => ‘this is my module’,
}
}
and when I try to refresh foreman I get “no changes detected”.

to add to the above: with additional module like ‘mymodule’ in place I still see no “environment”. I’ve added reference to mymodule from environments/production/manifests/sites.pp and confirmed it runs fine on the node intended (foreman node): ‘puppet agent -t’ however foreman plain refuses to see (or display?) newly created class and corresponding environment.

Bump the proxy up to debug logging, tail the log (/var/log/foreman-proxy/proxy.log), and restart it. It should dump the Puppet it’s working from, and you can check it over. Feel free to post it if you’re OK with that.

looking at logs it seems that foreman does see the environments:

D, [2018-05-25T16:15:07.173854 ] DEBUG -- : Initializing puppet class cache for 'production' environment
D, [2018-05-25T16:15:07.174117 ] DEBUG -- : Initializing puppet class cache for 'common' environment
D, [2018-05-25T16:15:07.182139 ] DEBUG -- : Initializing puppet class cache for 'development' environment

also logging in as admin I was able to see ‘mymodule’. However interface itself still insists that there are no environments defined and prompts me to either create one or import one.

In Foreman? Is the issue that the import works but the classes can’t be seen by a normal user? If not, what are you logging in to?

yes, in foreman web UI.

Issue is that while logged in as admin I can import environments/classes, but subsequently they are not displayed in web UI.

Which part of the UI are you looking in? Host(group) edit, or under Puppet Classes?

configure/environments

or

configure/classes

of which latter one seems to be working at least in context of “admin” user. Former (environment) does not show up in any interface (admin or otherwise) under above specified UI path.

Do you use Organizations/Locations? If so, environment might be imported into different Organizations/Locations than your current context (which is shown in topbar)

@Ondrej_Prazak that did it! I had to de-select Organization & Location to see the environment, and once accessed I’ve found out that it wasn’t assigned any Organization nor Location. I’ll assign it manually.

Note you can choose where should the environments be imported automatically for next time.

Go to Administer > Settings, “Puppet” tab and set “Default organization” and “Default location” to whatever you need :smile:

2 Likes

thanks @dLobatog I’ve done just that. :slight_smile: