Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
viglesiasce committed Aug 15, 2014
0 parents commit 3f5cac6
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
driver:
name: vagrant

provisioner:
name: chef_solo

platforms:
- name: centos-6.5
driver_config:
box: chef/centos-6.5
network:
- [public_network, bridge: 'en0: Wi-Fi (AirPort)']
customize:
cpus: 2
memory: 3024
cpuexecutioncap: 100

suites:
- name: deployer
run_list:
- recipe[deployer]
2 changes: 2 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'https://api.berkshelf.com'
metadata
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default['deployer']['chef-server'] = 'https://10.111.4.101'
10 changes: 10 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name 'deployer'
maintainer 'Eucalyptus Systems'
maintainer_email '[email protected]'
license 'Apache 2'
description 'Installs/Configures Deployer jenkins instance'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'python'
depends 'rbenv'
depends 'ntp'
11 changes: 11 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Cookbook Name:: cookbooks/micro-qa
# Recipe:: default
#
# Copyright 2014, Eucalyptus Systems
#
# All rights reserved - Do Not Redistribute
#

include_recipe "deployer::deploy"
include_recipe "deployer::eutester"
49 changes: 49 additions & 0 deletions recipes/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Cookbook Name:: cookbooks/deployer
# Recipe:: deploy
#
# Copyright 2014, Eucalyptus Systems
#
# All rights reserved - Do Not Redistribute
#
include_recipe "python"

directory "/root/.chef"

template "/root/.chef/knife.rb" do
source "knife.erb"
end

package "git"

if platform?("redhat", "centos", "fedora")
package "libxml2-devel"
package "libxslt-devel"
elsif platform?("ubuntu", "debian")
package "libxml2-dev"
package "libxslt1-dev"
end

include_recipe "rbenv"
include_recipe "rbenv::ruby_build"

mb_ruby_version = "2.1.2"

rbenv_ruby mb_ruby_version do
global true
not_if "ls /opt/rbenv/versions/#{mb_ruby_version}"
end

rbenv_execute "gem install motherbrain" do
ruby_version mb_ruby_version
timeout 1200
not_if "ls /opt/rbenv/versions/#{mb_ruby_version}/bin/mb"
end

directory "/root/.mb"

template "/root/.mb/config.json" do
source "motherbrain.erb"
end

python_pip "paramiko"
45 changes: 45 additions & 0 deletions recipes/eutester.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Cookbook Name:: cookbooks/micro-qa
# Recipe:: eutester
#
# Copyright 2014, Eucalyptus Systems
#
# All rights reserved - Do Not Redistribute
#
include_recipe "ntp"

pip_options = ""
if platform?("redhat", "centos", "fedora")
# code for only redhat family systems.
%w{python-devel python-setuptools gcc make git unzip ant}.each do |package_name|
package package_name
end
pip_options = "--pre"
elsif platform?("ubuntu", "debian")
# code for debian
%w{python-setuptools gcc python-dev git python-virtualenv
git unzip ant}.each do |package_name|
package package_name
end
end

directory "/vagrant/jenkins/share" do
only_if "ls /vagrant"
end

execute "easy_install pip"
python_pip "virtualenv"

python_virtualenv "/vagrant/jenkins/share/eutester-base" do
owner "root"
group "root"
action :create
only_if "ls /vagrant"
end

python_pip "eutester" do
virtualenv "/vagrant/jenkins/share/eutester-base"
only_if "ls /vagrant"
options pip_options
end

8 changes: 8 additions & 0 deletions templates/default/knife.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
log_level :info
log_location STDOUT
node_name 'admin'
client_key '/etc/chef-server/admin.pem'
validation_client_name 'chef-validator'
validation_key '/etc/chef-server/chef-validator.pem'
chef_server_url '<%= node['deployer']['chef-server'] %>'
cookbook_path '/root/cookbooks'
55 changes: 55 additions & 0 deletions templates/default/motherbrain.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"berkshelf": {
"path": "~/.berkshelf"
},
"chef": {
"api_url": "<%= node['deployer']['chef-server-url'] %>",
"api_client": "admin",
"api_key": "/etc/chef-server/admin.pem",
"validator_client": "chef-validator",
"validator_path": "/etc/chef-server/chef-validator.pem",
"bootstrap_proxy": null,
"encrypted_data_bag_secret_path": null
},
"ssh": {
"user": "root",
"password": "foobar",
"keys": ["/root/.ssh/id_rsa"],
"sudo": false,
"timeout": 10.0,
"verbose": null
},
"winrm": {
"user": null,
"password": null,
"port": 5985
},
"ssl": {
"verify": false
},
"log": {
"level": "INFO",
"location": "STDOUT"
},
"server": {
"daemonize": false,
"pid": "/var/run/motherbrain/mb.pid"
},
"rest_gateway": {
"enable": false,
"host": "0.0.0.0",
"port": 0
},
"plugin_manager": {
"eager_loading": false,
"eager_load_interval": 300,
"async_loading": false
},
"ef": {
"api_url": null,
"api_key": null
},
"bootstrap": {
"default_template": null
}
}
20 changes: 20 additions & 0 deletions test/integration/deployer/serverspec/deployer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'serverspec'

include Serverspec::Helper::Exec
include Serverspec::Helper::DetectOS

RSpec.configure do |c|
c.before :all do
c.path = '/sbin:/usr/sbin'
end
end

describe "Deployer" do
describe command('ruby -v') do
it { should match /2.1.2/ }
end

describe command('mb version') do
it { should return_exit_status 0 }
end
end

0 comments on commit 3f5cac6

Please sign in to comment.