Permalink
Browse files

Merge branch 'master' of p5sagit@git.shadowcat.co.uk:Oyster

  • Loading branch information...
2 parents 680e49c + 24bf65b commit 6c983a4a9ffd4e9b2890c91f43b5e9c8c087704b Paul Tipper committed Nov 20, 2010
Showing with 32 additions and 11 deletions.
  1. +13 −8 lib/Dist/Zilla/App/Command/provision.pm
  2. +5 −3 lib/Oyster/Provision/Rackspace.pm
  3. +13 −0 oyster.conf
  4. +1 −0 share/deploy/git/post-receive
@@ -8,6 +8,7 @@ BEGIN {
use Dist::Zilla::App -command;
use Moose;
use Config::Any;
+use Hash::Merge 'merge';
sub abstract { 'provision a new Oyster VM' }
@@ -24,21 +25,25 @@ sub execute {
or die "No name provided!";
my @config_files = ( './oyster.conf' ); # TODO make configurable
- my $cfg = Config::Any->load_files({ files => \@config_files });
+ my $cfg = Config::Any->load_files({ files => \@config_files, use_ext => 0 });
($cfg) = values %{ $cfg->[0] }; # FIX with ::JFDI or similar
my $Provision = $cfg->{Provision} or die "No <Provision> section";
- my $target = $Provision->{$name} or die "No section for <Provision> <$name>";
- my $type = $target->{type} || 'Rackspace';
+ my @hashes = grep $_, $Provision->{Default}, $Provision->{$name}
+ or die "No section for <Provision> <$name>, and no <default>";
+
+ my %hash = @hashes > 1 ? %{ merge( @hashes ) } : $hashes[0];
+
+ $hash{provision_backend} = delete $hash{type} || 'Rackspace';
+ $hash{pub_ssh} ||= "$ENV{HOME}/.ssh/id_rsa.pub";
+ $hash{size} ||= 1; # id 1 - ram 256 MiB - disk 10 GiB
+ $hash{image} ||= 69; # id 69 - Ubuntu 10.10 (meerkat)
use Oyster::Provision;
my $server = Oyster::Provision->new(
- name => $name,
- size => 1, # id 1 - ram 256 MiB - disk 10 GiB
- image => 69, # id 69 - Ubuntu 10.10 (meerkat)
- pub_ssh => "$ENV{HOME}/.ssh/id_rsa.pub",
- provision_backend => $type,
+ name => $name,
+ %hash,
);
$server->create;
print "Instance $name created! ($server)\n";
@@ -7,15 +7,17 @@ use MIME::Base64;
requires 'config';
-has 'api_username' => ( is => 'ro', isa => 'Str', required => 1, default => sub {
+has 'api_username' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1);
+sub _build_api_username {
return $ENV{CLOUDSERVERS_USER} if exists $ENV{CLOUDSERVERS_USER};
confess "Need api_username or CLOUDSERVERS_USER in environment";
});
-has 'api_password' => ( is => 'ro', isa => 'Str', required => 1, default => sub {
+has 'api_password' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1);
+sub _build_api_password {
return $ENV{CLOUDSERVERS_KEY} if exists $ENV{CLOUDSERVERS_KEY};
confess "Need api_password or CLOUDSERVERS_KEY in environment";
-});
+}
has '_rs' => ( is => 'rw', isa => 'Net::RackSpace::CloudServers', default => sub {
my $self = shift;
View
@@ -1,7 +1,20 @@
<Provision>
+ <default>
+ type Rackspace
+ username foo
+ password baz
+ size 256
+ </default>
+
<test>
type Rackspace
username foo
password baz
</test>
+ <live>
+ type Rackspace
+ username foo
+ password baz
+ size 512
+ </live>
</Provision>
@@ -2,3 +2,4 @@
cd ..
env -i git reset --hard HEAD
+dzil listdeps | xargs cpanm --local-lib=~/perl5

0 comments on commit 6c983a4

Please sign in to comment.