Commit | Line | Data |
4aedd3bb |
1 | use strict; |
2 | use warnings; |
3 | package Dist::Zilla::App::Command::provision; |
4 | BEGIN { |
5 | $Dist::Zilla::App::Command::provision::VERSION = '0.1'; |
6 | } |
7 | # ABSTRACT: release your dist to the CPAN |
8 | use Dist::Zilla::App -command; |
9 | use Moose; |
10 | use Config::Any; |
11 | |
12 | sub abstract { 'provision a new Oyster VM' } |
13 | |
14 | sub opt_spec { |
15 | [ 'name|s' => 'the name of the VM to create' ], |
16 | } |
17 | |
18 | sub 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 | |
47 | 1; |
48 | |
49 | __END__ |
50 | =pod |
51 | |
52 | =head1 NAME |
53 | |
54 | Dist::Zilla::App::Command::provision - provision a new Oyster VM |
55 | |
56 | =head1 VERSION |
57 | |
58 | version 0.1 |
59 | |
60 | =head1 SYNOPSIS |
61 | |
62 | TODO |
63 | |
64 | =head1 AUTHOR |
65 | |
66 | CONTRIBUTORS |
67 | |
68 | =head1 COPYRIGHT AND LICENSE |
69 | |
70 | This software is copyright (c) 2010 by CONTRIBUTORS |
71 | |
72 | This is free software; you can redistribute it and/or modify it under |
73 | the same terms as the Perl 5 programming language system itself. |
74 | |
75 | =cut |
76 | |