Ask Your Question
0

PE 3.8 Directory Envs - HOWTO ?

asked 2015-09-02 23:14:01 -0500

cm01 gravatar image

updated 2015-09-03 20:57:22 -0500

@Moderators: the first code block for puppet.conf looks fine in Preview, but the code formatting disappears when saving ...

I have PE 3.8.1 installed; trying to setup 2 envs. The default production env is working fine, but adding a 2nd env eg testenv1 has parsing issues for its site.pp

puppet.conf

[main]
certname = puppet.local
vardir = /var/opt/lib/pe-puppet
logdir = /var/log/pe-puppet
rundir = /var/run/pe-puppet
basemodulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
environmentpath = /etc/puppetlabs/puppet/environments
server = puppet.local
user  = pe-puppet
group = pe-puppet
archive_files = true
archive_file_server = puppet.local
module_groups = base+pe_only
parser = future

[agent]
    report = true
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig
    graph = true
    pluginsync = true


[master]
node_terminus = classifier
reports = console,puppetdb
storeconfigs = true
storeconfigs_backend = puppetdb
certname = puppet.local
always_cache_features = true

  # pwd
/etc/puppetlabs/puppet/environments/test_env_1/manifests

# cat site.pp 
# site.pp 

# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
# used when an agent connects to a master and asks for an updated configuration.
#
# Global objects like filebuckets and resource defaults should go in this file,
# as should the default node definition. (The default node can be omitted
# if you use the console and don't define any other nodes in site.pp. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.)

# Active Configurations 

# PRIMARY FILEBUCKET
# This configures puppet agent and puppet inspect to back up file contents when
# they run. The Puppet Enterprise console needs this to display file contents
# and differences.

# Define filebucket 'main':
filebucket { 'main':
  server => 'puppet.local',
  path   => false,
}

# Make filebucket 'main' the default backup location for all File resources:
File { backup => 'main' }

# DEFAULT NODE
# Node definitions in this file are merged with node data from the console. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.

# The default node definition matches any node lacking a more specific node
# definition. If there are no other nodes in this file, classes declared here
# will be included in every node's catalog, *in addition* to any classes
# specified in the console for that node.

node default {
  # This is where you can declare classes for all nodes.
  # Example:
  #   class { 'my_class': }
}

# My Nodes ...
include vm2

Now, parser validate works fine, but

# puppet  apply   site.pp 
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::vm2 for puppet.local at /etc/puppetlabs/puppet/environments/test_env_1/manifests/site.pp:45:1 on node puppet.local
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::vm2 for puppet.local at /etc/puppetlabs/puppet/environments/test_env_1/manifests/site.pp:45:1 on node puppet.local

# pwd
/etc/puppetlabs/puppet/environments/test_env_1/modules/vm2/manifests



# cat init.pp 
# vm2.local defn
class vm2 {
    node vm2.local {
        include vm2::groups
        include vm2::users
#       include testing
    }
}

Has anyone got a working example please?

Chris

===========================================================================

Hi Greg:

  1. Actually the above setup does work just fine for the 1st aka "production" env ...

(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-09-03 00:31:32 -0500

GregLarkin gravatar image

updated 2015-09-04 13:06:56 -0500

Puppet classes do not include the "node" directive. I don't know if that's the root cause of your problem, but you should remove it from the class file anyway. The node directive is used in your site.pp file, either as a "node default" or "node <some hostname>". This page should help: https://docs.puppetlabs.com/puppet/3.8/reference/langnodedefinitions.html

One other thing to note - puppet apply is not generally used with the site.pp file, since it typically contains the node directives, and puppet apply does not handle those the way the Puppet master does. puppet apply is good for testing your classes locally during development by creating a test manifest (often in the tests/ or examples/ subdirectory of your module) that simply contains "include <your classname>". It's not often executed directly on the Puppet master because it applies changes immediately to the node it's running on.

Puppet apply is a great tool to use during development, often in a Vagrant VM, that has all of the Puppet code loaded in it. You can edit the code, save it, and run puppet apply to test it. If you decide to try that, have a look here: https://docs.vagrantup.com/v2/provisioning/puppet_apply.html

Try running puppet apply on your target node with the --modulepath argument and manually specify the module path that you want. Of course, the Puppet code should be loaded on the node you're logged into, and the module path should include the testenv1 environment directory. It may also be helpful to invoke puppet apply with the "--debug" option while troubleshooting this problem.

UPDATE: Hi Chris, in order for puppet apply to use your testenv1 module directory, you'll have to use the method I described in the 4th paragraph above. Puppet apply does not natively handle environments so using the modulepath option sets everything up correctly. Once you start using Puppet in the master/agent configuration, you can assign the proper environment through the PE console or some other ENC.

This is the page I use when I'm working with node classification and environments: https://docs.puppetlabs.com/pe/3.8/consoleclassesgroupsenvironmentoverride.html

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-09-02 23:14:01 -0500

Seen: 503 times

Last updated: Sep 04 '15