This repository has been archived by the owner on Mar 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Showing
11 changed files
with
246 additions
and
13 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
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
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
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
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 @@ | ||
name "chef-server-schema" | ||
version "1.0.4" | ||
|
||
source :git => "git@github.com:opscode/chef-server-schema.git" | ||
|
||
dependency "sqitch" | ||
|
||
build do | ||
command "mkdir -p #{install_dir}/embedded/service/#{name}" | ||
command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/#{name}/" | ||
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,29 @@ | ||
name "sqitch" | ||
version "0.973" | ||
|
||
dependency "perl" | ||
dependency "postgresql" | ||
|
||
source :url => "http://www.cpan.org/authors/id/D/DW/DWHEELER/App-Sqitch-#{version}.tar.gz", | ||
:md5 => "0994e9f906a7a4a2e97049c8dbaef584" | ||
|
||
relative_path "App-Sqitch-#{version}" | ||
|
||
env = { | ||
"PATH" => "#{install_dir}/embedded/bin:#{ENV["PATH"]}" | ||
} | ||
|
||
# Ensure we install with the properly configured embedded `cpan` client | ||
omnibus_cpan_client = "#{install_dir}/embedded/bin/cpan -j #{cache_dir}/cpan/OmnibusConfig.pm" | ||
|
||
# See https://github.com/theory/sqitch for more | ||
build do | ||
command "perl Build.PL", :env => env | ||
command "./Build installdeps --cpan_client '#{omnibus_cpan_client}'", :env => env | ||
command "./Build", :env => env | ||
command "./Build test", :env => env | ||
command "./Build install", :env => env | ||
|
||
# We're using PostgreSQL as our database engine, so we need the right driver | ||
command "yes | #{omnibus_cpan_client} DBD::Pg", :env => env | ||
end |
100 changes: 100 additions & 0 deletions
100
files/chef-server-cookbooks/chef-server/files/default/sql/widen-cookbook-version.sql
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,100 @@ | ||
-- Copyright 2013 Opscode, Inc. All Rights Reserved. | ||
-- | ||
-- This file is provided to you 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. | ||
-- | ||
-- @author Oliver Ferrigni <oliver@opscode.com> | ||
-- @author Ho-Sheng Hsiao <hosh@opscode.com> | ||
-- See: https://github.com/opscode/chef_db/commit/389bb2c55f46f2148cbb976dac8dfbb08a1d0d5f | ||
|
||
START TRANSACTION; | ||
|
||
DROP VIEW cookbook_versions_by_rank; | ||
DROP VIEW cookbook_version_dependencies; | ||
DROP VIEW joined_cookbook_version; | ||
|
||
ALTER TABLE cookbook_versions | ||
ALTER major SET DATA TYPE bigint, | ||
ALTER minor SET DATA TYPE bigint, | ||
ALTER patch SET DATA TYPE bigint; | ||
|
||
CREATE OR REPLACE VIEW cookbook_versions_by_rank( | ||
-- Cookbook Version fields | ||
major, -- these 3 are needed for version information (duh) | ||
minor, | ||
patch, | ||
version, -- concatenated string of the complete version | ||
serialized_object, -- needed to access recipe manifest | ||
-- Cookbook fields | ||
org_id, -- used for filtering | ||
name, -- both version and recipe queries require the cookbook name | ||
-- View-specific fields | ||
-- (also used for filtering) | ||
rank) AS | ||
SELECT v.major, | ||
v.minor, | ||
v.patch, | ||
v.major || '.' || v.minor || '.' || v.patch, | ||
v.serialized_object, | ||
c.org_id, | ||
c.name, | ||
rank() OVER (PARTITION BY v.cookbook_id | ||
ORDER BY v.major DESC, v.minor DESC, v.patch DESC) | ||
FROM cookbooks AS c | ||
JOIN cookbook_versions AS v | ||
ON c.id = v.cookbook_id; | ||
|
||
CREATE OR REPLACE VIEW joined_cookbook_version( | ||
-- Cookbook Version fields | ||
major, -- these 3 are needed for version information (duh) | ||
minor, | ||
patch, | ||
version, -- concatenated string of the complete version | ||
serialized_object, -- needed to access recipe manifest | ||
id, -- used for retrieving environment-filtered recipes | ||
-- Cookbook fields | ||
org_id, -- used for filtering | ||
name) -- both version and recipe queries require the cookbook name | ||
AS | ||
SELECT v.major, | ||
v.minor, | ||
v.patch, | ||
v.major || '.' || v.minor || '.' || v.patch, | ||
v.serialized_object, | ||
v.id, | ||
c.org_id, | ||
c.name | ||
FROM cookbooks AS c | ||
JOIN cookbook_versions AS v | ||
ON c.id = v.cookbook_id; | ||
|
||
CREATE OR REPLACE VIEW cookbook_version_dependencies( | ||
org_id, -- for filtering | ||
name, -- cookbook name | ||
major, | ||
minor, | ||
patch, | ||
dependencies) -- version dependency JSON blob; needed for depsolver | ||
AS | ||
SELECT c.org_id, | ||
c.name, | ||
v.major, | ||
v.minor, | ||
v.patch, | ||
v.meta_deps | ||
FROM cookbooks AS c | ||
JOIN cookbook_versions AS v | ||
ON c.id = v.cookbook_id; | ||
|
||
COMMIT; |
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
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
43 changes: 43 additions & 0 deletions
43
files/chef-server-cookbooks/chef-server/recipes/pre_11.1_upgrade_setup.rb
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,43 @@ | ||
# Brings up an existing database for sqitch. We assume you installed the schema | ||
# via omnibus. If this does not work, it would be better to use knife to backup | ||
# the chef server and then restore it after installing the new version of the chef-server. | ||
# We don't expect this to be needed in the future, since Chef Server 11.1+ will have | ||
# sqitch-managed databases. | ||
|
||
pg_helper = PgHelper.new(node) | ||
pg_user = pg_helper.db_user | ||
cookbook = run_context.cookbook_collection['chef-server'] | ||
sql_file = cookbook.preferred_filename_on_disk_location(node, :files, 'sql/widen-cookbook-version.sql', nil) | ||
|
||
# Make sure postgresql is running so we can check the db schema on file. | ||
execute '/opt/chef-server/bin/chef-server-ctl start postgresql' do | ||
retries 20 | ||
end | ||
|
||
ruby_block "check-for-sqitch" do | ||
block { } # no op | ||
only_if { pg_helper.is_running? && !pg_helper.managed_by_sqitch? } | ||
notifies :run, "execute[apply-widen-cookbook-version]", :immediately | ||
end | ||
|
||
execute 'apply-widen-cookbook-version' do | ||
command "psql -U #{pg_user} -d opscode_chef < #{sql_file}" | ||
user pg_user | ||
action :nothing | ||
notifies :run, "execute[sqitchfy_database]", :immediately | ||
end | ||
|
||
execute 'sqitchfy_database' do | ||
command "sqitch --db-user #{pg_user} deploy --log-only --to-target @1.0.0" | ||
cwd '/opt/chef-server/embedded/service/chef-server-schema' | ||
user pg_user | ||
action :nothing | ||
notifies :run, "execute[migrate_database]", :immediately | ||
end | ||
|
||
execute "migrate_database" do | ||
command "sqitch --db-user #{pg_user} deploy --verify" | ||
cwd "/opt/chef-server/embedded/service/chef-server-schema" | ||
user pg_user | ||
action :nothing | ||
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,19 @@ | ||
# | ||
# Copyright:: Copyright (c) 2014 Opscode, Inc. | ||
# | ||
# All Rights Reserved | ||
# | ||
|
||
add_command "upgrade", "Upgrade your private chef installation. Add the '--no-op' flag to see what *would* be upgraded", 1 do | ||
use_why_run_mode = ARGV.include?("--no-op") | ||
|
||
# Our upgrade process is really just a special chef run | ||
command = ["chef-solo", | ||
"--config #{base_path}/embedded/cookbooks/solo.rb", | ||
"--json-attributes #{base_path}/embedded/cookbooks/pre_upgrade_setup.json", | ||
"--log_level fatal"] # yes, that's an underscore in log_level | ||
command << "--why-run" if use_why_run_mode | ||
status = run_command(command.join(" ")) | ||
exit! 1 unless status.success? | ||
reconfigure(false) | ||
end |