I'm joining this project now. I made inquiries a few months ago, and 
finally our internal puppet management team green-lighted me for the 
enhancements that needed to be made. 

The main focus point and primary obstacle to my enhancements is 
external_node_v2.rb (puppet-foreman subproject).  I thank +domcleal for 
pointing me in direction of this file. It looks like it was originally 
authored by +ohadlevy and most recently by +mmoll. What I need to do is as 
follows: We use The Foreman purely as an ENC to puppet -- pretty much 
nothing else. We assign classes to hosts, and tag hosts as belonging to 
hostgroups and organizations. 

TheForeman's hostgroups feature does not integrate well with puppet. This 
would seem to be an obvious use-case, but for whatever reason, we're (UIBK) 
somewhat alone here. A hostgroup in TheForeman consists of an entire 
hierarchy of hostgroups. When TheForeman is queries as an ENC for a 
particular node, we get something like:

   hostgroup: base/base_uibk/base_osdb/postgresql/postgresql_95

What we want is that each hostgroup triggers a different Hiera file to be 
read. Our hiera.yaml file contains directives like this:

 :hierarchy:
   - "%{::environment}/hiera/base"
   - "%{::environment}/hiera/repos"
   - "%{::environment}/hiera/nodes/%{::clientcert}"
   - "%{::environment}/hiera/hostgroups/%{::foreman_hostgroup}"
   - "%{::environment}/hiera/hostgroups/%{::foreman_hostgroup_parent5}"
   - "%{::environment}/hiera/hostgroups/%{::foreman_hostgroup_parent4}"
   - "%{::environment}/hiera/hostgroups/%{::foreman_hostgroup_parent3}"
   - "%{::environment}/hiera/hostgroups/%{::foreman_hostgroup_parent2}"
   - "%{::environment}/hiera/hostgroups/%{::foreman_hostgroup_parent1}"
   - "%{::environment}/hiera/organizations/%{::foreman_organization}"

The result is that the hiera files will be processed in the following order:

   <organization-specific>
   hostgroups/base.yaml
   hostgroups/base_uibk.yaml
   hostgroups/base_osdb.yaml
   hostgroups/postgresql.yaml
   hostgroups/postgresql_95.yaml
   nodes/<certname>.yaml
   repos.yaml
   base.yaml

But there is no easy/clean way to get the hiera backend to process the 
hostgroup fact in such a way.

We can use the foreman to load a fact file on the client which will then 
report its facts. However, on the first run, the fact file will be empty 
and incomplete. This creates probelms for deployment. 

After discussions with domcleal, the simplest solution seems to be to 
modify the external_node_v2.rb file, which is replaced as node.rb on the 
production system.

I have created such a patch .... BUT I feel the strong need to refactor the 
code. A lot of this code does things that are completely mysterious to me 
(what's "push facts" for?), so I need to get a discussion going with all 
the maintainers of this file.


-- 
You received this message because you are subscribed to the Google Groups 
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to