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

how can i execute a python script on all puppet clients.

i have added a class for the script to be executed

class curp {
       exec { "/usr/src/scripts/curp.py": }
}

and included it in nodes.pp

but when i execute on the remote client, it says file cannot be found ???

#client:# /usr/sbin/puppetd --test --server=puppetmasterserver
notice: //chkconfig/Package[vsftpd]/ensure: created
err: //curp/Exec[/usr/src/scripts/curp.py]/returns: change from notrun to 0 failed: Could not `find executable /usr/src/scripts/curp.py`

more edition:

i have fixed the configissue by creating a fileserver,

class curp {
       file { '/opt/files/curp.py':
          ensure => present,
          owner => 'root',
          group => 'root',
          mode => '0755',
          source => 'puppet:///modules/files/curp.py',
       }
       exec { '/opt/files/curp.py': require => File['/opt/files/curp.py'] }

}

but the script fails with a dependency, i cant find anywhere else in the log to what it is related to...

err: //curp/File[/opt/files/curp.py]: Failed to retrieve current state of resource: Could not retrieve information from source(s) puppet:///modules/files/curp.py at /etc/puppet/manifests/templates.pp:114
notice: //curp/Exec[/opt/files/curp.py]: Dependency file[/opt/files/curp.py] has 1 failures
warning: //curp/Exec[/opt/files/curp.py]: Skipping because of failed dependencies

Any ideas?

resolved:

problem was /opt/files did not exist on the client servers, it works when the remote directory is available

share|improve this question
    
So what does ls -l /usr/src/scripts/curp.py say? –  womble Aug 23 '11 at 10:50
    
This is actually what mcollective is for. –  pfo Aug 23 '11 at 11:12
    
You have forget the coma after two lines : source => "puppet:///modules/curp/curp.py" }, exec { "/usr/src/scripts/curp.py": }, –  Razique Aug 23 '11 at 11:30
    
source => 'puppet:///puppet/files/curp.py', --> what does your puppet directory structure look like? –  quanta Aug 23 '11 at 12:44
    
the curp.py file is located in /etc/puppet/modules/files/curp.py –  krisdigitx Aug 23 '11 at 13:15

3 Answers 3

up vote 2 down vote accepted

The error:

Failed to retrieve current state of resource: Could not retrieve information from source(s)

means that puppet could not retrieve the file from the puppetmaster. The second error is because it won't attempt to execute the file if it can't retrieve the file.

I think you'll find this page useful as you learn puppet: http://bitcube.co.uk/content/puppet-errors-explained The error you are hitting here is the top one on that page. It also has some more information about where puppet expects files to be. The URLs don't necessarily match up directly with the file system paths.

In general, when debugging error messages, fix the first one first. It's quite common for later error messages to be caused by earlier ones.

share|improve this answer
    
the curp.py file is located in /etc/puppet/modules/files/curp.py –  krisdigitx Aug 23 '11 at 13:15
    
The URL you have in your error message: puppet:///modules/files/curp.py will be trying to find the file in /etc/puppet/modules/modules/files/files/curp.py on the puppetmaster. If the file is in a module called "curp" the URL you want is puppet:///curp/curp.py –  Ladadadada Aug 23 '11 at 13:23
    
thanks man.. worked.. –  krisdigitx Aug 23 '11 at 14:38

You should use the recommended directory structure, something like this:

|-- environments
|   |-- development
|   |   `-- modules
|   `-- testing
|       `-- modules
|-- manifests
|   |-- defines
|   |   `-- netinstall.pp
|   |-- nodes.pp
|   `-- site.pp
|-- modules
|   |-- python
|   |   |-- files
|   |   |-- manifests
|   |   `-- templates

put your class into modules/python/manifests, the curp.py into modules/python/files, and use source like belows:

source => 'puppet:///modules/python/curp.py',
share|improve this answer

you have to add a file statement :

file { "curp": name => "/usr/src/scripts/curp.py", ensure => file, source => "puppet:///modules/your_module/curp.py" }

and

class curp { exec { "/usr/src/scripts/curp.py": } require => {File["curp"]}, }

It means the statement File will send the file to all puppet nodes which use that module.

share|improve this answer
    
You don't need a file statement if the script's already on the system, and you really don't need an explicit require, because Puppet will autorequire if needed. –  womble Aug 23 '11 at 10:57
    
Good to know, thanks. I've always thought that I should use the "require", so I make sure that the function is being run without error. –  Razique Aug 23 '11 at 10:59

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.