Linux – puppet execute remote script on all servers

centoslinuxpuppet

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

Best Answer

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.

Related Topic