-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nelson Silva
committed
Sep 13, 2013
0 parents
commit d7498ef
Showing
23 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.deps | ||
.vagrant | ||
aws_config.json | ||
packer_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[submodule "cookbooks/git"] | ||
path = cookbooks/git | ||
url = https://github.com/opscode-cookbooks/git.git | ||
[submodule "cookbooks/maven"] | ||
path = cookbooks/maven | ||
url = https://github.com/opscode-cookbooks/maven.git | ||
[submodule "cookbooks/java"] | ||
path = cookbooks/java | ||
url = https://github.com/opscode-cookbooks/java.git | ||
[submodule "cookbooks/ark"] | ||
path = cookbooks/ark | ||
url = https://github.com/opscode-cookbooks/ark.git | ||
[submodule "cookbooks/nodejs"] | ||
path = cookbooks/nodejs | ||
url = https://github.com/inevo/nodejs-cookbook.git | ||
[submodule "cookbooks/apt"] | ||
path = cookbooks/apt | ||
url = https://github.com/opscode-cookbooks/apt.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DEPS = .deps | ||
PACKER = $(DEPS)/packer/packer | ||
VAGRANT = /usr/bin/vagrant | ||
|
||
$(VAGRANT): | ||
@echo "Downloading vagrant" | ||
wget http://files.vagrantup.com/packages/b12c7e8814171c1295ef82416ffe51e8a168a244/vagrant_1.3.1_x86_64.deb -P $(DEPS) | ||
sudo dpkg -i $(DEPS)/vagrant_1.3.1_x86_64.deb | ||
rm $(DEPS)/vagrant_1.3.1_x86_64.deb | ||
|
||
$(PACKER): | ||
@echo "Downloading packer" | ||
wget https://dl.bintray.com/mitchellh/packer/0.3.7_linux_amd64.zip -P $(DEPS)/packer | ||
unzip -d $(DEPS)/packer $(DEPS)/packer/0.3.7_linux_amd64.zip | ||
rm $(DEPS)/packer/0.3.7_linux_amd64.zip | ||
|
||
aws: $(PACKER) | ||
$(PACKER) build -only=aws -var-file=aws_config.json bamboo_elastic.json | ||
|
||
vagrant: $(VAGRANT) | ||
$(VAGRANT) up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Bamboo Elastic Image | ||
### a Template for Packer | ||
|
||
## Quick Start | ||
|
||
* Copy `aws_config.json.sample` to `aws_config.json` and add your access/secret keys for AWS. | ||
* Run `make aws` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
|
||
config.vm.box = "raring" | ||
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box" | ||
|
||
# DRY, let's read the config from the packet config | ||
bamboo_elastic = JSON.parse(File.read("bamboo_elastic.json")) | ||
|
||
# find the chef-solo provisioner | ||
p = bamboo_elastic["provisioners"].find {|p| p["type"] == "chef-solo"} | ||
|
||
config.vm.provision :chef_solo do |chef| | ||
chef.cookbooks_path = p["cookbook_paths"] | ||
chef.json = p["json"] | ||
p["run_list"].each {|r| chef.add_recipe r} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"aws_access_key": "ACCESS_KEY", | ||
"aws_secret_key": "SECRET_KEY", | ||
"aws_region": "eu-west-1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"variables": { | ||
"aws_access_key": "", | ||
"aws_secret_key": "", | ||
"aws_region": "us-east-1", | ||
"aws_ami": "ami-e894719f" | ||
}, | ||
|
||
"builders": [ | ||
{ | ||
"name": "aws", | ||
"type": "amazon-ebs", | ||
"access_key": "{{user `aws_access_key`}}", | ||
"secret_key": "{{user `aws_secret_key`}}", | ||
"region": "{{user `aws_region`}}", | ||
"source_ami": "{{user `aws_ami`}}", | ||
"instance_type": "t1.micro", | ||
"ssh_username": "ubuntu", | ||
"ami_name": "Bamboo Elastic Image {{timestamp}}" | ||
} | ||
], | ||
|
||
"provisioners": [ | ||
{ | ||
"type": "shell", | ||
"scripts": [ | ||
"scripts/update.sh", | ||
"scripts/bamboo_agent.sh" | ||
], | ||
"execute_command": "{{ .Vars }} sudo -E sh '{{ .Path }}'" | ||
}, | ||
{ | ||
"type": "chef-solo", | ||
"cookbook_paths": ["cookbooks", "site-cookbooks"], | ||
"run_list": [ | ||
"git", | ||
"java", | ||
"maven", | ||
"nodejs", | ||
"grunt", | ||
"bower" | ||
], | ||
"json": { | ||
"java": { | ||
"install_flavor": "openjdk", | ||
"jdk_version": "7", | ||
"arch": "x86_64", | ||
"oracle": { "accept_oracle_download_terms": true} | ||
}, | ||
"maven": { | ||
"m2_home": "/opt/maven-3.0" | ||
}, | ||
"nodejs": { | ||
"install_method": "binary", | ||
"version": "0.10.18", | ||
"dir": "/opt/node-0.10", | ||
"check_sha": false | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# Enable the multiverse repos | ||
sed -i "/^# deb.*multiverse/ s/^# //" /etc/apt/sources.list | ||
|
||
apt-get update | ||
|
||
# Install the deps | ||
apt-get -y install ec2-api-tools unzip | ||
|
||
# Add the bamboo user | ||
useradd -m bamboo | ||
|
||
# Downloading agent installer to the instance | ||
imageVer=3.0 | ||
wget https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/${imageVer}/atlassian-bamboo-elastic-image-${imageVer}.zip | ||
mkdir -p /opt/bamboo-elastic-agent | ||
unzip -o atlassian-bamboo-elastic-image-${imageVer}.zip -d /opt/bamboo-elastic-agent | ||
chown -R bamboo /opt/bamboo-elastic-agent | ||
chmod -R u+r+w /opt/bamboo-elastic-agent | ||
|
||
# Instance configuration | ||
|
||
chown -R bamboo:bamboo /home/bamboo/ | ||
|
||
# Configure path variables | ||
echo "export PATH=/opt/bamboo-elastic-agent/bin:\$PATH" > /etc/profile.d/bamboo.sh | ||
|
||
# Configure automatic startup of the Bamboo agent (add before line 14 of /etc/rc.local | ||
sed -i '14 i . /opt/bamboo-elastic-agent/etc/rc.local' /etc/rc.local | ||
|
||
# Welcome screen | ||
cp /opt/bamboo-elastic-agent/etc/motd /etc/motd | ||
echo bamboo-5.0.2 >> /etc/motd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
apt-get update | ||
apt-get -y upgrade | ||
apt-get -y dist-upgrade | ||
apt-get -y autoclean | ||
|
||
# ensure the correct kernel headers are installed | ||
apt-get -y install linux-headers-$(uname -r) | ||
|
||
apt-get -y clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name "bower" | ||
|
||
depends "npm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_recipe "npm" | ||
|
||
npm_package "bower" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name "grunt" | ||
|
||
depends "npm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_recipe "npm" | ||
|
||
npm_package "grunt-cli" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name "npm" | ||
|
||
depends "nodejs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# encoding: utf-8 | ||
|
||
action :install do | ||
NPM ||= "#{node['nodejs']['dir']}/bin/npm" | ||
Chef::Log.info("Using npm from #{NPM}") | ||
pkg_id = new_resource.name | ||
pkg_id += "@#{new_resource.version}" if new_resource.version | ||
execute "install NPM package #{new_resource.name}" do | ||
command "#{NPM} -g install #{pkg_id}" | ||
not_if "#{NPM} -g ls 2> /dev/null | grep '^[├└]─[─┬] #{pkg_id}'" | ||
end | ||
end | ||
|
||
action :uninstall do | ||
NPM ||= "#{node['nodejs']['dir']}/bin/npm" | ||
pkg_id = new_resource.name | ||
pkg_id += "@#{new_resource.version}" if new_resource.version | ||
execute "uninstall NPM package #{new_resource.name}" do | ||
command "#{NPM} -g uninstall #{pkg_id}" | ||
only_if "#{NPM} -g ls 2> /dev/null | grep '^[├└]─[─┬] #{pkg_id}'" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NPM = "#{node['nodejs']['dir']}/bin/npm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
actions :install, :uninstall | ||
|
||
attribute :name, :name_attribute => true | ||
attribute :version, :default => nil | ||
|
||
def initialize(*args) | ||
super | ||
@action = :install | ||
end |