fhcap-cli 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/fhcap-cli.gemspec +3 -0
- data/lib/cookbooks/provision/recipes/cluster_provision_instances.rb +1 -0
- data/lib/fhcap/cluster.rb +12 -0
- data/lib/fhcap/component.rb +2 -5
- data/lib/fhcap/cookbook.rb +20 -21
- data/lib/fhcap/tasks/chef/chef_server_task.rb +32 -0
- data/lib/fhcap/tasks/chef/chef_task_base.rb +1 -0
- data/lib/fhcap/tasks/chef/cookbook/archive.rb +6 -1
- data/lib/fhcap/tasks/chef/cookbook/list_artifacts.rb +3 -1
- data/lib/fhcap/tasks/chef/cookbook/update_config.rb +13 -7
- data/lib/fhcap/tasks/chef/cookbook/update_readme.rb +9 -2
- data/lib/fhcap/tasks/chef/cookbook/update_version.rb +1 -1
- data/lib/fhcap/tasks/chef/environments/destroy.rb +5 -3
- data/lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb +2 -1
- data/lib/fhcap/tasks/chef/provisioning/provision.rb +1 -1
- data/lib/fhcap/tasks/chef/server/create_user.rb +1 -0
- data/lib/fhcap/tasks/cluster/bootstrap_server.rb +17 -0
- data/lib/fhcap/tasks/cluster/create.rb +1 -0
- data/lib/fhcap/tasks/repo/checkout.rb +12 -4
- data/lib/fhcap/version.rb +1 -1
- data/spec/fhcap/tasks/chef/cookbook/archive_spec.rb +21 -0
- data/templates/chef/cookbook/README.md.erb +72 -0
- data/templates/chef/cookbook/metadata.erb +0 -19
- data/templates/chef/environment_core.json.erb +1 -1
- data/templates/chef/environment_single.json.erb +1 -1
- data/templates/cluster/aws/core-3node.json.erb +2 -2
- data/templates/cluster/aws/mbaas-3node.json.erb +1 -1
- metadata +22 -5
- data/lib/fhcap/tasks/chef/cookbook/update_changelog.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2404936a843382f70df3f7f0c834b3ed5891ab4f
|
4
|
+
data.tar.gz: b3edd1294c2b6ea919a7d81642bf464adf29808a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78843714ea979e07b5dffc9a4dec0f75e3fc626480bab516f27879e2ce106ca6cfeef9867fa3862ddd9a43dd1546055967a9d1e01be585f4d1d49fe1e01cc2d8
|
7
|
+
data.tar.gz: 1d8872f549528b47f72ec8f465763b94beb8d907c7d9d43a6ab4d38606f306aa3a84db13284c729891546ec83f225f35405a0aa0cb255c504d6bdbac621cf6f9
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
|
2
|
+
## 0.4.5
|
3
|
+
|
4
|
+
* [RHMAP-3789] - Implement series option for cluster provision task to allow switching between parallel/series provisions of cluster nodes.
|
5
|
+
* [RHMAP-2898] - Use library classes where possible instead of running commands directly via CLI.
|
6
|
+
* [RHMAP-3708] - Use meh1 buildfarm by default
|
7
|
+
* [RHMAP-3675] - Remove metadata, readme and changelog update from component/cookbook update task. Added separate update_metadata task to allow updating metadata and readmes.
|
8
|
+
* [RHMAP-3787] - Skip config update if not applicable during component update
|
9
|
+
|
2
10
|
## 0.4.4
|
3
11
|
|
4
12
|
* [RHMAP-3188] - Multi node template improvements. Breaks out clustered component (galera, rabbitmq and mongo) provisions into separate creation steps allowing them to be handled in isolation from the full chef run.
|
data/fhcap-cli.gemspec
CHANGED
@@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'FHCAP Command Line Tool'
|
13
13
|
spec.homepage = "https://github.com/fheng/fhcap-cli"
|
14
14
|
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = '>= 2.0.0'
|
16
|
+
spec.required_rubygems_version = '>= 2.5.0'
|
15
17
|
|
16
18
|
spec.files = `git ls-files -z`.split("\x0")
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -28,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
28
30
|
spec.add_dependency 'knife-cookbook-readme', '= 0.2.1'
|
29
31
|
spec.add_dependency 'ruby-progressbar', '= 1.7.5'
|
30
32
|
spec.add_dependency 'java_properties', '= 0.0.4'
|
33
|
+
spec.add_dependency 'archive-tar-minitar', '= 0.5.2'
|
31
34
|
spec.add_dependency 'aws-sdk', '= 2.1.35'
|
32
35
|
spec.add_dependency 'chef', '= 12.4.3'
|
33
36
|
spec.add_dependency 'chef-provisioning', '= 1.4.1'
|
@@ -2,6 +2,7 @@ with_cluster_instances(node) do |cluster_instances|
|
|
2
2
|
cluster_instances.each do |chef_environment, instances|
|
3
3
|
with_chef_environment chef_environment do
|
4
4
|
machine_batch 'cluster_provision_instances' do
|
5
|
+
max_simultaneous node['max_simultaneous']
|
5
6
|
instances.each do |name, cfg|
|
6
7
|
machine name do
|
7
8
|
chef_environment chef_environment
|
data/lib/fhcap/cluster.rb
CHANGED
@@ -42,6 +42,7 @@ module Fhcap
|
|
42
42
|
method_option 'roles', :type => :string, :desc => "Query to pass to roles"
|
43
43
|
method_option 'series', :type => :boolean, :default => false, :desc => "Run provision in series"
|
44
44
|
method_option 'strategy', :type => :string, :default => 'chef', :desc => "Provision strategy to use. Default is chef provisioning, falls back to knife provision.", :enum => %w{chef knife}
|
45
|
+
method_option 'seed-cookbooks', :type => :boolean, :default => false, :desc => "Seed cookbooks on each node before running provision (Prevents long wait during cookbook sync if nodes run-list has changed)"
|
45
46
|
|
46
47
|
provision_steps = %w{repo-checkout cookbook-promote server-bootstrap provision}
|
47
48
|
provision_steps.each do |step|
|
@@ -123,6 +124,17 @@ module Fhcap
|
|
123
124
|
Tasks::Cluster::ChefProvisioningTask.new(task_options(options.dup)).run
|
124
125
|
end
|
125
126
|
|
127
|
+
desc "bootstrap_server", "[ADVANCED USAGE] Bootstrap a chef server for this cluster"
|
128
|
+
|
129
|
+
shared_options :verbose
|
130
|
+
|
131
|
+
method_option 'name', :type => :string, :required => true, :desc => 'Cluster name'
|
132
|
+
|
133
|
+
def bootstrap_server
|
134
|
+
require 'fhcap/tasks/cluster/bootstrap_server'
|
135
|
+
Tasks::Cluster::BootstrapServer.new(task_options(options.dup)).run
|
136
|
+
end
|
137
|
+
|
126
138
|
end
|
127
139
|
end
|
128
140
|
end
|
data/lib/fhcap/component.rb
CHANGED
@@ -12,8 +12,7 @@ module Fhcap
|
|
12
12
|
|
13
13
|
shared_options :interactive, :verbose
|
14
14
|
method_option 'force', :type => :boolean, :aliases => "-f", :desc => "Will force the component version update even if the artifact cant be found"
|
15
|
-
method_option '
|
16
|
-
method_option 'tag', :type => :string, :desc => "Adds a tag to a components changelog entry"
|
15
|
+
method_option 'level', :type => :string, :aliases => "-l", :desc => "Cookbook Bump level", :default => 'minor', :enum => %w{major minor patch}
|
17
16
|
|
18
17
|
def update(component, version, build)
|
19
18
|
|
@@ -24,9 +23,7 @@ module Fhcap
|
|
24
23
|
Fhcap::CLI::Component.new.invoke(:update_config, [component], {force: options[:force]})
|
25
24
|
|
26
25
|
#3. Update cookbook
|
27
|
-
|
28
|
-
clog_entry += " (#{options[:tag]})" if options[:tag]
|
29
|
-
Fhcap::CLI::Cookbook.new.invoke(:update, [], {cookbooks: [component], :"changelog-entries" => [clog_entry], wip: options['wip']})
|
26
|
+
Fhcap::CLI::Cookbook.new.invoke(:update, [], {cookbooks: [component], level: options['level']})
|
30
27
|
|
31
28
|
end
|
32
29
|
|
data/lib/fhcap/cookbook.rb
CHANGED
@@ -10,56 +10,55 @@ module Fhcap
|
|
10
10
|
|
11
11
|
desc "update", "Update a cookbook, defaults to all cookbooks."
|
12
12
|
long_desc <<-LONGDESC
|
13
|
-
Updates a cookbook(s) version
|
13
|
+
Updates a cookbook(s) version.
|
14
14
|
|
15
15
|
With --cookbooks (-c) <cookbook1 cookbook2> option, specifies the cookbook(s) to update, default is all cookbooks.
|
16
16
|
|
17
17
|
With --modified (-m) option, updates all cookbooks modified between the current HEAD and the last origin commit.
|
18
18
|
|
19
|
-
With --changelog-entries (-e) <'entry1' 'entry2'> option, changelog entries to be put into the cookbook(s) changelog file for this version change.
|
20
|
-
|
21
19
|
With --level (-l) [major|minor|patch"] option, sets the bump level to be applied to the given cookbook(s), default is minor.
|
22
20
|
|
23
21
|
With --version (-v) 1.1.1 option, sets the version to be applied to the given cookbook(s).
|
24
22
|
|
25
|
-
With --wip option, defaults the level option to 'patch' and skips all metadata updates
|
23
|
+
With --wip option, defaults the level option to 'patch' and skips all metadata updates.
|
26
24
|
|
27
25
|
Examples:
|
28
26
|
|
29
|
-
fhcap cookbook update -c feedhenry_common
|
27
|
+
fhcap cookbook update -c feedhenry_common
|
30
28
|
|
31
|
-
fhcap cookbook update -c feedhenry_common
|
29
|
+
fhcap cookbook update -c feedhenry_common -l major
|
32
30
|
|
33
|
-
fhcap cookbook update -c feedhenry_common -
|
31
|
+
fhcap cookbook update -c feedhenry_common -v 1.2.3
|
34
32
|
LONGDESC
|
35
33
|
|
36
34
|
shared_options :cookbooks, :modified
|
37
35
|
|
38
|
-
method_option '
|
39
|
-
method_option 'level', :type => :string, :aliases => "-l", :desc => "Bump level", :enum => %w{major minor patch}
|
36
|
+
method_option 'level', :type => :string, :aliases => "-l", :desc => "Cookbook Bump level", :default => 'minor', :enum => %w{major minor patch}
|
40
37
|
method_option 'version', :type => :string, :aliases => "-v", :desc => "Version to set manually"
|
41
|
-
method_option 'wip', :type => :boolean, :desc => "Work in progress. No meta is generated and level is set to patch level changes."
|
42
38
|
|
43
39
|
def update
|
44
40
|
require "fhcap/tasks/chef/cookbook/update_version"
|
45
|
-
require "fhcap/tasks/chef/cookbook/update_metadata"
|
46
|
-
require "fhcap/tasks/chef/cookbook/update_readme"
|
47
|
-
require "fhcap/tasks/chef/cookbook/update_changelog"
|
48
41
|
cookbooks = get_cookbooks(options, nil, repo_cookbook_paths('-cookbooks'))
|
49
42
|
say("Cookbook update for #{cookbooks}", :yellow)
|
50
43
|
|
51
44
|
cookbooks.each do |cookbook|
|
52
45
|
Tasks::Chef::Cookbook::UpdateVersion.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
53
46
|
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "update_metadata", "Update a cookbooks metadata, defaults to all cookbooks."
|
50
|
+
|
51
|
+
shared_options :cookbooks, :modified
|
52
|
+
|
53
|
+
def update_metadata
|
54
|
+
require "fhcap/tasks/chef/cookbook/update_metadata"
|
55
|
+
require "fhcap/tasks/chef/cookbook/update_readme"
|
56
|
+
cookbooks = get_cookbooks(options, nil, repo_cookbook_paths('-cookbooks'))
|
57
|
+
say("Cookbook update_metadata for #{cookbooks}", :yellow)
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
cookbooks.each do |cookbook|
|
59
|
-
Tasks::Chef::Cookbook::UpdateMetadata.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
60
|
-
Tasks::Chef::Cookbook::UpdateReadme.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
61
|
-
Tasks::Chef::Cookbook::UpdateChangelog.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
62
|
-
end
|
59
|
+
cookbooks.each do |cookbook|
|
60
|
+
Tasks::Chef::Cookbook::UpdateMetadata.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
61
|
+
Tasks::Chef::Cookbook::UpdateReadme.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
@@ -21,6 +21,7 @@ module Fhcap
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def with_chef_server(&block)
|
24
|
+
::Chef::Config.solo = false
|
24
25
|
if local_chef_server?
|
25
26
|
with_local_chef_server(&block)
|
26
27
|
else
|
@@ -102,6 +103,37 @@ module Fhcap
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
106
|
+
def knife_environment_delete(env, server)
|
107
|
+
thor.say " * deleting environment '#{env}' from #{server}"
|
108
|
+
delete_chef_object(::Chef::Knife::EnvironmentDelete, server, env)
|
109
|
+
end
|
110
|
+
|
111
|
+
def knife_data_bag_delete(data_bag, item, server)
|
112
|
+
thor.say " * deleting data bag '#{data_bag} #{item}' from #{server}"
|
113
|
+
delete_chef_object(::Chef::Knife::DataBagDelete, server, data_bag, item)
|
114
|
+
end
|
115
|
+
|
116
|
+
def delete_chef_object(klass, server, *args)
|
117
|
+
begin
|
118
|
+
suppress_stdout(!options[:verbose]) do
|
119
|
+
klass.load_deps
|
120
|
+
knife_command = klass.new(args)
|
121
|
+
knife_command.config[:config_file] = knife_config_file_for(server)
|
122
|
+
knife_command.config[:yes] = true
|
123
|
+
knife_command.configure_chef
|
124
|
+
knife_command.run
|
125
|
+
end
|
126
|
+
rescue Net::HTTPServerException => e
|
127
|
+
response = e.response
|
128
|
+
case response
|
129
|
+
when Net::HTTPNotFound
|
130
|
+
puts "The object you are looking for could not be found, assuming this ok and continuing ..."
|
131
|
+
else
|
132
|
+
raise e
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
105
137
|
end
|
106
138
|
end
|
107
139
|
end
|
@@ -25,6 +25,7 @@ module Fhcap
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def run_knife_cmd(cmd, server, capture=true)
|
28
|
+
#ToDo [RHMAP-2898] Use knife object
|
28
29
|
cmd = "cd #{File.expand_path("..", knife_config_dir)} && knife #{cmd} -c #{knife_config_file_for(server)}"
|
29
30
|
resp = thor.run(cmd, :capture => capture)
|
30
31
|
thor.say resp if verbose && !capture
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'fhcap/tasks/chef/chef_task_base'
|
2
2
|
require 'fhcap/tasks/repo/checkout'
|
3
|
+
require 'zlib'
|
4
|
+
require 'archive/tar/minitar'
|
3
5
|
|
4
6
|
module Fhcap
|
5
7
|
module Tasks
|
@@ -31,7 +33,10 @@ module Fhcap
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
|
36
|
+
Dir.chdir config.tmp_dir do
|
37
|
+
::Archive::Tar::Minitar.pack('cookbooks', Zlib::GzipWriter.new(File.open(@archive, 'wb')))
|
38
|
+
end
|
39
|
+
|
35
40
|
thor.say_status 'create', @archive, :green
|
36
41
|
end
|
37
42
|
|
@@ -12,7 +12,9 @@ module Fhcap
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run
|
15
|
-
|
15
|
+
if print_table?
|
16
|
+
thor.say "Chef::Cookbook::Component::List", :yellow
|
17
|
+
end
|
16
18
|
cookbooks = get_cookbooks(options, nil, repo_cookbook_paths('site-cookbooks'))
|
17
19
|
|
18
20
|
results = print_table? ? [table_header("Component", "Version", "Build")] : []
|
@@ -43,7 +43,9 @@ module Fhcap
|
|
43
43
|
cookbook = cookbook_loader.cookbooks_by_name[name]
|
44
44
|
|
45
45
|
conf_attr_file = cookbook.attribute_filenames.find { |e| /conf.rb/ =~ e }
|
46
|
-
|
46
|
+
unless conf_attr_file
|
47
|
+
return thor.say "No cookbook conf.rb attribute file found for #{name}, skipping config update"
|
48
|
+
end
|
47
49
|
|
48
50
|
conf_src_files = cfg_lookup(name)
|
49
51
|
exit_with_error("No local src config file found for #{name}") if conf_src_files.empty?
|
@@ -52,14 +54,18 @@ module Fhcap
|
|
52
54
|
thor.say "conf_src_files = #{conf_src_files}"
|
53
55
|
|
54
56
|
conf_src_files.each() do |file|
|
55
|
-
if File.
|
56
|
-
|
57
|
+
if File.exists? file
|
58
|
+
if File.extname(file) =~ /.properties/
|
59
|
+
cfg = Fhcap::JavaConfig.new
|
60
|
+
else
|
61
|
+
cfg = Fhcap::JsonConfig.new
|
62
|
+
end
|
63
|
+
cfg.from_attributes_file(name, conf_attr_file)
|
64
|
+
cfg.from_file(file, force, overrides)
|
65
|
+
thor.create_file(conf_attr_file, cfg.attribute_file_content(name, sort))
|
57
66
|
else
|
58
|
-
|
67
|
+
thor.say "Missing local file '#{file}', skipping config update"
|
59
68
|
end
|
60
|
-
cfg.from_attributes_file(name, conf_attr_file)
|
61
|
-
cfg.from_file(file, force, overrides)
|
62
|
-
thor.create_file(conf_attr_file, cfg.attribute_file_content(name, sort))
|
63
69
|
end
|
64
70
|
|
65
71
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fhcap/tasks/chef/chef_task_base'
|
2
|
+
require 'knife_cookbook_readme'
|
2
3
|
|
3
4
|
module Fhcap
|
4
5
|
module Tasks
|
@@ -18,8 +19,14 @@ module Fhcap
|
|
18
19
|
cookbook = cookbook_loader.cookbooks_by_name[name]
|
19
20
|
metadata_file = cookbook.metadata_filenames.first
|
20
21
|
readme_file = cookbook.root_filenames.find { |e| /README/ =~ e }
|
21
|
-
|
22
|
-
|
22
|
+
thor.say_status :run, "knife cookbook readme from #{metadata_file} > #{readme_file}", :green
|
23
|
+
|
24
|
+
template_file = File.join(Fhcap.source_root, 'templates', 'chef', 'cookbook', 'README.md.erb')
|
25
|
+
metadata = ::KnifeCookbookReadme::Metadata.from_file(metadata_file)
|
26
|
+
template = File.read(template_file)
|
27
|
+
result = ::KnifeCookbookReadme::Readme.new(metadata).render(template)
|
28
|
+
|
29
|
+
thor.create_file readme_file, result, force: true
|
23
30
|
end
|
24
31
|
|
25
32
|
end
|
@@ -12,7 +12,7 @@ module Fhcap
|
|
12
12
|
super
|
13
13
|
@name = options[:cookbook]
|
14
14
|
@version = options[:version]
|
15
|
-
@level = ('manual' if @version) ||
|
15
|
+
@level = ('manual' if @version) || options[:level] || 'minor'
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'fhcap/tasks/chef/chef_server_task'
|
2
|
+
require 'chef/knife/environment_delete'
|
3
|
+
require 'chef/knife/data_bag_delete'
|
2
4
|
|
3
5
|
module Fhcap
|
4
6
|
module Tasks
|
@@ -17,10 +19,10 @@ module Fhcap
|
|
17
19
|
thor.say "Chef::Environments::Destroy #{@name}", :yellow
|
18
20
|
|
19
21
|
if chef_server
|
20
|
-
if thor.yes? "Remove all environments and config from the chef server
|
22
|
+
if thor.yes? "Remove all environments and config from the chef server '#{chef_server}'? (y/n)"
|
21
23
|
with_chef_server do
|
22
|
-
|
23
|
-
|
24
|
+
knife_environment_delete(@name, chef_server)
|
25
|
+
knife_data_bag_delete('environments', @name, chef_server)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -20,7 +20,8 @@ module Fhcap
|
|
20
20
|
local_repo_path: repo_dir(@chef_repo),
|
21
21
|
local_repo_clusters_dir: repo_clusters_dir(@chef_repo),
|
22
22
|
chef_server_config: chef_server_config_hash_for(@chef_server),
|
23
|
-
provider_credentials: provider_credentials(@cluster_config[:provider_id])
|
23
|
+
provider_credentials: provider_credentials(@cluster_config[:provider_id]),
|
24
|
+
max_simultaneous: options[:series] ? 1 : nil
|
24
25
|
})
|
25
26
|
else
|
26
27
|
exit_with_error("Unknown cluster #{@name}")
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fhcap/tasks/cluster/cluster_task_base'
|
2
|
+
require 'fhcap/tasks/chef/server/bootstrap'
|
3
|
+
|
4
|
+
module Fhcap
|
5
|
+
module Tasks
|
6
|
+
module Cluster
|
7
|
+
class BootstrapServer < ClusterTaskBase
|
8
|
+
|
9
|
+
def run
|
10
|
+
thor.say "Cluster::BootstrapServer: name = #{name}", :yellow
|
11
|
+
Chef::Server::Bootstrap.new(@options.dup.merge({:environments => cluster_environments}.merge(chef_task_options))).run
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -207,6 +207,7 @@ module Fhcap
|
|
207
207
|
cluster_config[:environments].each do |env_name, env_cfg|
|
208
208
|
env_name = "#{name}-#{env_name}"
|
209
209
|
knife_config_file = knife_config_file_for(cluster_config[:chef_server])
|
210
|
+
#ToDo [RHMAP-2898] Use knife object
|
210
211
|
nodes = JSON.parse(`knife search "chef_environment:#{env_name} AND recipes:nginx_feedhenry\\:\\:loadbalancer" -c #{knife_config_file} -F json -a name -a cloud.public_ipv4`)
|
211
212
|
|
212
213
|
lb_node = nodes['rows'].collect do |row|
|
@@ -147,10 +147,18 @@ module Fhcap
|
|
147
147
|
|
148
148
|
def repo_librarian_install(repo_dir)
|
149
149
|
if File.exists? File.join(repo_dir, 'Cheffile')
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
thor.say_status :run, "librarian-chef install from \"#{repo_dir}\"", :green
|
151
|
+
require "librarian/chef/environment"
|
152
|
+
require "librarian/action/resolve"
|
153
|
+
require "librarian/action/install"
|
154
|
+
require "librarian/ui"
|
155
|
+
|
156
|
+
environment = ::Librarian::Chef::Environment.new(:project_path => repo_dir)
|
157
|
+
environment.ui = ::Librarian::UI::Shell.new(::Thor::Shell::Basic.new)
|
158
|
+
environment.ui.be_quiet! unless verbose
|
159
|
+
|
160
|
+
::Librarian::Action::Resolve.new(environment).run
|
161
|
+
::Librarian::Action::Install.new(environment).run
|
154
162
|
end
|
155
163
|
true
|
156
164
|
end
|
data/lib/fhcap/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "fhcap/tasks/chef/cookbook/archive"
|
3
|
+
|
4
|
+
describe Fhcap::Tasks::Chef::Cookbook::Archive do
|
5
|
+
|
6
|
+
subject {
|
7
|
+
Fhcap::Tasks::Chef::Cookbook::Archive.new(options)
|
8
|
+
}
|
9
|
+
|
10
|
+
let(:thor) do
|
11
|
+
DummyThor.new
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:config) do
|
15
|
+
{}
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#initialize" do
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<%= title %>
|
2
|
+
<%= '=' * title.length %>
|
3
|
+
|
4
|
+
<%= description %>
|
5
|
+
|
6
|
+
Requirements
|
7
|
+
------------
|
8
|
+
|
9
|
+
### Platform:
|
10
|
+
|
11
|
+
<% unless platforms.empty? %>
|
12
|
+
<% platforms.each do |platform| %>
|
13
|
+
* <%= platform %>
|
14
|
+
<% end %>
|
15
|
+
<% else %>
|
16
|
+
*No platforms defined*
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
### Cookbooks:
|
20
|
+
|
21
|
+
<% unless dependencies.empty? %>
|
22
|
+
<% dependencies.each do |cookbook| %>
|
23
|
+
* <%= cookbook %>
|
24
|
+
<% end %>
|
25
|
+
<% else %>
|
26
|
+
*No dependencies defined*
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
Attributes
|
30
|
+
----------
|
31
|
+
|
32
|
+
<% unless attributes.empty? %>
|
33
|
+
<table>
|
34
|
+
<tr>
|
35
|
+
<td>Attribute</td>
|
36
|
+
<td>Description</td>
|
37
|
+
<td>Default</td>
|
38
|
+
</tr>
|
39
|
+
<% attributes.each do |name, description, default| %>
|
40
|
+
<tr>
|
41
|
+
<td><code><%= name %></code></td>
|
42
|
+
<td><%= description %></td>
|
43
|
+
<td><code><%= default %></code></td>
|
44
|
+
</tr>
|
45
|
+
<% end %>
|
46
|
+
</table>
|
47
|
+
<% else %>
|
48
|
+
*No attributes defined*
|
49
|
+
<% end %>
|
50
|
+
|
51
|
+
Recipes
|
52
|
+
-------
|
53
|
+
|
54
|
+
<% unless recipes.empty? %>
|
55
|
+
<% recipes.each do |recipe, description| %>
|
56
|
+
### <%= recipe %>
|
57
|
+
|
58
|
+
<%= description %>
|
59
|
+
|
60
|
+
<% end %>
|
61
|
+
<% else %>
|
62
|
+
*No recipes defined*
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
License and Author
|
66
|
+
------------------
|
67
|
+
|
68
|
+
Author:: <%= author %> (<<%= author_email %>>)
|
69
|
+
|
70
|
+
Copyright:: <%= copyright_year %>, <%= author %>
|
71
|
+
|
72
|
+
License:: <%= license %>
|
@@ -23,23 +23,4 @@ depends '<%= k %>'
|
|
23
23
|
%>
|
24
24
|
<% sanatized_recipes_hash.sort.each do |k, v| %>
|
25
25
|
recipe '<%= k.to_s %>', '<%= v %>'
|
26
|
-
<% end %>
|
27
|
-
<% attributes.sort.each do |attr_name, attr_hash| %>
|
28
|
-
|
29
|
-
attribute '<%= attr_name %>',
|
30
|
-
<% sanatized_attrs_hash = {}
|
31
|
-
attr_hash.each do |k, v|
|
32
|
-
if k == 'calculated' || k == 'type' || (k == 'choice' && v.empty?)
|
33
|
-
next
|
34
|
-
end
|
35
|
-
sanatized_attrs_hash[k] = v
|
36
|
-
end
|
37
|
-
%>
|
38
|
-
<% sanatized_attrs_hash.sort.each_with_index do |attr, index| %>
|
39
|
-
<%
|
40
|
-
k = attr[0]
|
41
|
-
v = attr[1]
|
42
|
-
%>
|
43
|
-
:<%= k %> => <% if v.is_a? Array %><%=v%><% else %>"<%== v %>"<%end%><%if index < sanatized_attrs_hash.length - 1%>,<%end%>
|
44
|
-
<% end %>
|
45
26
|
<% end %>
|
@@ -82,7 +82,7 @@
|
|
82
82
|
"subnet": "1a"
|
83
83
|
},
|
84
84
|
"load_balancers": ["studio", "scm", "messaging", "metrics"],
|
85
|
-
"run_list": ["role[mount_data_volumes]", "role[platform_mongo_server]", "role[rabbitmq_server]", "role[app_server]", "role[fh-scm]", "role[fh-messaging]", "role[fh-metrics]", "role[fh-stats]", "recipe[feedhenry_common::fhctl]"]
|
85
|
+
"run_list": ["role[mount_data_volumes]", "role[platform_mongo_server]", "role[rabbitmq_server]", "role[galera_server]", "role[app_server]", "role[fh-scm]", "role[fh-messaging]", "role[fh-metrics]", "role[fh-stats]", "recipe[feedhenry_common::fhctl]"]
|
86
86
|
},
|
87
87
|
"node2": {
|
88
88
|
"aws": {
|
@@ -91,7 +91,7 @@
|
|
91
91
|
"subnet": "1b"
|
92
92
|
},
|
93
93
|
"load_balancers": ["studio", "scm", "messaging", "metrics"],
|
94
|
-
"run_list": ["role[mount_data_volumes]", "role[platform_mongo_server]", "role[rabbitmq_server]", "role[app_server]", "role[fh-scm]", "role[fh-messaging]", "role[fh-metrics]", "recipe[feedhenry_common::fhctl]"]
|
94
|
+
"run_list": ["role[mount_data_volumes]", "role[platform_mongo_server]", "role[rabbitmq_server]", "role[galera_server]", "role[app_server]", "role[fh-scm]", "role[fh-messaging]", "role[fh-metrics]", "recipe[feedhenry_common::fhctl]"]
|
95
95
|
},
|
96
96
|
"mgt1": {
|
97
97
|
"aws": {
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"protocols": ["all"],
|
38
38
|
"start": 0,
|
39
39
|
"end": 65535,
|
40
|
-
"groups": ["<%= config[:environment_name] %>", "<%= config[:environment_name] %>-
|
40
|
+
"groups": ["<%= config[:environment_name] %>", "<%= config[:environment_name] %>-api-lb"]
|
41
41
|
}
|
42
42
|
]
|
43
43
|
},
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fhcap-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Nairn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.0.4
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: archive-tar-minitar
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.5.2
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.5.2
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: aws-sdk
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -420,7 +434,6 @@ files:
|
|
420
434
|
- lib/fhcap/tasks/chef/cookbook/list.rb
|
421
435
|
- lib/fhcap/tasks/chef/cookbook/list_artifacts.rb
|
422
436
|
- lib/fhcap/tasks/chef/cookbook/update_artifact.rb
|
423
|
-
- lib/fhcap/tasks/chef/cookbook/update_changelog.rb
|
424
437
|
- lib/fhcap/tasks/chef/cookbook/update_config.rb
|
425
438
|
- lib/fhcap/tasks/chef/cookbook/update_metadata.rb
|
426
439
|
- lib/fhcap/tasks/chef/cookbook/update_readme.rb
|
@@ -438,6 +451,7 @@ files:
|
|
438
451
|
- lib/fhcap/tasks/chef/server/info.rb
|
439
452
|
- lib/fhcap/tasks/chef/server/provision.rb
|
440
453
|
- lib/fhcap/tasks/clean.rb
|
454
|
+
- lib/fhcap/tasks/cluster/bootstrap_server.rb
|
441
455
|
- lib/fhcap/tasks/cluster/chef_provisioning_task.rb
|
442
456
|
- lib/fhcap/tasks/cluster/cluster_task_base.rb
|
443
457
|
- lib/fhcap/tasks/cluster/create.rb
|
@@ -469,6 +483,7 @@ files:
|
|
469
483
|
- lib/fhcap/thor_base.rb
|
470
484
|
- lib/fhcap/version.rb
|
471
485
|
- spec/fhcap/cli_spec.rb
|
486
|
+
- spec/fhcap/tasks/chef/cookbook/archive_spec.rb
|
472
487
|
- spec/fhcap/tasks/chef/cookbook/list_artifacts_spec.rb
|
473
488
|
- spec/fhcap/tasks/chef/cookbook/update_artifact_spec.rb
|
474
489
|
- spec/fhcap/tasks/chef/cookbook/update_config_spec.rb
|
@@ -487,6 +502,7 @@ files:
|
|
487
502
|
- spec/spec_helper.rb
|
488
503
|
- spec/support/dummy_config.rb
|
489
504
|
- spec/support/dummy_thor.rb
|
505
|
+
- templates/chef/cookbook/README.md.erb
|
490
506
|
- templates/chef/cookbook/changelog.md.erb
|
491
507
|
- templates/chef/cookbook/metadata.erb
|
492
508
|
- templates/chef/environment_core.json.erb
|
@@ -540,12 +556,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
540
556
|
requirements:
|
541
557
|
- - '>='
|
542
558
|
- !ruby/object:Gem::Version
|
543
|
-
version:
|
559
|
+
version: 2.0.0
|
544
560
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
545
561
|
requirements:
|
546
562
|
- - '>='
|
547
563
|
- !ruby/object:Gem::Version
|
548
|
-
version:
|
564
|
+
version: 2.5.0
|
549
565
|
requirements: []
|
550
566
|
rubyforge_project:
|
551
567
|
rubygems_version: 2.5.0
|
@@ -554,6 +570,7 @@ specification_version: 4
|
|
554
570
|
summary: FHCAP Command Line Tool
|
555
571
|
test_files:
|
556
572
|
- spec/fhcap/cli_spec.rb
|
573
|
+
- spec/fhcap/tasks/chef/cookbook/archive_spec.rb
|
557
574
|
- spec/fhcap/tasks/chef/cookbook/list_artifacts_spec.rb
|
558
575
|
- spec/fhcap/tasks/chef/cookbook/update_artifact_spec.rb
|
559
576
|
- spec/fhcap/tasks/chef/cookbook/update_config_spec.rb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'fhcap/tasks/chef/chef_task_base'
|
2
|
-
|
3
|
-
module Fhcap
|
4
|
-
module Tasks
|
5
|
-
module Chef
|
6
|
-
module Cookbook
|
7
|
-
class UpdateChangelog < ChefTaskBase
|
8
|
-
|
9
|
-
attr_reader :name
|
10
|
-
|
11
|
-
def initialize(options)
|
12
|
-
super
|
13
|
-
@name = options[:cookbook]
|
14
|
-
end
|
15
|
-
|
16
|
-
def run
|
17
|
-
thor.say "Chef::Cookbook::UpdateChangelog cookbook = #{name}", :yellow
|
18
|
-
cookbook = cookbook_loader.cookbooks_by_name[name]
|
19
|
-
meta = get_cookbook_meta(name)
|
20
|
-
|
21
|
-
version = meta.version
|
22
|
-
changelog_file = cookbook.root_filenames.find { |e| /CHANGELOG.md/ =~ e }
|
23
|
-
|
24
|
-
if changelog_file
|
25
|
-
changelog = parse_changelog(changelog_file)
|
26
|
-
|
27
|
-
if changelog[version]
|
28
|
-
thor.say_status("error", "Already a Changelog entry for #{name} version #{version}", :red)
|
29
|
-
else
|
30
|
-
changelog[version] = options[:'changelog-entries'] || []
|
31
|
-
thor.template(File.join('templates', 'chef', 'cookbook', 'changelog.md.erb'), changelog_file, {:cookbook => name, :changelog => changelog})
|
32
|
-
end
|
33
|
-
else
|
34
|
-
thor.say_status("error", "No Changelog found for #{name}", :red)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def parse_changelog(file)
|
42
|
-
changelog = {}
|
43
|
-
lines = File.readlines(file)
|
44
|
-
current_version = nil
|
45
|
-
lines.each do |line|
|
46
|
-
if match = line.match(/^## (\d+.\d+.\d+):/)
|
47
|
-
current_version = version = match[1]
|
48
|
-
changelog[version] = []
|
49
|
-
elsif match = line.match(/^* (.+)$/)
|
50
|
-
entry = match[1]
|
51
|
-
if current_version
|
52
|
-
changelog[current_version] << entry
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
changelog
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|