1

My puppet file looks like this:

# Test finger harry harry.pp
exec {'harryd':                                                                                                                   
   command => "/usr/bin/finger $title",                                                                                            
   logoutput => true                                                                                                               
 }

When I run puppet apply harry.pp I get this output:

notice: /Stage[main]//Exec[harryd]/returns: finger: main: no such user.
notice: /Stage[main]//Exec[harryd]/returns: executed successfully
notice: Finished catalog run in 0.14 seconds

Running finger harryd gets me the expected output. It looks like puppet is running finger main, but I don't understand why.

Son of the Wai-Pan
  • 757
  • 4
  • 11
  • 25

1 Answers1

3

$title is only specially set to the title of the resource within the scope of a defined type, which exec is not.

So if you had..

define finger {
  exec { 'finger-$title':                                                                                                             
    command   => "/usr/bin/finger $title",                                                                                            
    logoutput => true                                                                                                               
  }
}

finger { "harryd": }

..then that would work as intended, since within the scope of the defined type, $title is set to the title of the defined type.

Can you clarify what you're trying to achieve?

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • I was just trying to work through some of the documentation and was experimenting to see if I understood how puppet worked. In the broader scope, I'd like to `finger` (or some other command) a number of strings. In the above case, is finger { ['a','b','c']:} sufficient to finger a,b, and c? This is actually what I'm trying to accomplish. Also, what's the point of title in my original example? Why does it have main in it? Thanks @Shane Madden. – Son of the Wai-Pan May 30 '13 at 01:39
  • `is finger { ['a','b','c']:} sufficient to finger a,b, and c?` Yes, it will declare the defined type for each element in the array, resulting in three different `exec` resources. `Also, what's the point of title in my original example? Why does it have main in it?` There's no reason to use `$title` outside of a defined type - that's where it's special, otherwise you might be using it as a normal variable. If I had to guess, the "main" in that variable is probably from the default run stage, `Stage['main']`. – Shane Madden May 30 '13 at 02:13