Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Created March 30, 2014 13:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winebarrel/9872697 to your computer and use it in GitHub Desktop.
Save winebarrel/9872697 to your computer and use it in GitHub Desktop.
Drone on AWS
Parameters do
ImageId do
Type "String"
# http://cloud-images.ubuntu.com/precise/current/
# ap-northeast-1; 64-bit; ebs
Default "ami-1f334f1e"
end
InstanceType do
Type "String"
Default "t1.micro"
end
KeyName do
Type "String"
end
VpcId do
Type "String"
end
SubnetId do
Type "String"
end
end
Resources do
DroneInstance do
Type "AWS::EC2::Instance"
Properties do
ImageId { Ref "ImageId" }
InstanceType { Ref "InstanceType" }
KeyName { Ref "KeyName" }
NetworkInterfaces [
_{
DeviceIndex 0
SubnetId { Ref "SubnetId" }
AssociatePublicIpAddress true
GroupSet [
_{ Ref "DroneSecurityGroup" }
]
}
]
Tags [
_{
Key "Name"
Value "drone #{Time.now}"
}
]
end # Properties
end
DroneSecurityGroup do
Type "AWS::EC2::SecurityGroup"
Properties do
GroupDescription "drone"
VpcId { Ref "VpcId" }
SecurityGroupIngress [
_{
IpProtocol "tcp"
FromPort 80
ToPort 80
CidrIp "0.0.0.0/0"
},
_{
IpProtocol "tcp"
FromPort 22
ToPort 22
CidrIp "0.0.0.0/0"
}
]
end
end
end
Outputs do
DronePublicIp do
Value {
Fn__GetAtt "DroneInstance", "PublicIp"
}
end
end
_post do
install_drone do
ssh do
host { Key "DronePublicIp" }
user "ubuntu"
connect_tries 90
retry_interval 10
end
command <<-EOS
sudo apt-get -y update
sudo apt-get -y install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo reboot
EOS
end
#wait do
# command "sleep 10"
#end
install_drone2 do
ssh do
host { Key "DronePublicIp" }
user "ubuntu"
connect_tries 90
retry_interval 10
end
command <<-EOS
curl -s https://get.docker.io/ubuntu/ | sudo sh
echo 'DOCKER_OPTS="-H tcp://0.0.0.0:4243"' | sudo sh -c 'cat >> /etc/default/docker' < /dev/stdin
wget http://downloads.drone.io/latest/drone.deb
sudo dpkg -i drone.deb
sudo start drone; true
EOS
end
echo_url do
command 'echo http://<%= Key "DronePublicIp" %>/install'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment