On Tue, Jul 6, 2010 at 12:42 AM, christopher floess <skepti...@gmail.com> wrote: > Hi, quick question: > > I have been following the thread: "Splitting classes into separate files" > and decided to to some refactoring based on that. I have the following file > structure for a module
Great, thanks for taking the time to do this. I have a few suggestions I'll include in-line with the quoted reply. Before diving in, please keep in mind the difference between import and include. import loads a manifest and parses it, include adds a class to the catalog. The "goal" is to structure the manifests so include foo::bar automatically imports the right file without us having to manually specify an import statement. > modules/packages/manifests/init.pp > modules/packages/manifests/classes/redis.pp I recommend against the use of a "classes" directory component. Puppet and the autoloader will expect this to be a namespace underneath the module namespace, which probably isn't what you want. For the autoloader to automatically import redis.pp above, you would have to make the statement: include packages::classes::redis "classes" is redundant since the include function only operates on classes. > ~/puppet_config$ cat modules/packages/manifests/init.pp > import "redis" init.pp should contain a single class named exactly after the module name. In your structure, init.pp should contain "class packages {}" Also, if you have import statements, it should signal something isn't in the place puppet expects it to be. > ~/puppet_config$ cat modules/packages/manifests/classes/redis.pp I believe the ideal location for redis.pp is modules/packages/manifests/redis.pp (not in classes) and the autoloader will automatically load this file if you name the class packages::redis instead of just "redis" If you'd like to keep the classes directory component, then you could rename the class packages::classes::redis and puppet will autoload modules/packages/manifests/classes/redis.pp to look for the class. > class redis { > file { > "/home/adva/builds/redis_1.02-1_i386.deb": > ensure => present, > source => "puppet:///redis/redis_1.02-1_i386.deb"; > } > > file { > "/etc/redis.conf": > ensure => present; > } > > package { > "redis": > require => File["/home/adva/builds/redis_1.02-1_i386.deb"], > source => "/home/adva/builds/redis_1.02-1_i386.deb", > ensure => installed, > provider => dpkg; > } > } > > then in manifests/modules.pp I have > > ~/puppet_config$ cat manifests/modules.pp > # /etc/puppet/manifests/modules.pp > > import "base_packages" > import "base_configs" > import "users" > import "sphinx" > import "gems" > import "ree" > import "nginx" > import "puppet_client" > import "packages" You shouldn't need this file at all. The expectation is that when you include a class into the catalog, puppet should automatically locate the manifest containing the class and import it for you. > puppet-ad...@servercharlie:~/puppet_config$ > > and in manifests/nodes.pp, I have > <--- snip ---> > node 'ext-b2c-sk-test' inherits default { > include b2c_test > include sk_base > include gems_sk_all > include gems_b2c_base > include ree > include packages::redis > include nginx > include sphinx > adva_users{"application": username => "application",} > } > <--- snip ---> I notice you have include packages::redis. If you move redis.pp to modules/packages/manifests/redis.pp and in the file declare the class like: class packages::redis { } rather than just class redis { } > I'm getting the error: Could not retrieve catalog from remote server: Error > 400 on SERVER: Could not parse for environment production: No file(s) found > for import of 'redis' at > /home/puppet-admin/puppet_config/modules/packages/manifests/init.pp:2 This error is a result of the import redis you have. You really don't need any import statements. > So my question is, how do I change things in the 4 files above so that this > runs properly. > > Because of the auto-load stuff mentioned in Module standards, I've also > tried changing 'include packages::redis" to 'include redis', but that didn't > work either. Puppet will import the right files if you move redis.pp into the manifests directory and name the class inside packages::redis. What puppet is doing is relatively straight forward when you say "include packages::redis" 1: import packages/manifests/init.pp 2: If no class named packages::redis results, then import packages/manifests/redis.pp if it exists. 3: If no class named packages::redis results, throw an error. Hope this helps, -- Jeff McCune http://www.puppetlabs.com/ -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.