tags:

views:

52

answers:

4

I have a PHP script that I keep updated and need to run on several servers to gather data based on config files like php ini, phpinfo, and other config files. I need to make sure that what's run is always the latest version of the script but this creates an annoying maintenance problem because the script is always being updated.

So I'd like to store the PHP script in another central location and have a generic script that never changes on the server of interest. The generic PHP script sends data to the central script and gets feedback without me having to visit the server to change the code to the new script. How can this be done? Is this an API? and what's the best way to do it? I'm using PHP

If I'm not explaining the problem clearly, please ask me if there's something that's not clear.

+2  A: 

Sounds like you need a configuration management tool such as Puppet or cfengine.

Ignacio Vazquez-Abrams
+2  A: 

You can mount an NFS share for that. Or if you want higher performance iSCSI over GigE will fit the bill. But realistically rsync will probably do you well.

Novikov
+3  A: 

You can deploy a php file that will check with the central server if there is a new version of the script, if so download, run it and keep that version along with a version tag.

Next time, check for new version, if version is the same, just run the local script. Else, repeat first step.

With this approach you can also get some extra benefits, like the ability to setup custom process depending on the machine running the process or get reports sent back to the central server, etc.

xmarcos
+2  A: 

scheduledtask.sh:

svn update DataGatherer.php
php DataGatherer.php
Michael Kopinsky
If you've not got a VCS accessible from the server, then it would also be feasible to run a script to scp the probe into the server, remote execute it and pull back the output - you certainly don't want to be able to deploy PHP code via HTTP!
symcbean
Based on what the OP described with versioning, I would strongly recommend a VCS. That said, scp/ssh is also a great solution. You can set permissions on the script to 700 to avoid any security issues.
Michael Kopinsky