FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
documentcloud/lib/tasks/aws.rake at diffdocs · documentcloud/documentcloud · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Mar 11, 2021. It is now read-only.
documentcloud
/
documentcloud
Public archive
Notifications
You must be signed in to change notification settings
Fork
157
Star
425
Code
Issues
194
Pull requests
16
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
documentcloud
/
lib
/
tasks
/
aws.rake
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (36 loc) · 1.85 KB
Breadcrumbs
documentcloud
/
lib
/
tasks
/
aws.rake
Copy path
File metadata and controls
45 lines (36 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace
:aws
do
desc
"Launch a new unconfigured EC2 instance and configure it for documentcloud"
task
:new_instance_from_scratch
,
:instance_type
,
:needs
=>
:environment
do
|
t
,
args
|
DC
::
AWS
.
new
.
boot_instance
(
{
:type
=>
args
.
instance_type
,
:scripts
=>
[
DC
::
AWS
::
SCRIPTS
[
:scratch
]
]
}
)
end
desc
"Launch a new preconfigured EC2 instance"
task
:new_instance
,
:instance_type
,
:needs
=>
:environment
do
|
t
,
args
|
DC
::
AWS
.
new
.
boot_instance
(
{
:type
=>
args
.
instance_type
,
:scripts
=>
[
DC
::
AWS
::
SCRIPTS
[
:update
]
]
}
)
end
desc
"Snapshot EBS root and register it as a new AMI"
task
:register_ami
,
:instance_id
,
:needs
=>
:environment
do
|
t
,
args
|
require
'right_aws'
ec2
=
RightAws
::
Ec2
.
new
(
SECRETS
[
'aws_access_key'
]
,
SECRETS
[
'aws_secret_key'
]
)
instance
=
ec2
.
describe_instances
(
args
.
instance_id
)
[
0
]
if
instance
[
:aws_state
]
==
'running'
puts
"It is recommended to halt the instance before snapshotting. You have 5 seconds to ctrl-c interrupt."
sleep
5
end
image
=
ec2
.
describe_images
(
instance
[
:aws_image_id
]
)
[
0
]
volume
=
ec2
.
describe_volumes
.
select
{
|
vol
|
vol
[
:aws_instance_id
]
==
args
.
instance_id
}
.
first
new_snapshot
=
ec2
.
create_snapshot
volume
[
:aws_id
]
while
true
do
sleep
2
new_snapshot
=
ec2
.
describe_snapshots
(
new_snapshot
[
:aws_id
]
)
[
0
]
puts
"
#{
new_snapshot
[
:aws_id
]
}
status:
#{
new_snapshot
[
:aws_status
]
}
progress:
#{
new_snapshot
[
:aws_progress
]
}
"
break
if
new_snapshot
[
:aws_status
]
==
'completed'
end
puts
"ec2-register --snapshot
#{
new_snapshot
[
:aws_id
]
}
--kernel
#{
instance
[
:aws_kernel_id
]
}
--ramdisk
#{
instance
[
:aws_ramdisk_id
]
}
--description='dcloud revision of
#{
instance
[
:aws_image_id
]
}
' --name='
#{
instance
[
:aws_image_id
]
}
/
#{
new_snapshot
[
:aws_id
]
}
.manifest.xml' --architecture
#{
image
[
:aws_architecture
]
}
--root-device-name /dev/sda1"
end
end
Back
|
FazBrowse Home
|
New Git URL