I am trying to use variables in my modules manifest.pp with little luck

class mysoftware($version="dev-2011.02.04b") {
  File {
    links => follow
  }

  file { "/opt/mysoftware":
    ensure => directory
  }
  file { "/opt/mysoftware/share":
    source => "puppet://puppet/mysoftware/air/$version",
    recurse => "true",
  }
  }

This does not seem to be working when I assign this to a node via the nodes.pp file.

I am running puppetmaster 2.6.4 puppetd clients are 0.25

link|improve this question

71% accept rate
feedback

2 Answers

up vote 2 down vote accepted

I believe that you need to reference it like this:

source => "puppet://puppet/mysoftware/air/${version}",

Here's how I use something similar:

class aliases($al="aliases") {
    file { "/etc/aliases":
        mode  => 640,
        source => "puppet:///files/sendmail/${al}",
        owner => "root",
        group => "root",
        before  => Exec["create aliases db"]
    }

     exec { "new_aliases":
        command => "/usr/bin/newaliases",
        subscribe => File["/etc/aliases"],
        alias => "create aliases db",
        refreshonly => true,
     }
}

Which I reference from manifests/nodes.pp. I actually don't need to do it that way but set it up and tested it on your behalf (my other examples would have been much longer). Works like a charm.

link|improve this answer
feedback

Are you using 2.6 or older? Parameterized classes are new in 2.6, so if you're using an older version, this should not work.

link|improve this answer
I am using 2.6.4 puppetmaster with 0.25 puppet clients. – Joey Bagodonuts Feb 24 '11 at 22:30
Then I can only answer the question if it should work with a maybe. The puppetmaster compiles the client's catalog, which I would guess is where the feature would need to exist, but it seems like treading on thin ice. – Wil Cooley Feb 24 '11 at 22:38
Ok, I cannot figure out how to get a newline in the previous post to make a new paragraph, so I'll continue here... I would start by testing on the puppetmaster itself using the stand-alone interpreter (what prior to 2.6 was called just 'puppet', whereas the puppetmaster-client was called 'puppetd') doing something trivial, like copying /etc/hosts to /tmp or running /bin/echo. Once you get that to work, try to add it to a node and see if it works there too. If so, then you have a simple but working example and you can compare that with the one that isn't working. – Wil Cooley Feb 24 '11 at 22:43
I think the easiest thing would be to upgrade my puppet clients to a new version. Is it possible to update puppet client versions with a module? – Joey Bagodonuts Feb 24 '11 at 22:58
If you're using a Linux system with something like yum or apt-get or one of the similar tools that most other distros have, or Solaris with the Blastwave/OpenCSW with the pkg-get tool and are installing Puppet from one of them, then it should be pretty easy--just use a package resource and set the ensure attribute to either the version you want installed or latest. – Wil Cooley Feb 25 '11 at 0:00
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.