Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to write a puppet template. I have a puppet-master and a few puppet-agents and they all must be divided. I think it's good to do this by the node's hostname. But when I tried to do this I've encountered an error

"puppet-agent[169037]: (/Stage[main]//Exec[adduser]) Could not evaluate: Could not find command 'ru1'"

see code below

exec { 'adduser': 
        command => 'sudo adduser -m -p pawSfQewWrUAA test -G wheel',
        path => [ '/bin','/usr/bin' ],
        onlyif => "$hostname == ru1"
}

I need to specify this task for only one node with the hostname ru1. So have can I do this? Thanks.

share|improve this question
1  
FWIW - wouldn't it be easier to use the user type? –  thinice May 30 '12 at 13:40

2 Answers 2

Wouldn't this be quite a lot more easier and sensible?

case $hostname {
    ru1: user {
             ensure => 'present',
             name => 'test',
             gid => 'wheel',
             password => 'pawSfQewWrUAA',
             otherparametersgohere,
             }
}

Code syntax might not be perfect, since this was just out of my head, not checking the syntax or testing this in any way. But you get the idea.

share|improve this answer

Only is expecting a shell command to be executed, not a condition like what you have, which should be a case instead.

share|improve this answer
    
Yes, should working. Thank you all. Ill check it later –  Valintinr May 30 '12 at 14:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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