Project

General

Profile

Actions

Bug #2226

closed

puppet proxy does not detect certain classes

Added by Mark Heily about 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Puppet
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

I ran the foreman-proxy importer against a large codebase of about 50 Puppet modules containing around 200 classes. About 20 classes failed to be discovered, and did not up in the list of available classes.

I added some printf logging to puppet_class.rb and determined that it was able to parse the AST but did not find whatever it was looking for. As a workaround, I added some fallback logic that will make an educated guess as to what the classname should be.

--- puppet_class.rb.ORIG    2013-02-18 18:06:54.000000000 -0500
+++ puppet_class.rb.NEW    2013-02-19 17:47:52.000000000 -0500
@@ -39,6 +39,17 @@
             klasses << new(klass.namespace, params)
           end
         end
+    #
+    # WORKAROUND: if we don't find any classes by examining the AST,
+    # assume that there is a single class that matches the filename.
+     #
+    # Example: 
+    #   
+    #   file .../modules/foo/manifests/bar.pp becomes class foo::bar
+    #
+        if klasses.empty?
+          klasses << new(filename.clone.gsub(/.*\/modules\//, '').gsub('/manifests/', '::').gsub(/.pp$/, '').gsub('::init', ''), {})
+        end
         klasses
       rescue => e
         puts "Error while parsing #{filename}: #{e}" 

See below for an example of a class that the foreman-proxy was unable to discover:

class apache2 {
  # barebones minimum of apache, just the groups and devel package
  # some boxes require just this, cassandra for example.
  realize (
    Group["bronto"],
    User["bronto"],
    Group["tomcat"],
    User["tomcat"],
    Group["apache"],
    User["apache"],
  )
  package { "httpd-devel":
    ensure  => "installed",
    alias   => "httpd-devel",
  }
}

Here are the versions I am running:

  • foreman-proxy-1.1stable-1.el5
  • puppet 2.7.11
  • CentOS 5.4
  • ruby 1.8.6 (2009-08-04 patchlevel 383) [x86_64-linux]

Related issues 1 (0 open1 closed)

Is duplicate of Smart Proxy - Bug #2067: puppet:import:puppet_classes silently ignores classes when the .pp contains an "import" statementClosedDominic Cleal12/20/2012Actions
Actions

Also available in: Atom PDF