Convert provisioning recipes to cookbook

Allows for newer ChefDK releases.

Change-Id: I6619a4852dfeb4ad0dda610b14fe097ad84db9e0
Closes-Bug: #1589764
This commit is contained in:
Samuel Cassiba 2016-06-06 18:56:20 -07:00 committed by Samuel Cassiba
parent a25d83fad1
commit 606507409d
17 changed files with 244 additions and 6 deletions

View File

@ -11,5 +11,6 @@ validation_key "#{current_dir}/validator.pem"
chef_server_url 'https://api.opscode.com/organizations/my_awesome_org'
cache_type 'BasicFile'
cache_options(path: "#{ENV['HOME']}/.chef/checksums")
cookbook_path ["#{current_dir}/../cookbooks"]
cookbook_path ["#{current_dir}/../cookbooks",
"#{current_dir}/../site-cookbooks"]
knife[:secret_file] = "#{current_dir}/encrypted_data_bag_secret"

View File

@ -173,6 +173,10 @@ $ chef exec rake clean
See the doc/tools.md for more information.
## The provisioning cookbook
See site-cookbooks/provisioning/README.md for more information
## Databags
Some basic information about the use of databags within this repo.

View File

@ -39,12 +39,12 @@ end
desc "All-in-One build"
task :allinone => :create_key do
run_command("chef-client #{client_opts} vagrant_linux.rb allinone.rb")
run_command("chef-client #{client_opts} -o 'provisioning::vagrant_linux,provisioning::allinone'")
end
desc "Multi-Node build"
task :multi_node => :create_key do
run_command("chef-client #{client_opts} vagrant_linux.rb multi-node.rb")
run_command("chef-client #{client_opts} -o 'provisioning::vagrant_linux,provisioning::multi-node'")
end
desc "Blow everything away"

16
site-cookbooks/provisioning/.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
.vagrant
Berksfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
# Bundler
Gemfile.lock
bin/*
.bundle/*
.kitchen/
.kitchen.local.yml

View File

@ -0,0 +1,21 @@
---
driver:
name: vagrant
provisioner:
name: chef_zero
# Uncomment the following verifier to leverage Inspec instead of Busser (the
# default verifier)
# verifier:
# name: inspec
platforms:
- name: ubuntu-14.04
- name: centos-7.1
suites:
- name: default
run_list:
- recipe[provisioning::default]
attributes:

View File

@ -0,0 +1,3 @@
source 'https://supermarket.chef.io'
metadata

View File

@ -0,0 +1,16 @@
# provisioning
This cookbook is used for serving chef-provisioning recipes for provisioning
OpenStack with Chef. It is intended to be referenced by chef-client in
local-mode a la ChefDK.
# recipes
## provisioning::vagrant_linux
* installs/uses a Vagrant box based on Linux distribution
## provisioning::allinone
* provisions an all-in-one OpenStack Compute Controller
## provisioning::multi-node
* provisions an OpenStack Controller with Compute nodes

View File

@ -0,0 +1,102 @@
# Put files/directories that should be ignored in this file when uploading
# to a chef-server or supermarket.
# Lines that start with '# ' are comments.
# OS generated files #
######################
.DS_Store
Icon?
nohup.out
ehthumbs.db
Thumbs.db
# SASS #
########
.sass-cache
# EDITORS #
###########
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log
## COMPILED ##
##############
a.out
*.o
*.pyc
*.so
*.com
*.class
*.dll
*.exe
*/rdoc/
# Testing #
###########
.watchr
.rspec
spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
.kitchen*
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml
# SCM #
#######
.git
*/.git
.gitignore
.gitmodules
.gitconfig
.gitattributes
.svn
*/.bzr/*
*/.hg/*
*/.svn/*
# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp
# Cookbooks #
#############
CONTRIBUTING*
CHANGELOG*
TESTING*
MAINTAINERS.toml
# Strainer #
############
Colanderfile
Strainerfile
.colander
.strainer
# Vagrant #
###########
.vagrant
Vagrantfile

View File

@ -0,0 +1,7 @@
name 'provisioning'
maintainer 'openstack-chef'
maintainer_email 'openstack-dev@lists.openstack.org'
license 'Apache 2.0'
description 'Helper cookbook for chef-provisioning'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'

View File

@ -39,6 +39,6 @@ machine 'controller' do
role 'allinone'
chef_environment env
file('/etc/chef/openstack_data_bag_secret',
"#{File.dirname(__FILE__)}/.chef/encrypted_data_bag_secret")
"#{File.dirname(__FILE__)}/../../../../../encrypted_data_bag_secret")
converge true
end

View File

@ -0,0 +1,17 @@
#
# Cookbook Name:: provisioning
# Recipe:: default
#
# Copyright 2016 openstack-chef
#
# 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.

View File

@ -27,7 +27,7 @@ machine 'controller' do
role 'multi-node-controller'
chef_environment env
file('/etc/chef/openstack_data_bag_secret',
"#{File.dirname(__FILE__)}/.chef/encrypted_data_bag_secret")
"#{File.dirname(__FILE__)}/../../../../../encrypted_data_bag_secret")
converge true
end
@ -51,7 +51,7 @@ end
role 'multi-node-compute'
chef_environment env
file('/etc/chef/openstack_data_bag_secret',
"#{File.dirname(__FILE__)}/.chef/encrypted_data_bag_secret")
"#{File.dirname(__FILE__)}/../../../../../encrypted_data_bag_secret")
converge true
end
end

View File

@ -0,0 +1,2 @@
require 'chefspec'
require 'chefspec/berkshelf'

View File

@ -0,0 +1,32 @@
#
# Cookbook Name:: provisioning
# Spec:: default
#
# Copyright 2016 openstack-chef
#
# 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.
require 'spec_helper'
describe 'provisioning::default' do
context 'When all attributes are default, on an unspecified platform' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
end

View File

@ -0,0 +1,9 @@
require 'spec_helper'
describe 'provisioning::default' do
# Serverspec examples can be found at
# http://serverspec.org/resource_types.html
it 'does something' do
skip 'Replace this with meaningful tests'
end
end

View File

@ -0,0 +1,8 @@
require 'serverspec'
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
set :backend, :exec
else
set :backend, :cmd
set :os, family: 'windows'
end