1
votes

I've been trying to set up a development environment for my colleage's using vagrant and puppet for provisioning (Vagrant version 1.2.2, precise64 box). I'm currently stuck on downloading and importing a database.

For some context my company has daily database backups that get stored on Amazons S3 service, the dev environments should obtain the latest database backup and import it. We currently use Tim Kays aws tool to fetch the backups from S3.

I've successfully setup the aws tool using the following with puppet (and confirmed it works via 'vagrant ssh'):

file { '/usr/local/bin/aws':
  owner => 'root',
  group => 'root',
  mode  => 755,
  source  => '/puppet-files/aws',
}

file { '/home/vagrant/.awssecret':
  owner => 'vagrant',
  group => 'vagrant',
  mode  => 400,
  source => '/puppet-files/.awssecret',
}

I've tried using a modified version of a suggestion for 'wget' from a post on google groups with no luck. The following is the configuration for fetching the database.

# Get and import latest db copy
exec { "download-reduced-db" :
    cwd => "/tmp",
    command => "/usr/local/bin/aws get sqldump.example.com/2013-01-02-db-backup.sql.gz /tmp/2013-01-02-db-backup.sql.gz",
    creates => "/tmp/2013-01-02-db-backup.sql.gz",
    timeout => 3600,
    require => [File["/usr/local/bin/aws"], File["/home/vagrant/.awssecret"]],
}

The (shortened) output from 'vagrant up' is below, which indicates that it completed successfully.

notice: /Stage[main]//File[/home/vagrant/.awssecret]/ensure: defined content as '{md5}a4b7b1ac48eb207d93cb0b1541766718'
notice: /Stage[main]//File[/usr/local/bin/aws]/ensure: defined content as '{md5}92fa9a6d77c8185fdaf970e2c4eb254e'
notice: /Stage[main]//Exec[download-reduced-db]/returns: executed successfully

However when using 'vagrant ssh' and checking the /tmp/ directory the file is not listed. If I execute the command from above by hand it completes successfully and I can see the file listed in /tmp/

Thanks for your time and help.

1

1 Answers

0
votes

Try to use

puppet.options = "--verbose --debug"

as explained here http://docs.puppetlabs.com/references/latest/configuration.html

Possibly, try to run exec with the user parameter to make sure it runs as vagrant, but first check the debug output.

Also redirect stdout and stderr of your command to a file, so you can check what's going wrong. In the Bourne shell, used by default by Puppet, this is done as:

command > file.log 2>&1

Let me know how it goes.