Foreman and default classes (con't from puppet users)

So someone brought up in the puppet users group how to add a class to all
systems in foreman. It sounds like there is currently not a way to do
this, please correct me if I'm wrong. If so I'll create a feature request
for it. :slight_smile:

Also, here is what I'm looking to do to add this feature for myself as I
need this as a workaround for a bug I ran into with puppet (normally I was
assigning classes for all hosts in site.pp) …

— /var/tmp/host.rb 2012-05-11 10:01:24.000000000 -0500
+++ app/models/host.rb 2012-05-11 10:04:58.000000000 -0500
@@ -283,6 +283,8 @@ class Host < Puppet::Rails::Host

 info_hash = {}
 info_hash[&#39;classes&#39;] = self.puppetclasses_names
  • default_classes = [ 'common' ]
  • info_hash['classes'] = info_hash['classes'] | default_classes
    info_hash['parameters'] = param
    info_hash['environment'] = param["foreman_env"]

Basically for now hardcode a new array of classes I would like to be added
to all hosts, and then merge that with classes already assigned to the
host. THis is for others who maybe want/need this functionality and don't
mind hacking. You'll need to 'patch' this into future releases of foreman
as well.

The example above would add class 'common' to all systems. You can also
have multiple classes just by adding array elements for the classes you
want:

default_classes = [ 'common', 'common_new' ]

Would then add both common and common_new to all systems.

Regards,
Jake

> So someone brought up in the puppet users group how to add a class to all systems in foreman. It sounds like there is currently not a way to do this, please correct me if I'm wrong. If so I'll create a feature request for it. :slight_smile:
>
> Also, here is what I'm looking to do to add this feature for myself as I need this as a workaround for a bug I ran into with puppet (normally I was assigning classes for all hosts in site.pp) …

I have always made a default group and then based all other groups off the default group. This way I can assign a module to a every node so as long as they are part any group.

Although the problem is that unless they are assigned a group, they will not get any "common" modules.

··· On May 11, 2012, at 8:13 AM, jmccann wrote:

— /var/tmp/host.rb 2012-05-11 10:01:24.000000000 -0500
+++ app/models/host.rb 2012-05-11 10:04:58.000000000 -0500
@@ -283,6 +283,8 @@ class Host < Puppet::Rails::Host

 info_hash = {}
 info_hash['classes'] = self.puppetclasses_names
  • default_classes = [ ‘common’ ]
  • info_hash[‘classes’] = info_hash[‘classes’] | default_classes
    info_hash[‘parameters’] = param
    info_hash[‘environment’] = param[“foreman_env”]

Basically for now hardcode a new array of classes I would like to be added to all hosts, and then merge that with classes already assigned to the host. THis is for others who maybe want/need this functionality and don’t mind hacking. You’ll need to ‘patch’ this into future releases of foreman as well.

The example above would add class ‘common’ to all systems. You can also have multiple classes just by adding array elements for the classes you want:

default_classes = [ ‘common’, ‘common_new’ ]

Would then add both common and common_new to all systems.

Regards,
Jake


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/-/Eq8IC75MpMcJ.
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.

I didn't even think of that approach! But yea, most of our systems
currently are not assigned to groups … and builds are not strictly
controlled through foreman so unless there is a way to set a default
hostgroup to assign to a system it wouldn't help me.

But thanks for that point still, I hadn't thought of it.

Regards,
Jake

So I've submitted this as a feature request:
http://theforeman.org/issues/1616

Regards,
Jake