It's important to keep in mind that Hiera is "just data". You still
need to actually create the resources somehow in your manifest based on
that data.
Thus, creating a data element called "classes" in Hiera isn't enough to
actually get those classes applied to the node. You need to add
hiera_include('classes') in your manifest. More info here:
https://docs.puppet.com/hiera/3.1/puppet.html#assigning-classes-to-nodes-with-hiera-hierainclude
Having said that, until you get more experience with Puppet I would
recommend avoiding using Hiera to assign classes to nodes. It can be
harder to debug and maintain, and breaks the rule of thumb that Hiera
should only contain configuration data and not class structure. You may
want to look into the "roles and profiles" model instead. There ARE
valid reasons to assign classes via Hiera (e.g. assigning a role to the
node based on the output of a custom Hiera backend) but this wouldn't be
the approach I recommend to a newbie. :)
On 6/26/2016 8:41 PM, Alex Samad wrote:
Hi
Newbie - greenfield install . Centos 6.8 - PC1 puppet. Master puppet
setup.
I have installed R10K and git and hiera.
I would like to group my nodes into groups
I'm doing some testing
testnode - puppet client
masternode - puppet master
On the master node I have
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/puppet/latest/reference/configuration.html
[master]
vardir = /opt/puppetlabs/server/data/puppetserver
logdir = /var/log/puppetlabs/puppetserver
rundir = /var/run/puppetlabs/puppetserver
pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
codedir = /etc/puppetlabs/code
# https://docs.puppet.com/puppetdb/4.1/connect_puppet_master.html
storeconfigs = true
storeconfigs_backend = puppetdb
reports = store,puppetdb
# https://docs.puppet.com/guides/external_nodes.html
node_terminus = exec
external_nodes = /usr/local/bin/puppet_node_classifier
I was use a node classifier at the top level to place nodes into
environments - but I am testing grouping nodes in to groups in 1 env/
all it produces is
---
environment: alex
for now
cat /etc/puppetlabs/puppet/hiera.yaml
# https://docs.puppet.com/hiera/3.1/configuring.html
---
:backends:
- yaml
:hierarchy:
- "nodes/%{::trusted.certname}"
- common
:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# -
%CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata
on Windows
# When specifying a datadir, make sure the directory exists.
:datadir:
This is the default hiera setup
cat /etc/puppetlabs/code/environments/alex/hieradata/common.yaml
---
classes:
- profile::mypuppet
message: "This node is using common data"
#Puppet Server Tuning
puppet_enterprise::master::puppetserver::jruby_max_requests_per_instance:
0
cat
/etc/puppetlabs/code/environments/alex/site/profile/manifests/mypuppet.pp
class profile::mypuppet {
package { 'puppet-agent' :
ensure => 'present',
}
#include ::puppet_agent;
}
then i go to my test node
# for testing ..
sudo /opt/puppetlabs/bin/puppet agent --noop --verbose -t
Notice: Local environment: 'production' doesn't match server specified
node environment 'alex', switching agent to 'alex'.
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Applying configuration version
'ee80ea6b15178f517618992833a8bc3c7c378bd0'
Notice: Applied catalog in 0.04 seconds
I don't see any mention of mypuppet ??
Am i testing the system the right way ?
What am i doing wrong ?
Thanks
Alex
--
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 [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/a7bb4a4b-d61b-4db0-bdff-57030d75cb51%40googlegroups.com
<https://groups.google.com/d/msgid/puppet-users/a7bb4a4b-d61b-4db0-bdff-57030d75cb51%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/cb352a0f-20a3-c79c-ada2-fe717850ebff%40alter3d.ca.
For more options, visit https://groups.google.com/d/optout.