Bug #6452
closedSource file from the wrong environment
Description
In order to make some changes to a module and test before pushing them to production, I copied a module from /etc/puppet/environments/production to /etc/puppet/environments/development
Then I added the following statement to the class and consequently I generated the file /etc/puppet/environments/development/modules/rimm-base/files/hugepage-defrag-off
case $::osfamily { debian: {
case $::lsbmajdistrelease {'7': {
file {"/etc/cron.d/hugepage-defrag-off":
source => 'puppet:///modules/rimm-base/hugepage-defrag-off',
owner => 'root',
group => 'root',
mode => '0644', }
}}
}}
I run the agent on a development node that got the changes but unexpectedly failed to fetch the file:
root@eca86bfa40d8:~# /usr/sbin/puppetd --onetime --no-daemonize --verbose --logdest syslog
notice: Ignoring --listen on onetime run
info: Caching catalog for eca86bfa40d8
info: Applying configuration version '1404161338'
err: /Stage[main]/Rimm-base/File[/etc/cron.d/hugepage-defrag-off]: Could not evaluate: Could not retrieve information from *environment production* source(s) puppet:///modules/rimm-base/hugepage-defrag-off at /etc/puppet/environments/development/modules/rimm-base/manifests/init.pp:114
notice: Finished catalog run in 5.03 seconds
Following the hint given by the error message I therefore tried to copy the file
/etc/puppet/environments/development/modules/rimm-base/files/hugepage-defrag-off
into
/etc/puppet/environments/production/modules/rimm-base/files/
and magically:
root@eca86bfa40d8:~# /usr/sbin/puppetd --onetime --no-daemonize --verbose --logdest syslog
notice: Ignoring --listen on onetime run
info: Caching catalog for eca86bfa40d8
info: Applying configuration version '1404161534'
notice: /Stage[main]/Rimm-base/File[/etc/cron.d/hugepage-defrag-off]/ensure: defined content as '{md5}a62ff42d216058e8c2d791449efe3165'
notice: Finished catalog run in 4.93 seconds
The node's ENC is the following:
root@blabla-server:/etc/puppet/environments/development/modules/rimm-base# sudo -u puppet /etc/puppet/node.rb eca86bfa40d8
---
classes:
rimm-base:
rimm_ip: 10.99.99.1
rimm_mask: 255.255.255.0
timezone: Europe/Rome
rimm-drivers:
moxa_nport: false
moxa_uport1130: false
moxa_uport1250: false
parameters:
puppetmaster: foreman-proxy.blabla.it
hostgroup: blabla-development
foreman_env: development
owner_name: Admin User
owner_email: root@blabla
As provided by foreman installaer in the puppet.conf file I have:
[development]
modulepath = /etc/puppet/environments/development/modules:/etc/puppet/environments/common:/usr/share/puppet/modules
config_version =
[production]
modulepath = /etc/puppet/environments/production/modules:/etc/puppet/environments/common:/usr/share/puppet/modules
config_version =
Is this bug or am doing something wrong here?
In case it looks more like a puppet bug, but since its configuration is the one generated by the foreman installer I posted it here at this stage.
Regards,
PL
Updated by Dominic Cleal over 10 years ago
- Status changed from New to Feedback
How are you setting the environment? Usually Foreman would specify it from node.rb, but I see this is missing (perhaps you've set "enc_environment" to false in Adminster>Settings).
Ensure you're using Puppet 3.0 or higher, as environments weren't handled well in 2.x, leading to mismatches like the one you're seeing.
Updated by Paolo Larcheri over 10 years ago
Paolo Larcheri wrote:
The node's ENC is the following:
root@blabla-server# sudo -u puppet /etc/puppet/node.rb eca86bfa40d8
---
classes:
rimm-base:
rimm_ip: 10.99.99.1
rimm_mask: 255.255.255.0
timezone: Europe/Rome
rimm-drivers:
moxa_nport: false
moxa_uport1130: false
moxa_uport1250: false
parameters:
puppetmaster: foreman-proxy.blabla.it
hostgroup: blabla-development
foreman_env: development
owner_name: Admin User
owner_email: root@blabla
My enc_environment variable is set to true.
Actually am using puppet 2.7.23, anyway I'd expect the ENC above to include the environment parameter (I guess the master is not aware of what the foreman_env parameter is meaning)
Is this a misbehaviour of my foreman instance?
regards,
PL
Updated by Dominic Cleal over 10 years ago
If it's missing and enc_environment appears to be true, yes, that's a Foreman issue. Maybe try changing it to false & back to true in the UI. Even when this is present, you'll need Puppet 3.x for it to completely follow what the Puppet master/ENC are saying is the environment, or you'll see exactly the issue you describe - where files are loaded from production, but the catalog/manifests are loaded from the ENC environment.
I'm still not sure how you're setting the development environment without it though?
Updated by Paolo Larcheri over 10 years ago
Ok, forget it, I unvoluntarily truncated the output. I rerun the node.rb and as expected there is a trailing "environment: development".
I will try upgrading the agent.
Thanks for the time,
PL
Updated by Dominic Cleal over 10 years ago
- Status changed from Feedback to Resolved
Ah cool, that makes more sense, so you're seeing the old Puppet 2.x issue. Please take note of these config changes between Puppet 2 and 3 when upgrading: http://projects.theforeman.org/projects/foreman/wiki/FAQ#Upgrade-puppet-from-v2-to-v3-gotchas, or if you've recently installed, you can upgrade Puppet and re-run our installer to update relevant configuration. Be sure to keep the Puppet master version newer than the agent.