Search code examples
puppettheforeman

Foreman v1.7 Environment blank/null


Issue:

In Foreman I see the Environment column empty for this (and any other client) I try to add.

Environment:

I have a Foreman 1.7 Server with 2 additional Puppet masters (3.8.2) which are seen in Smart-Proxies and look healthy. I have created a new environment call 'destruct' which is defined in /etc/puppet/environments on all 3 servers with 'puppet' as the owner.

/etc/puppet/environments/destruct/   
    ├── manifests
    └── modules
        └── linux_ntp
            ├── manifests
            │   ├── config.pp
            │   ├── init.pp
            │   ├── install.pp
            │   ├── params.pp
            │   └── service.pp
            ├── metadata.json
            ├── Modulefile
            ├── Rakefile
            ├── README.markdown
            ├── spec
            │   ├── spec_helper.rb
            │   └── spec.opts
            ├── templates
            │   └── ntp.conf.erb
            └── tests
                └── init.pp

The environments path is specified in the [master] section in puppet.conf in all 3 servers (foreman server + 2 external puppet masters) so directory environments should be in play.

environmentpath  = /etc/puppet/environments
basemodulepath   = /etc/puppet/modules

I added the 'destruct' environment in Foreman: Configure->Environments, after which I ran the import from all 3 servers and it did not try to remove it, and it did import that single ntp module.

When I attempt to add a new puppet agent I specify the environment as 'destruct' in puppet.conf:

report      = true
pluginsync  = true
masterport  = 8140
certname    = clientname.domain
server      = puppetserver1.domain
listen      = true
environment = destruct
ca_server   = foremanserver1.domain

However in Foreman I see the Environment column empty for this (and any other client) I try to add. There are no errors on the puppet agent indicating it cannot find that environment.

I am able to manually assign a sever to an environment after it is in Foreman and successfully run modules, but that is far from ideal.

Any ideas why client systems are not being automatically assigned to the correct environment?


Solution

  • It appears that this behavior is expected. If you are using Foreman only as a puppet ENC then when a new sever is added via the puppet agent it does not auto-populate the Puppet Environment in Foreman based on what is in puppet.conf 'environment' variable, as I expected.

    It looks like the best way is to create the Hosts in Foreman (via the API or WebUI) then your puppet environment in Foreman would be correctly applied.