Assigning Classes based on facter info

Hi All,

My setup consists of assigning nodes which contain roles based on custom
facter values in order to avoid adding hosts in node.pp. Based on the setup
mentioned below:

http://nuknad.com/2011/02/11/self-classifying-puppet-nodes/

Is there a possibility of creating roles (which contain puppet classes) and
then assign them to nodes which have a particular facter values within
foreman?

Eg: I have following in puppet

  • In /etc/puppet/modules/truth/manifests/init.pp

class truth::enforcer {
$groupname = "$company_platform-$company_dc-$company_role"
case $groupname {
"production-dc1-dev_tst" : {
include role::production::dc1::dev_tst
}
}
}

  • In /etc/puppet/manifests/nodes.pp

node default {
include truth::enforcer
}

  • In classes.pp

class role::production::dev_tst::frankfurt inherits role {
include apache
}

  • Could i create a file via foreman : eg : /etc/company_facts.txt via the
    UI for the host that is being provisioned and that would create the
    following on the host.

role = dev_tst
platform = production
location = dc1

The fields could be any custom facts defined by the user.

Is the above classes defined in puppet doable via the foreman UI or does
the UI need to be refactored?. I feel this could a good addition to foreman
UI, since this would enable clear separation of hosts according to facter.

Awaiting feedback.

Regards,
Kevin

What you want to do is to create a puppet module with a truth class that
assigns roles based on facts, smartvars, parameters, or the new
parameterized classes feature. Inside this class you can set up your
conditions for assigning roles. Example:

class truth {

If $::kernel == 2.6.9{
class { "truth::apacherole": }
}
# foreman parameter
If $::foremanrole == dbrole{
class { "truth::dbrole" }
}

}
class truth::dbrole{
class {" bloatedsoftware::oracle" :}

}

··· On Oct 16, 2012 5:19 AM, "linuxbsdfreak" wrote:

Hi All,

My setup consists of assigning nodes which contain roles based on custom
facter values in order to avoid adding hosts in node.pp. Based on the setup
mentioned below:

http://nuknad.com/2011/02/11/self-classifying-puppet-nodes/

Is there a possibility of creating roles (which contain puppet classes)
and then assign them to nodes which have a particular facter values within
foreman?

Eg: I have following in puppet

  • In /etc/puppet/modules/truth/manifests/init.pp

class truth::enforcer {
$groupname = "$company_platform-$company_dc-$company_role"
case $groupname {
“production-dc1-dev_tst” : {
include role::production::dc1::dev_tst
}
}
}

  • In /etc/puppet/manifests/nodes.pp

node default {
include truth::enforcer
}

  • In classes.pp

class role::production::dev_tst::frankfurt inherits role {
include apache
}

  • Could i create a file via foreman : eg : /etc/company_facts.txt via the
    UI for the host that is being provisioned and that would create the
    following on the host.

role = dev_tst
platform = production
location = dc1

The fields could be any custom facts defined by the user.

Is the above classes defined in puppet doable via the foreman UI or does
the UI need to be refactored?. I feel this could a good addition to foreman
UI, since this would enable clear separation of hosts according to facter.

Awaiting feedback.

Regards,
Kevin


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/foreman-users/-/L4tBKRFi3l0J.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.