Tomas Jansson
Tomas Jansson

Reputation: 23472

How do I "require" an external module in puppet?

To install a module on a node you run somethig like: puppet module install SomeModuleOnForge

Is there a way to put that piece of code in the manifest instead of having to install it on every single node?

I know I could write some custom code to do it but doesn't it exist something like require that works for external modules? Or do I have to download the code for the module and put it in my own repo?

To make it more concrete. I'm doing this on windows and what to use Josh Cooper powershell module, but I can't get it to work. My folder structure look like this:

I think that's the most important files. The rest from the module is there as well, but I shouldn't need them if I understand the code correctly.

My simple stupid site.pp looks like this:

include powershell
node default {
    notify {"Stuff from default":}
}

node 'MYCOMPUTER' {
    notify {"MYCOMPUTER":}
}

node 'winpuppet' {
    notify {"Notify from random":}
}

exec {'get_eventstore':
    command => 'Invoke-WebRequest http://download.geteventstore.com/binaries/EventStore-OSS-Win-v3.0.0-rc9.zip -OutFile c:\\downloads\\EventStore-OSS-Win-v3.0.0-rc9.zip',
    creates => "c:/downloads/EventStore-OSS-Win-v3.0.0-rc9.zip",
    provider => powershell,
}

file {'c:/downloads/EventStore-OSS-Win-v3.0.0-rc9.zip':
    mode => 0755,
    require => Exec["get_eventstore"],
}

notify {"I'm notifying you.":}

This is only supposed to copy a file, nothing serious since I'm still learning.

Upvotes: 0

Views: 2081

Answers (2)

Felix Frank
Felix Frank

Reputation: 8223

Yes, managing modules from within Puppet is possible.

You need to bundle the "puppet_module" module with your manifests (preferably through source control). You can then write manifests such as

module {
    'joshcooper/powershell':
        ensure => 'present'
}

It might even be possible to sync exec resources in the same run that fetched the module. Make sure that those execs require the module, so that the powershell provider can become available in time.

Upvotes: 2

daxlerod
daxlerod

Reputation: 1166

You already have a git repository of your modules, so you can just check out that repository on each of your nodes.

Puppet modules don't require any installation other than copying their contents into your module directory.

The puppet module install foo does some checking to identify the appropriate version to meet the requirements of other installed modules, and installs required by the module you are installing, but otherwise just downloads the data and copies it to your module directory.

Upvotes: 1

Related Questions