简体   繁体   中英

Puppet: Multiple manifests in module

I am trying to create Puppet module to setup my web server.

What i want - is to split configuration to logical modules (manifests by services: webserver , database , ftp etc.) But I can not figure out how to use additional manifests in init.pp

I am going to use it only with puppet apply not server-client configuration.

My text module manifest (kp/manifests/init.pp):

class kp {
    include kp::testfile
}

include kp

And additional manifest (kp/manifests/testfile.pp)

define kp::testfile {

    $value = template("kp/some.erb")

    file { 'testfile':
        path    => '/tmp/my.txt',
        ensure  => file,
        content => $value
    }
}

Documentation says:

If a class is defined in a module, you can declare that class by name in any manifest. Puppet will automatically find and load the manifest that contains the class definition.

But when I run puppet apply init.pp I am getting error message

Could not find class kp::testfile for myhost.com at /myDir/puppetModules/kp/manifests/init.pp:2 on node vagrant.example.com

Facts

  • /myDir/puppetModules/ is in modulepath so no problems here
  • Puppet version v2.7.11
  • Ubuntu 12.04 LTS

What I am doing wrong? Thanks in advance!

Your kp::testfile is a defined type, not a class. To use a defined type you need to declare it like:

kp::testfile { 'name': }

Try redefining kp::testfile like

class kp::testfile {

    $value = template("kp/some.erb")

    file { 'testfile':
        path    => '/tmp/my.txt',
        ensure  => file,
        content => $value
    }
}

and you may have better luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM