We have a similar configuration (although we're working with Tomcat and Grails instead of nginx and RoR). We've set up individual userids for each instance of Tomcat. We set the home directories for Java, Grails and any other dependent libraries in the .profile for the user as environment variables, so each Tomcat can run with any version that we've got installed.
The userid user by our automated deployment software (Atlassian Bamboo) is a member of the group assigned to each of the Tomcat directories.
Have a look at the .sql script that the deploy is creating. It should contain something like
IF (DB_ID(N'$(DatabaseName)') IS NOT NULL)
BEGIN
DECLARE @rc int, -- return code
@fn nvarchar(4000), -- file name for back up
@dir nvarchar(4000) -- backup directory
EXEC @rc = [master].[dbo].[xp_instance_regread] N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', @dir output, 'no_output'
if (@rc = 0) SELECT @dir = @dir + N'\'
IF (@dir IS NULL)
BEGIN
EXEC @rc = [master].[dbo].[xp_instance_regread] N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', @dir output, 'no_output'
if (@rc = 0) SELECT @dir = @dir + N'\'
END
IF (@dir IS NULL)
BEGIN
EXEC @rc = [master].[dbo].[xp_instance_regread] N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\Setup', N'SQLDataRoot', @dir output, 'no_output'
if (@rc = 0) SELECT @dir = @dir + N'\Backup\'
END
IF (@dir IS NULL)
BEGIN
SELECT @dir = N'$(DefaultDataPath)'
END
SELECT @fn = @dir + N'$(DatabaseName)' + N'-' +
CONVERT(nchar(8), GETDATE(), 112) + N'-' +
RIGHT(N'0' + RTRIM(CONVERT(nchar(2), DATEPART(hh, GETDATE()))), 2) +
RIGHT(N'0' + RTRIM(CONVERT(nchar(2), DATEPART(mi, getdate()))), 2) +
RIGHT(N'0' + RTRIM(CONVERT(nchar(2), DATEPART(ss, getdate()))), 2) +
N'.bak'
BACKUP DATABASE [$(DatabaseName)] TO DISK = @fn
END
GO
As you can see above, the destination for the backups is determined by the registry values which store the default backup location for the target SQL Server.
Best Answer
Puppet sounds perfect for what you're trying to do, with the caveat that as of right now, there is no support for Windows.
In your case, you would define a Server node in terms of all of the packages that are identical across the machines. Then, you define the individual hosts as nodes which inherit from Server, and set up the specific unique things for it.
Puppet is declarative - it allows you to describe of your boxes in terms of the resources each box should have. So if you want
ssh
- you write a class for that resource - and inside the class you can include logic about how ssh is called slightly different on FreeBSD vs Ubuntu. It also knows to useyum
inside Redhat andapt-get
inside Debian based distros, andports
in the BSDs. Now in your Server node, you'll just have a line likeinclude ssh
- and puppet will do the right thing and put SSH on the machine without you having to remember if that's Ubuntu or Redhat or FreeBSD.What's nice is that all of the Server stuff lives in one place - and if at any point you add to the Server node definition, ALL machines would update their configuration accordingly.
Right now, I'm only managing three boxes using Puppet - but it's already paid off. After spending a week setting up a box we'll be using for stimulus presentation in an experiment, it turned out the graphics card driver was too old in the version of Ubuntu I put on it (8.04). I had to install the latest Ubuntu (9.04), but after that I just had to apt-get and run puppet - and everything I had spent a week setting up was restored.
Puppet does have a little bit of a learning curve, but I've successfully avoided learning Ruby - I know I'm using it, since that's what puppet is written in - but so far I've been successful in just modifying the examples in the documentation and the recipes on the wiki . Another downside is that puppet does take a bit longer to do things the first time. The upside is that everything you change across all of your machines is stored in one place - it's standard practice to keep your puppet configuration in a version control system - so you can always look back and see how you've set up servers in the past - or roll-back some unsuccessful changes.
Finally, here's a quick video that does a simple puppet demo that got me started quickly.