Commit | Line | Data |
e74d6d9c |
1 | package Oyster::Provision::AmazonEC2; |
2 | use Moose::Role; |
3 | use Net::Amazon::EC2; |
4 | |
5 | requires 'config'; |
6 | |
7 | my $ec2_image_id = "ami-1a837773"; |
8 | my $ec2_username = "AKIAJXSD25MPWFYTQWIQ"; |
9 | my $ec2_password = "m76s9DyoXrHdpVy8HkhjgD0RAjy14bhkQ5Zts/gg"; |
10 | |
11 | my $ec2 = Net::Amazon::EC2->new( |
12 | AWSAccessKeyId => $ec2_username, |
13 | SecretAccessKey => $ec2_password, |
14 | ); |
15 | |
16 | my $ec2_oyster_key = "OysterDefault"; |
17 | my $key_pairs = $ec2->describe_key_pairs({ KeyName => $ec2_oyster_key }); |
18 | |
19 | unless(defined($key_pairs)) { |
20 | |
21 | print("Creating $ec2_oyster_key key pair\n"); |
22 | $ec2->create_key_pair({ KeyName => $ec2_oyster_key }); |
23 | |
24 | } |
25 | |
26 | |
27 | sub create { |
28 | my $self = shift; |
29 | |
30 | $self->config(); |
31 | |
32 | |
33 | # Start 1 new instance from AMI: ami-XXXXXXXX |
34 | my $instance = $ec2->run_instances( |
35 | ImageId => $ec2_image_id, |
36 | KeyName => $ec2_oyster_key, |
37 | MinCount => 1, |
38 | MaxCount => 1, |
39 | ); |
40 | |
41 | } |
42 | |
43 | sub delete { |
44 | my $self = shift; |
45 | |
46 | $self->config(); |
47 | } |
48 | |
49 | sub resize { |
50 | my $self = shift; |
51 | |
52 | $self->config(); |
53 | } |
54 | |
55 | 1; |
56 | |
57 | __END__ |
58 | |
59 | =head1 NAME |
60 | |
61 | Oyster::Provision::AmazonEC2 -- Provision your Oyster on Amazon EC2 |
62 | |
63 | =head1 SYNOPSIS |
64 | |
65 | Use the Rackspace backend on your Oyster configuration file |
66 | |
67 | =head1 REQUIRED PARAMETERS |
68 | |
69 | The following are required to instantiate a backend: |
70 | |
71 | =over |
72 | |
73 | =item name |
74 | |
75 | The name of your new/existing rackspace server. |
76 | |
77 | =item size |
78 | |
79 | The size ID of the rackspace server you want to create. |
80 | Use the following incantation to see them: |
81 | |
82 | perl -MNet::RackSpace::CloudServers -e' |
83 | $r=Net::RackSpace::CloudServers->new( |
84 | user=>$ENV{CLOUDSERVERS_USER}, |
85 | key=>$ENV{CLOUDSERVERS_KEY}, |
86 | ); |
87 | print map |
88 | { "id $_->{id} ram $_->{ram} disk $_->{disk}\n" } |
89 | $r->get_flavor_detail |
90 | ' |
91 | id 1 ram 256 disk 10 |
92 | id 2 ram 512 disk 20 |
93 | id 3 ram 1024 disk 40 |
94 | id 4 ram 2048 disk 80 |
95 | id 5 ram 4096 disk 160 |
96 | id 6 ram 8192 disk 320 |
97 | id 7 ram 15872 disk 620 |
98 | |
99 | =item image |
100 | |
101 | The image ID of the rackspace server you want to create. |
102 | Use the following incantation to see them: |
103 | |
104 | perl -MNet::RackSpace::CloudServers -e' |
105 | $r=Net::RackSpace::CloudServers->new( |
106 | user=>$ENV{CLOUDSERVERS_USER}, |
107 | key=>$ENV{CLOUDSERVERS_KEY}, |
108 | ); |
109 | print map |
110 | { "id $_->{id} name $_->{name}\n" } |
111 | $r->get_image_detail |
112 | ' |
113 | id 29 name Windows Server 2003 R2 SP2 x86 |
114 | id 69 name Ubuntu 10.10 (maverick) |
115 | id 41 name Oracle EL JeOS Release 5 Update 3 |
116 | id 40 name Oracle EL Server Release 5 Update 4 |
117 | id 187811 name CentOS 5.4 |
118 | id 4 name Debian 5.0 (lenny) |
119 | id 10 name Ubuntu 8.04.2 LTS (hardy) |
120 | id 23 name Windows Server 2003 R2 SP2 x64 |
121 | id 24 name Windows Server 2008 SP2 x64 |
122 | id 49 name Ubuntu 10.04 LTS (lucid) |
123 | id 14362 name Ubuntu 9.10 (karmic) |
124 | id 62 name Red Hat Enterprise Linux 5.5 |
125 | id 53 name Fedora 13 |
126 | id 17 name Fedora 12 |
127 | id 71 name Fedora 14 |
128 | id 31 name Windows Server 2008 SP2 x86 |
129 | id 51 name CentOS 5.5 |
130 | id 14 name Red Hat Enterprise Linux 5.4 |
131 | id 19 name Gentoo 10.1 |
132 | id 28 name Windows Server 2008 R2 x64 |
133 | id 55 name Arch 2010.05 |
134 | |
135 | Oyster only supports Linux images, specifically |
136 | Ubuntu 10.10 (maverick). |
137 | |
138 | =item pub_ssh |
139 | |
140 | The public ssh key you would like copied to the |
141 | new server's C</root/.ssh/authorized_keys> file |
142 | to allow you to ssh in the box without providing |
143 | a root password. |
144 | |
145 | =back |
146 | |
147 | =cut |