Dear all,
beg your pardon if this question was already answered before, but I'm kind 
of stuck with this.

I want to learn more about environments,  the goal is to assign a node to a 
different environment via the agent's puppet.conf. But no matter what I 
try, the node is still using the default environment "production".

Found the following in the documentation:
https://docs.puppet.com/puppet/4.3/reference/environments_assigning.html
<quote>
There are two ways to assign nodes to a different environment:

    Via your ENC or node terminus
    Via each agent node’s puppet.conf

Assigning Environments Via the Agent’s Config File

In puppet.conf on each agent node, you can set the environment setting in 
either the agent or main config section. When that node requests a catalog 
from the Puppet master, it will request that environment.

If you are using an ENC and it specifies an environment for that node, it 
will override whatever is in the config file.  
</quote>

Steps done:
===========
1. Set up a fresh node:
[root@glucks ~]# puppet agent -t
Info: Caching certificate for glucks.localdomain
Info: Caching certificate_revocation_list for ca
Info: Caching certificate for glucks.localdomain
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
...

2. Created the following directory structure for env "test" on the puppet 
server
[root@puppmaster environments]# tree -L 3
.
├── production
│   ├── environment.conf
│   ├── manifests
│   │   ├── site.pp
│   │   ├── site.pp~
│   │   ├── site.pp_20160321
│   │   ├── site.pp_orig
│   │   └── site.pp_with_pieps_error
│   └── modules
│       └── stdlib
└── test
    ├── hieradata
    ├── manifests
    │   ├── site.pp
    │   └── site.pp~
    └── modules

Puppet server, version:
[root@puppmaster ~]# puppet-enterprise-version-check
Version 2016.1.1 is now available! (currently 2015.3.2).
http://links.puppet.com/enterpriseupgrade


3. node glucks is not listed in the $environment/manifests/site.pp, just 
put in a message:
/etc/puppetlabs/code/environments/production/manifests/site.pp

# atouim print out message only (fallback)
# here you declare modules for ALL nodes
node default {
  notify { "${::fqdn} has no node definition, env production": }
}

/etc/puppetlabs/code/environments/test/manifests/site.pp
node default {
  notify { "${::fqdn} has no node definition, env test": }
}

4. puppet.conf for puppet server and node
puppet.conf for Puppet server
-----------------------------
[root@puppmaster ~]# cat /etc/puppetlabs/puppet/puppet.conf
[main]
    certname = puppmaster.localdomain
    server = puppmaster.localdomain
    user  = pe-puppet
    group = pe-puppet
    archive_files = true
    archive_file_server = puppmaster.localdomain
    module_groups = base+pe_only
    environmentpath = /etc/puppetlabs/code/environments

[agent]
    graph = true


[master]
  app_management = true
  node_terminus = classifier
  storeconfigs = true
  storeconfigs_backend = puppetdb
  reports = puppetdb
  certname = puppmaster.localdomain
  always_cache_features = true

puppet.conf for node glucks
----------------------------
[root@glucks puppet]# cat /etc/puppetlabs/puppet/puppet.conf
# This file can be used to override the default puppet settings.
# See the following links for more details on what settings are available:
# - 
https://docs.puppetlabs.com/puppet/latest/reference/config_important_settings.html
# - 
https://docs.puppetlabs.com/puppet/latest/reference/config_about_settings.html
# - 
https://docs.puppetlabs.com/puppet/latest/reference/config_file_main.html
# - https://docs.puppetlabs.com/references/latest/configuration.html
[main]
server = puppmaster.localdomain
[agent]
certname = glucks.localdomain
# atouim 20150413 assign env via the puppet agent's config file
environment = test

5. Test the environment on the node

a) specify env "test" on command line
[root@glucks puppet]#  puppet agent --test --server=puppmaster.localdomain 
--environment=test
Notice: Local environment: 'test' doesn't match server specified node 
environment 'production', switching agent to 'production'.
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for glucks.localdomain
Info: Applying configuration version '1460558479'
Notice: glucks.localdomain has no node definition, env production
Notice: /Stage[main]/Main/Node[default]/Notify[glucks.localdomain has no 
node definition, env production]/message: defined 'message' as 
'glucks.localdomain has no node definition, env production'
Notice: Applied catalog in 0.51 seconds
[root@glucks puppet]# 

b) specify env "production" on command line
[root@glucks puppet]#  puppet agent --test --server=puppmaster.localdomain 
--environment=production
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for glucks.localdomain
Info: Applying configuration version '1460558637'
Notice: glucks.localdomain has no node definition, env production
Notice: /Stage[main]/Main/Node[default]/Notify[glucks.localdomain has no 
node definition, env production]/message: defined 'message' as 
'glucks.localdomain has no node definition, env production'
Notice: Applied catalog in 0.49 seconds
[root@glucks puppet]# 

Any help is greatly appreciated.

Thank you for your input and your time,

Manuela Atoui


-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/8698d98d-4112-4617-b030-e6af6655c2a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to