1 "faulty" exported resource to block them all

asked 2015-08-18 04:43:25 -0600

janos gravatar image

Hi, so I guess this is caused by a faulty configured puppet module I have written.

I have a quite amazing set up that syncs my Puppet-Dashboard host variables with the host variables out of my CMDB. I then create an exported resource "icinga configuration" on the host with my puppet module that uses a few of these variables.

After that, my icinga server module instanciates each of the exported resources and creates the configuration.

As meantioned, in generally this works perfectly.

The problem starts if I introduce a new mandatory parameter to the resource definition. Then, it needs a puppet-run on each puppet node in order to recreate the host-configuration again. Before that, my icinga:server module refuses to work as the "mandatory parameter" is not available - logically correct, as the exported resources in my puppetdb are "outdated".

So, you can imagine what happens if one host is for example in a maintenance and cannot run puppet at the moment? In that case I have to wait until the server is back again and can start a puppet run in order to update the exported resource!!

Is there any smarter way so 1 "wrong" exported resource does not block all the others??

Resource:

define   icinga::client::icinga2_ppc64_linux_host($p_hosttemplate,$p_address,$p_hostname,$p_operatingsystem,$p_architecture,$p_kernel,$p_location,$p_dutyclass,$p_gpfs,$p_kernelversion,$p_network){
        file { "${name}":
                ensure          =>      present,
                content         =>      template('icinga/client/icinga2_ppc64_linux_host.erb'),
                owner           =>      'icinga',
                group           =>      'icinga',
        }
}

Resource Creation on the Node:

   'ppc64': {
                                        @@icinga::client::icinga2_ppc64_linux_host { "/etc/icinga2/zones.d/master/hosts/puppet/$::kernel/$fqdn.conf":
                                                p_hosttemplate  => 'generic-host-ppc64',
                                                p_address       => $fqdn,
                                                p_hostname      => $fqdn,
                                                p_operatingsystem => $operatingsystem,
                                                p_kernelversion => $::kernelversion,
                                                p_architecture  => $architecture,
                                                p_kernel        => $kernel,
                                                # Get Location out of CMDB_CACHE_LOCATION Parameter in Puppet-Dashboard
                                                p_location      => $::cmdb_cache_location,
                                                p_dutyclass     => $::cmdb_cache_dutyclass,
                                                p_gpfs          => $gpfs,
                                                p_network       => $::cmdb_cache_network,
                                        }

                                }

Template:

object Host "<%= @p_hostname %>" {
        import "<%= @p_hosttemplate %>"
        address = "<%= @p_address %>"

        vars.os = "<%= @p_operatingsystem %>"
        vars.kernelversion ="<%= @p_kernelversion %>"
        vars.architecture = "<%= @p_architecture %>"
        vars.kernel = "<%= @p_kernel %>"
        vars.dutyclass = "<%= @p_dutyclass %>"
        vars.location = "<%= @p_location %>"
        vars.gpfs = "<%= @p_gpfs %>"
        vars.network = "<%= @p_network %>"

  }

Collect exported resources on the icinga::server

 Icinga::Client::Icinga2_x86_64_linux_host <<||>> {
                require => [File["/etc/icinga2/zones.d/master/hosts"],File["/etc/icinga2/zones.d/master/hosts/"],File["/etc/icinga2/zones.d/master/hosts/puppet"],File["/etc/icinga2/zones.d/master/hosts/puppet/Linux"]],
                notify  => [Exec['make-icinga2-cfg-readable'],Service['icinga2']],
        }
edit retag flag offensive close merge delete

Comments

Break out of using normal collection, and revert to something like puppetdbquery to get the data, validate it first (skipping over anything invalid), and then create resources from the data yourself using the new iteration features. Standard resource collection is unforgiving, go around it.

ken gravatar imageken ( 2015-08-18 06:07:32 -0600 )edit

Alternatively, come up with a meaningful default instead of a new mandatory parameter. You've broken the API basically, so now its new API is not backwards compatible. This new default could be temporary until it's all working.

ken gravatar imageken ( 2015-08-18 06:09:28 -0600 )edit