Correction to client "provision" command
[p5sagit/Oyster.git] / lib / Dist / Zilla / App / Command / provision.pm
CommitLineData
4aedd3bb 1use strict;
2use warnings;
3package Dist::Zilla::App::Command::provision;
4BEGIN {
5 $Dist::Zilla::App::Command::provision::VERSION = '0.1';
6}
7# ABSTRACT: release your dist to the CPAN
8use Dist::Zilla::App -command;
9use Moose;
10use Config::Any;
11
12sub abstract { 'provision a new Oyster VM' }
13
14sub opt_spec {
919b8f96 15 [ 'name=s' => 'the name of the VM to create' ],
4aedd3bb 16}
17
18sub execute {
19 my ($self, $opt, $arg) = @_;
20
21 my $zilla = $self->zilla;
22
23 my $name = $opt->name
24 or die "No name provided!";
25 my @config_files = ( './oyster.conf' ); # TODO make configurable
26
27 my $cfg = Config::Any->load_files({ files => \@config_files });
28 ($cfg) = values %{ $cfg->[0] }; # FIX with ::JFDI or similar
29
30 my $Provision = $cfg->{Provision} or die "No <Provision> section";
31 my $target = $Provision->{$name} or die "No section for <Provision> <$name>";
32
33 my $type = $target->{type} || 'EC2';
34
35 use Oyster::Provision;
36 my $server = Oyster::Provision->new(
37 name => $name,
38 size => '256',
39 image => 'Meerkat',
40 pub_ssh => "$ENV{HOME}/.ssh/id_rsa.pub",
41 provision_backend => $type,
42 );
43 $server->create;
44 print "Instance $name created! ($server)\n";
45}
46
471;
48
49__END__
50=pod
51
52=head1 NAME
53
54Dist::Zilla::App::Command::provision - provision a new Oyster VM
55
56=head1 VERSION
57
58version 0.1
59
60=head1 SYNOPSIS
61
62 TODO
63
64=head1 AUTHOR
65
66CONTRIBUTORS
67
68=head1 COPYRIGHT AND LICENSE
69
70This software is copyright (c) 2010 by CONTRIBUTORS
71
72This is free software; you can redistribute it and/or modify it under
73the same terms as the Perl 5 programming language system itself.
74
75=cut
76