Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Barclamp for "Chef Ready" role so we can extend the target state. #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ All the exciting stuff is happening in chef-provisioning-crowbar/cookbooks/app/r
/$HOME/build_and_test_chef-provisioning-crowbar.sh

```bash
# source the chef-dk env
source the chef-dk env
. $HOME/.bash_profile
CPC_REPO_PATH=<path to chef-provisioning-crowbar git repo>
cd ${CPC_REPO_PATH}
Expand All @@ -134,3 +134,12 @@ cd ${CPC_REPO_PATH}/cookbooks/app/recipes/
# or omit -z to use a chef server indicated elsewhere
chef-client ./crowbar_test.rb
```
## Chef Ready Barclamp

This workload also installs a small Crowbar barclamp for Chef Integrations.

At this time, the only purpose of the Chef Integration is
1) provide the target "chef-ready" milestone so that roles can be added before the Chef Provisioning target that are unique to the Chef Provisioning driver
2) to install a SSL Certificate in /etc/chef/trusted_certs so that the Chef Server (assumed to be the Crowbar installed Chef at 192.168.124.10 which is currently hard coded).

To install the SSL Certificate, you must export the certificate manually and copy the file to `/tftpboot/files/chef/192.168.124.10.crt` and it will be automatically copied to the nodes during bring up.
8 changes: 4 additions & 4 deletions cookbooks/app/recipes/crowbar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
require 'chef/provisioning'
with_driver 'crowbar'

with_chef_server 'https://192.168.124.10',
:client_name => 'metal',
:signing_key_filename => '/etc/chef/client.pem'

with_chef_server 'https://192.168.124.10:443',
:client_name => 'rack1',
:signing_key_filename => '/home/rob/.chef/client.pem'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to $ENV{"HOME"} or appropriate rubyism, please.

# Crowbar these days is defaulting to installing Centos-7.0
# on its slave nodes.
#
Expand Down
45 changes: 45 additions & 0 deletions crowbar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2015, RacKN by Rob Hirschfeld
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

barclamp:
name: chef_integration
display: "Chef Integration"
license: "apache2"
copyright: "RackN - Rob Hirschfeld 2015"
os_support:
- centos-6.5
- redhat-6.5
- centos-7.0
- redhat-7.0
- ubuntu-12.04

roles:
- name: chef-ready
description: "Chef Provisioned"
jig: noop
flags:
- milestone
- implicit
requires:
- chef-provisioning
- name: chef-provisioning
description: "prepare node for Chef Server"
jig: script
requires:
- crowbar-installed-node
flags:
- implicit
wants-attribs:
- provisioner-webserver
7 changes: 7 additions & 0 deletions crowbar_engine/barclamp_chef_integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
17 changes: 17 additions & 0 deletions crowbar_engine/barclamp_chef_integration/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
source "https://rubygems.org"

# Declare your gem's dependencies in barclamp_burnin.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# jquery-rails is used by the dummy application
# gem "jquery-rails"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use debugger
# gem 'debugger'
40 changes: 40 additions & 0 deletions crowbar_engine/barclamp_chef_integration/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'BarclampChefIntegration'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'



Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end


task :default => :test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2015, RacKN by Rob Hirschfeld
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module BarclampChefIntegration
class ApplicationController < ActionController::Base
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2015, RackN, Rob Hirschfeld
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

class BarclampChefIntegration::BarclampsController < BarclampsController
def initialize
@service_object = ChefIntegrationService.new logger
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2015, RacKN by Rob Hirschfeld
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module BarclampChefIntegration
module ApplicationHelper
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
require "barclamp_chef_integration/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "barclamp_chef_integration"
s.version = BarclampChefIntegration::VERSION
s.authors = ["Rob Hirschfeld"]
s.email = ["rob@rackn.com"]
s.homepage = ""
s.summary = "Chef Integrations for Crowbar"
s.description = ""

s.files = Dir["{app,config,db,lib}/**/*"] + [ "Rakefile", ]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
# s.add_dependency "jquery-rails"

# s.add_development_dependency "sqlite3"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2014, Greg Althaus
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

bc = Barclamp.table_exists? ? Barclamp.find_by_name("chef_integration") : nil
BarclampChefIntegration::API_VERSION=(bc && bc.api_version || "v1")
BarclampChefIntegration::API_VERSION_ACCEPTS=(bc && bc.api_version_accepts || "v1")
11 changes: 11 additions & 0 deletions crowbar_engine/barclamp_chef_integration/config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2015, Rob Hirschfeld
# All Rights Reserved

en:
barclamp_chef_integration:
node_roles:
common:
roles:
chef-ready: "Chef Ready"
chef-provisioning: "Chef Provisioning Prepared"
attribs:
47 changes: 47 additions & 0 deletions crowbar_engine/barclamp_chef_integration/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2014, Greg Althaus
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

BarclampBurnin::Engine.routes.draw do

# API routes
scope :defaults => {:format=> 'json'} do
constraints( :api_version => /v[1-9]/ ) do
scope ':api_version' do

resources :barclamps do
collection do
get :catalog
end
member do
end
end
end
end
end

# non-API routes
resources :barclamps do
collection do
end
member do
end
end


# configure routes for these Burnin barclamps controller actions...
# (other controllers may also need routing configuration!)
#
# initialize

end
3 changes: 3 additions & 0 deletions crowbar_engine/barclamp_chef_integration/db/seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_path = File.expand_path(File.join(__FILE__,"../../../.."))
yml_blob = YAML.load_file(File.join(source_path,"crowbar.yml"))
Barclamp.import("chef_integration",yml_blob,source_path)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "barclamp_chef_integration/engine"

module BarclampChefIntegration

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module BarclampChefIntegration
class Engine < ::Rails::Engine
isolate_namespace BarclampChefIntegration
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module BarclampChefIntegration
VERSION = "0.0.2"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :barclamp_chef_integration do
# # Task goes here
# end
8 changes: 8 additions & 0 deletions crowbar_engine/barclamp_chef_integration/script/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/barclamp_chef_integration/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class BarclampBurninTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, BarclampBurnin
end
end
Loading