fhcap-cli 0.4.12 → 0.4.13

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -1
  3. data/lib/cookbooks/provision/recipes/cluster_bootstrap_instances.rb +2 -1
  4. data/lib/fhcap/cluster.rb +17 -2
  5. data/lib/fhcap/component.rb +2 -2
  6. data/lib/fhcap/config.rb +1 -1
  7. data/lib/fhcap/provider.rb +2 -1
  8. data/lib/fhcap/repos_helper.rb +7 -1
  9. data/lib/fhcap/tasks/chef/cookbook/update_artifact.rb +13 -1
  10. data/lib/fhcap/tasks/chef/cookbook/update_config.rb +5 -0
  11. data/lib/fhcap/tasks/chef/environments/update_attributes.rb +47 -0
  12. data/lib/fhcap/tasks/chef/server/info.rb +12 -2
  13. data/lib/fhcap/tasks/cluster/create_dns_records.rb +4 -3
  14. data/lib/fhcap/tasks/cluster/create_environment.rb +2 -2
  15. data/lib/fhcap/tasks/cluster/generate.rb +2 -1
  16. data/lib/fhcap/tasks/cluster/info.rb +36 -9
  17. data/lib/fhcap/tasks/cluster/update_environment_attributes.rb +19 -0
  18. data/lib/fhcap/tasks/knife/add.rb +1 -1
  19. data/lib/fhcap/tasks/knife/remove.rb +1 -1
  20. data/lib/fhcap/tasks/provider/add.rb +3 -1
  21. data/lib/fhcap/tasks/provider/remove.rb +1 -1
  22. data/lib/fhcap/tasks/repo/add.rb +1 -1
  23. data/lib/fhcap/tasks/repo/checkout.rb +2 -1
  24. data/lib/fhcap/tasks/repo/remove.rb +1 -1
  25. data/lib/fhcap/tasks/setup.rb +1 -1
  26. data/lib/fhcap/version.rb +1 -1
  27. data/lib/fhcap.rb +1 -1
  28. data/spec/fhcap/tasks/chef/cookbook/update_artifact_spec.rb +1 -1
  29. data/spec/fhcap/tasks/chef/environments/update_attributes_spec.rb +33 -0
  30. data/spec/fhcap/tasks/cluster/update_environment_attributes_spec.rb +40 -0
  31. data/spec/fhcap/tasks/provider/add_spec.rb +24 -0
  32. data/templates/chef/environment_core.json.erb +2 -2
  33. data/templates/chef/{environment_ose-multi-node.json.erb → environment_oscp.json.erb} +5 -1
  34. data/templates/chef/environment_ose-single.json.erb +3 -2
  35. data/templates/chef/environment_single.json.erb +3 -3
  36. data/templates/cluster/aws/common.json.erb +1 -0
  37. data/templates/cluster/aws/{ose-multi-node.json.erb → oscp-5node.json.erb} +78 -36
  38. data/templates/cluster/aws/oscp-7node.json.erb +352 -0
  39. data/templates/cluster/aws/ose-single.json.erb +1 -0
  40. data/templates/cluster/openstack/common.json.erb +2 -1
  41. data/templates/cluster/openstack/oscp-5node.json.erb +68 -0
  42. data/templates/cluster/openstack/oscp-7node.json.erb +91 -0
  43. data/templates/cluster/oscp-5node.json.erb +8 -0
  44. data/templates/cluster/oscp-7node.json.erb +8 -0
  45. data/templates/kitchen/kitchen.aws.yml.erb +4 -0
  46. metadata +15 -6
  47. data/templates/cluster/openstack/ose-multi-node.json.erb +0 -30
  48. data/templates/cluster/ose-multi-node.json.erb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 586e4b4984cbf2ee4847cfa59ca3a69bb7784345
4
- data.tar.gz: bb3fc51822d6289862e760de8251eea9abbb2689
3
+ metadata.gz: 78c7eb91b57300a3bde0b17a9e658c95daf0ae28
4
+ data.tar.gz: e53cae790a8184c7b0f3d39bc9b8b9f0196bd938
5
5
  SHA512:
6
- metadata.gz: ab9358a1d95772e4bc80f9b256da13a476c0b2075eb3b11dd90377d64645229a0808761d811f6562b68275b844cc231d74f4c476a162ff779c31ecdb62434742
7
- data.tar.gz: c7410c8d9b6ec940b8b130ffefbd1f7504961fe1f53ba7a5d6fdff1bd05d80aa29ccabdb6633a5a3e8aa10e1610f29bd9b2a1136d1bfa969392fdf6f604a031a
6
+ metadata.gz: 3642959bb379209b96a820250ea2aaf16d142d894ac195cb3ec9261cd79a25a791cb57b3b809d92335ad0e43ae45c55f9a8a959cf4ed98d48e01778f8768b229
7
+ data.tar.gz: e4343b8c5346771acb9386a1d192fe36ba5659c8126381e412e3af8429614ac7019398b9fd7951d1c7ab3b01c23a6f5271eccf3488f11afb249b5760737533d8
data/CHANGELOG.md CHANGED
@@ -1,8 +1,25 @@
1
1
 
2
2
  ## Unreleased
3
3
 
4
- ## 0.4.12
4
+ ## 0.4.13
5
+
6
+ * [RHMAP-15127] - Add meta only option to cluster info task
7
+ * [RHMAP-15112] - Update artifact update task to auto detect the 'component-versions' cookbook and use that if it exists and nothing is explicitly specified.
8
+ * [RHMAP-13830] - Replacing OSE Multi cluster template with OSCP 5 node and 7 node templates. The 7 node template includes dedicated infra nodes.
9
+ * [RHMAP-14881] - Set default version of openshift to 3.4 in openshift environment templates.
10
+ * [RHMAP-14896] - Adding json format option for cluster info task
11
+ * [RHMAP-14813] - Add more informative message to component config update command.
12
+ * [RHMAP-14831] - Updating Openshift DNS record creation queries to use role due to known issue with Chef Zero: https://github.com/chef/chef-zero/issues/54
13
+ * [RHMAP-14198] - Force the deletion of ebs volumes attached for the root device of AWS kitchen instances.
14
+ * [RHMAP-14664] - Add cluster update environment attributes method.
15
+ * [RHMAP-14351] - Add --provider-config option to provider add command.
16
+ * [RHMAP-14323] - Use config.config_file attribute to ensure we are reading/updating the correct file when we using a config other than the default via the FHCAP_CFG_FILE env var.
17
+ * [RHMAP-15050] - Use meh2 buildfarm by default
5
18
 
19
+ ## 0.4.12
20
+ * [RHMAP-14418] - Adding support VPN to aws common template.
21
+ * [RHMAP-14122] - Add ability to set chef attribute overrides within organisation files
22
+ * [RHMAP-14203] - Modify FHCAP AWS Openshift templates to use larger instance types.
6
23
  * [RHMAP-14106] - Add cookbook option to component update tasks. Allows updating the version of a component that isn't contained in a cookbook of the same name.
7
24
  * [RHMAP-13583] - Adding support for NFS server in Openshift Multi Node templates
8
25
  * [RHMAP-13133] - Add options to component update task that allow any stage to be skipped (artifact/config/cookbook update)
@@ -28,10 +28,11 @@ with_cluster_instances(node) do |cluster_instances|
28
28
  chef_environment chef_environment
29
29
  machine_options cfg[:machine_options]
30
30
  run_list cfg[:instance_config][:run_list]
31
+ attributes cfg[:instance_config][:chef_attributes]
31
32
  end
32
33
  end
33
34
  end
34
35
  max_simultaneous node['max_simultaneous']
35
36
  action :setup
36
37
  end
37
- end
38
+ end
data/lib/fhcap/cluster.rb CHANGED
@@ -130,7 +130,8 @@ module Fhcap
130
130
 
131
131
  method_option 'name', :type => :string, :required => true, :desc => "Cluster name"
132
132
  method_option 'launch', :type => :boolean, :default => false, :desc => "Launch all urls in the browser"
133
- method_option 'only', :type => :string, :desc => "", :enum => %w{ips urls passwords}
133
+ method_option 'only', :type => :string, :desc => "", :enum => %w{ips urls passwords meta}
134
+ method_option 'format', :type => :string, :desc => "Format to output data in", :enum => %w{json}
134
135
 
135
136
  def info
136
137
  require "fhcap/tasks/cluster/info"
@@ -187,6 +188,20 @@ module Fhcap
187
188
  Tasks::Cluster::BootstrapServer.new(task_options(options.dup)).run
188
189
  end
189
190
 
191
+
192
+ desc "update_environment_attributes", "[ADVANCED USAGE] Update environment attributes"
193
+
194
+ shared_options :verbose
195
+
196
+ method_option 'name', :type => :string, :required => true, :desc => 'Cluster name'
197
+ method_option :attributes, :type => :hash, :required => true, :desc => 'Chef Attributes'
198
+ method_option :type, :type => :string, :required => true, :default => 'default', :desc => 'Chef Attributes', :enum => %w{default override}
199
+
200
+ def update_environment_attributes
201
+ require 'fhcap/tasks/cluster/update_environment_attributes'
202
+ Tasks::Cluster::UpdateEnvironmentAttributes.new(task_options(options.dup)).run
203
+ end
204
+
190
205
  end
191
206
  end
192
- end
207
+ end
@@ -22,10 +22,10 @@ module Fhcap
22
22
 
23
23
  artifact_cookbook = options[:cookbook] || component
24
24
  #1. Update artifact version
25
- Fhcap::CLI::Component.new.invoke(:update_artifact, [component, version, build], {cookbook: artifact_cookbook, interactive: options[:interactive]}) if options['update-artifact']
25
+ Fhcap::CLI::Component.new.invoke(:update_artifact, [component, version, build], {cookbook: options[:cookbook], interactive: options[:interactive]}) if options['update-artifact']
26
26
 
27
27
  #2. Update config
28
- Fhcap::CLI::Component.new.invoke(:update_config, [artifact_cookbook], {force: options[:force]}) if options['update-config']
28
+ Fhcap::CLI::Component.new.invoke(:update_config, [component], {force: options[:force]}) if options['update-config']
29
29
 
30
30
  #3. Update cookbook
31
31
  Fhcap::CLI::Cookbook.new.invoke(:update, [], {cookbooks: [artifact_cookbook], level: options['level']}) if options['update-cookbook']
data/lib/fhcap/config.rb CHANGED
@@ -64,7 +64,7 @@ module Fhcap
64
64
  end
65
65
 
66
66
  def fhcap_cookbook_archive_url
67
- 'https://s3-eu-west-1.amazonaws.com/fhcap/fhcap-cookbooks-0fa68747b476f7ee555a94483877969a30133e76.tgz'
67
+ 'https://s3-eu-west-1.amazonaws.com/fhcap/fhcap-cookbooks/fhcap-cookbooks-39c5f7b38bb69ccf9fbd367b39a777b83f15d1de.tgz'
68
68
  end
69
69
 
70
70
  # Generates the immutable fhcap configuration and reasonable defaults.
@@ -10,10 +10,11 @@ module Fhcap
10
10
  add_shared_option :name, :type => :string, :required => true, :desc => "Provider Name"
11
11
  add_shared_option :type, :type => :string, :required => true, :desc => "Provider Type", :enum => %w{aws openstack dnsmadeeasy}
12
12
  add_shared_option :credentials, :type => :hash, :desc => "Provider specific credentials"
13
+ add_shared_option :'provider-config', :type => :hash, :desc => "Provider specific config"
13
14
 
14
15
  desc "add", "Add a provider"
15
16
 
16
- shared_options :verbose, :name, :type, :credentials, :interactive
17
+ shared_options :verbose, :name, :type, :credentials, :interactive, :'provider-config'
17
18
 
18
19
  def add
19
20
  require "fhcap/tasks/provider/add"
@@ -175,7 +175,7 @@ module Fhcap
175
175
 
176
176
  def modified?(path, since='origin/master')
177
177
  stat = Dir.chdir(path) do
178
- `git diff #{since}...HEAD -- #{path}`
178
+ `git diff #{since} -- #{path}`
179
179
  end
180
180
  !stat.empty?
181
181
  end
@@ -187,6 +187,12 @@ module Fhcap
187
187
  !stat.empty?
188
188
  end
189
189
 
190
+ def git_diff(file, options='--shortstat')
191
+ Dir.chdir(File.dirname(file)) do
192
+ `git diff #{options} #{file}`
193
+ end
194
+ end
195
+
190
196
  private
191
197
 
192
198
  def cookbook_loader(paths=repo_cookbook_paths)
@@ -11,12 +11,13 @@ module Fhcap
11
11
  def initialize(options)
12
12
  super
13
13
  @name = options[:component]
14
- @cookbook = options[:cookbook] || @name
14
+ @cookbook = options[:cookbook]
15
15
  @version = options[:version]
16
16
  @build = options[:build]
17
17
  end
18
18
 
19
19
  def run
20
+ @cookbook = version_cookbook(options)
20
21
  thor.say "Chef::Cookbook::UpdateArtifact name = #{name}, cookbook = #{cookbook}, version = #{version}, build = #{build}", :yellow
21
22
  c = cookbook_loader.cookbooks_by_name[cookbook]
22
23
  unless c
@@ -36,6 +37,17 @@ module Fhcap
36
37
 
37
38
  end
38
39
 
40
+ private
41
+
42
+ def version_cookbook(options)
43
+ options[:cookbook] || component_versions_cookbook || options[:component]
44
+ end
45
+
46
+ def component_versions_cookbook
47
+ c = cookbook_loader.cookbooks_by_name['component-versions']
48
+ c ? c.name : nil
49
+ end
50
+
39
51
  end
40
52
  end
41
53
  end
@@ -64,6 +64,11 @@ module Fhcap
64
64
  cfg.from_attributes_file(name, conf_attr_file)
65
65
  cfg.from_file(file, force, overrides)
66
66
  thor.create_file(conf_attr_file, cfg.attribute_file_content(name, sort), {force: force})
67
+ if is_dirty?(conf_attr_file)
68
+ thor.say "Updated #{name} config: #{git_diff(conf_attr_file)}"
69
+ else
70
+ thor.say "No config changes for #{name}"
71
+ end
67
72
  else
68
73
  thor.say "Missing local file '#{file}', skipping config update"
69
74
  end
@@ -0,0 +1,47 @@
1
+ require 'fhcap/tasks/chef/chef_task_base'
2
+ require 'deep_merge'
3
+
4
+ module Fhcap
5
+ module Tasks
6
+ module Chef
7
+ module Environments
8
+ class UpdateAttributes < ChefTaskBase
9
+
10
+ attr_reader :environment, :attributes, :type
11
+
12
+ def initialize(options)
13
+ super
14
+ @environment = options[:environment]
15
+ @attributes = options[:attributes]
16
+ @type = options[:type] || 'default'
17
+ end
18
+
19
+ def run
20
+ thor.say "Chef::Environments::UpdateAttributes: environment = #{environment}", :yellow
21
+ if environment.empty?
22
+ exit_with_error("You must specify an environment")
23
+ else
24
+ environment_filepath = find_environment(environment)
25
+ if environment_filepath
26
+ environment_data = JSON.parse(IO.read(environment_filepath))
27
+
28
+ env_attributes = environment_data["#{type}_attributes"]
29
+
30
+ attributes.each do |key,value|
31
+ keys = key.to_s.split('.')
32
+ h = keys.reverse.inject(value) { |a, n| { n => a } }
33
+ env_attributes.deep_merge!(h)
34
+ end
35
+
36
+ thor.create_file(environment_filepath, JSON.pretty_generate(environment_data) + "\n", :force => true)
37
+ else
38
+ thor.say "Unknown environment #{environment}", :red
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -6,7 +6,7 @@ module Fhcap
6
6
  module Server
7
7
  class Info < ChefServerTask
8
8
 
9
- attr_reader :environments, :node_names, :roles, :urls
9
+ attr_reader :environments, :node_names, :roles, :urls, :cluster_data
10
10
 
11
11
  def initialize(options)
12
12
  super
@@ -14,6 +14,7 @@ module Fhcap
14
14
  @node_names = options[:nodes]
15
15
  @roles = options[:roles]
16
16
  @urls = {}
17
+ @cluster_data = {}
17
18
  end
18
19
 
19
20
  def run
@@ -30,15 +31,20 @@ module Fhcap
30
31
 
31
32
  def ip_addresses(env)
32
33
  thor.say "[#{env}] IP Addresses", :green
34
+ cluster_data[env] = {} unless cluster_data[env]
33
35
  search_cmd = "search 'chef_environment:#{env}'"
34
36
  search_options = '-a cloud.public_ips'
37
+ cluster_data[env][:nodes] = []
35
38
  nodes_for(search_cmd, search_options) do |node|
39
+ cluster_data[env][:nodes] << node
36
40
  thor.say_status "[#{env}] #{node['name']}:", node['cloud.public_ips'].join(','), :cyan
37
41
  end
38
42
  end
39
43
 
40
44
  def management_dashboards(env)
41
45
  thor.say "[#{env}] Monitoring Dashboards", :green
46
+ cluster_data[env] = {} unless cluster_data[env]
47
+ cluster_data[env][:urls] = []
42
48
  urls[env] = {} unless urls[env]
43
49
  search_cmd = "search 'chef_environment:#{env} AND roles:management_server'"
44
50
  search_options = '-a cloud.public_ips -a munin.web_server_port -a nagios.http_port'
@@ -65,6 +71,10 @@ module Fhcap
65
71
  thor.say_status "[#{env}] OpenShift Console:", "#{urls[env][:ose_master]}", :cyan
66
72
  end
67
73
 
74
+ urls[env].each do |service, url|
75
+ cluster_data[env][:urls] << {service => url}
76
+ end
77
+
68
78
  end
69
79
 
70
80
  def nodes_for(search_cmd, search_options)
@@ -88,4 +98,4 @@ module Fhcap
88
98
  end
89
99
  end
90
100
  end
91
- end
101
+ end
@@ -78,9 +78,10 @@ module Fhcap
78
78
 
79
79
  def create_records_openshift
80
80
  #This is a very basic openshift DNS setup and does not take into account a HA setup or LBs
81
+ #Setting query to use role (rather than roles) due to known issue with Chef Zero: https://github.com/chef/chef-zero/issues/54
81
82
  cluster_config[:environments].each do |env_name, env_cfg|
82
- create_records_for_query(env_name, env_cfg, "roles:ose_master_server", [""])
83
- create_records_for_query(env_name, env_cfg, "roles:ose_node_server", ["*"]) unless env_cfg[:load_balancers]
83
+ create_records_for_query(env_name, env_cfg, "role:ose_master_server", [""])
84
+ create_records_for_query(env_name, env_cfg, "role:ose_node_server", ["*"]) unless env_cfg[:load_balancers]
84
85
  end
85
86
  end
86
87
 
@@ -105,7 +106,7 @@ module Fhcap
105
106
  Dns::CreateRecord.new(@options.dup.merge(dns_record_cfg)).run
106
107
  end
107
108
  else
108
- thor.say "Found query node '#{query_node['name']}', but was unable to retrieve it's IP!!}"
109
+ thor.say "Found query node '#{query_node['name']}', but was unable to retrieve it's IP!!"
109
110
  end
110
111
  else
111
112
  thor.say "Unable to locate node for query '#{query}' in cluster!!"
@@ -160,8 +160,8 @@ module Fhcap
160
160
  'mbaas'
161
161
  when /ose-single/
162
162
  'ose-single'
163
- when /ose-multi-node/
164
- 'ose-multi-node'
163
+ when /oscp/
164
+ 'oscp'
165
165
  when /single/
166
166
  'single'
167
167
  when /farm/
@@ -113,7 +113,8 @@ module Fhcap
113
113
 
114
114
  def generate_machine_options
115
115
  cluster_config[:machine_options] = cluster_config[:machine_options] || {}
116
- cluster_config[:machine_options][:ssh_username] = cluster_config[:provider_config][:ssh_username] || 'ubuntu'
116
+ default_provider_conf = provider_config(@cluster_config[:provider_id])
117
+ cluster_config[:machine_options][:ssh_username] = cluster_config[:provider_config][:ssh_username] || default_provider_conf[:ssh_username]
117
118
  cluster_config[:machine_options][:convergence_options] = cluster_config[:machine_options][:convergence_options] || {}
118
119
  cluster_config[:machine_options][:convergence_options][:chef_version] = "12.6.0"
119
120
  cluster_config[:machine_options][:convergence_options][:ssl_verify_mode] = "verify_none"
@@ -7,11 +7,12 @@ module Fhcap
7
7
  module Cluster
8
8
  class Info < ClusterTaskBase
9
9
 
10
- attr_reader :launch, :cluster_pwds_file, :cluster_passwords
10
+ attr_reader :launch, :cluster_pwds_file, :cluster_passwords, :format
11
11
 
12
12
  def initialize(options)
13
13
  super
14
14
  @launch = options[:launch]
15
+ @format = options[:format]
15
16
  unless @cluster_passwords
16
17
  @cluster_passwords = {}
17
18
  cluster_environments.each do |env|
@@ -25,14 +26,33 @@ module Fhcap
25
26
  end
26
27
 
27
28
  def run
28
- thor.say "Cluster::Info: name = #{@name}", :yellow
29
- info_task = Chef::Server::Info.new(@options.dup.merge({:environments => cluster_environments}.merge(chef_task_options)))
30
- info_task.run
31
- cluster_environments.each do |env|
32
- passwords(env) unless options[:only] && options[:only] != 'passwords'
29
+ suppress_stdout(print_json?) do
30
+ thor.say "Cluster::Info: name = #{@name}", :yellow
31
+ @cluster_data = {
32
+ meta: {
33
+ name: @name,
34
+ template: cluster_config[:template],
35
+ driver: cluster_config[:driver],
36
+ domain: cluster_config[:domain],
37
+ repo: cluster_config[:repo],
38
+ chef_server: cluster_config[:chef_server],
39
+ provider_id: cluster_config[:provider_id],
40
+ file: cluster_file
41
+ }
42
+ }
43
+
44
+ unless options[:only] && ([options[:only]] & %w{ips urls passwords}).empty?
45
+ info_task = Chef::Server::Info.new(@options.dup.merge({:environments => cluster_environments}.merge(chef_task_options)))
46
+ info_task.run
47
+ @cluster_data[:environments] = info_task.cluster_data
48
+ cluster_environments.each do |env|
49
+ passwords(env, @cluster_data)
50
+ end unless options[:only] && options[:only] != 'passwords'
51
+ end
52
+
33
53
  end
34
54
 
35
- if launch
55
+ if launch && !print_json?
36
56
  info_task.urls.each do |env, urls|
37
57
  urls.each do |service, url|
38
58
  service = service.to_s
@@ -50,18 +70,25 @@ module Fhcap
50
70
  end
51
71
  end
52
72
 
73
+ thor.say JSON.pretty_generate(@cluster_data) if print_json?
53
74
  end
54
75
 
55
76
  private
56
77
 
57
- def passwords(env)
78
+ def passwords(env, cluster_data)
58
79
  thor.say "[#{env}] Passwords", :green
80
+ cluster_data[:environments][env][:passwords] = []
59
81
  cluster_passwords[env.to_sym].each do |user, pwd|
82
+ cluster_data[:environments][env][:passwords] << {user => pwd}
60
83
  thor.say_status "[#{env}] #{user}:", "#{pwd}", :cyan
61
84
  end
62
85
  end
63
86
 
87
+ def print_json?
88
+ @format == 'json'
89
+ end
90
+
64
91
  end
65
92
  end
66
93
  end
67
- end
94
+ end
@@ -0,0 +1,19 @@
1
+ require 'fhcap/tasks/cluster/cluster_task_base'
2
+ require 'fhcap/tasks/chef/environments/update_attributes'
3
+
4
+ module Fhcap
5
+ module Tasks
6
+ module Cluster
7
+ class UpdateEnvironmentAttributes < ClusterTaskBase
8
+
9
+ def run
10
+ thor.say "Cluster::UpdateEnvironmentAttributes: name = #{name}", :yellow
11
+ cluster_environments.each() do |environment|
12
+ Chef::Environments::UpdateAttributes.new(@options.dup.merge({:environment => environment})).run
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -45,7 +45,7 @@ module Fhcap
45
45
 
46
46
  config[:knife][name.to_sym] = @knife_config
47
47
 
48
- thor.create_file(config.default_config_file, JSON.pretty_generate(config.data), :force => true)
48
+ thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
49
49
  config.reload
50
50
  create_knife_config
51
51
  end
@@ -16,7 +16,7 @@ module Fhcap
16
16
  thor.say "Knife::Remove: name = #{name}", :yellow
17
17
  if thor.yes? "Remove knife #{name}? (y/n)"
18
18
  config[:knife].delete(name.to_sym)
19
- thor.create_file(config.default_config_file, JSON.pretty_generate(config.data), :force => true)
19
+ thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
20
20
  config.reload
21
21
  if thor.yes?("Remove local knife config? (y/n)")
22
22
  remove_knife_config
@@ -14,6 +14,7 @@ module Fhcap
14
14
 
15
15
  def initialize(options)
16
16
  super
17
+ @options_provider_config = options[:'provider-config'] || {}
17
18
  @name = options[:name]
18
19
  @type = options[:type]
19
20
  @credentials = options[:credentials] || {}
@@ -34,6 +35,7 @@ module Fhcap
34
35
  config[:providers][type.to_sym][name.to_sym] = {} unless config[:providers][type.to_sym][name.to_sym]
35
36
 
36
37
  @provider_config = config[:providers][type.to_sym][name.to_sym]
38
+ @provider_config.merge!(@options_provider_config)
37
39
  @provider_config[:provides] = [] unless @provider_config[:provides]
38
40
  @provider_config[:credentials] = {} unless @provider_config[:credentials]
39
41
  @provider_config[:credentials].merge!(credentials)
@@ -47,7 +49,7 @@ module Fhcap
47
49
 
48
50
  send(:"#{type}_config", @provider_config)
49
51
 
50
- thor.create_file(config.default_config_file, JSON.pretty_generate(config.data), :force => true)
52
+ thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
51
53
  config.reload
52
54
  end
53
55
 
@@ -17,7 +17,7 @@ module Fhcap
17
17
  thor.say "Provider::Remove: name = #{name}", :yellow
18
18
  if thor.yes? "Remove provider #{name}? (y/n)"
19
19
  config[:providers][type.to_sym].delete(name.to_sym)
20
- thor.create_file(config.default_config_file, JSON.pretty_generate(config.data), :force => true)
20
+ thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
21
21
  config.reload
22
22
  end
23
23
  end
@@ -34,7 +34,7 @@ module Fhcap
34
34
  end
35
35
 
36
36
  config[:repos][name.to_sym] = repo_config
37
- thor.create_file(config.default_config_file, JSON.pretty_generate(config.data), :force => true)
37
+ thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
38
38
  config.reload
39
39
  Checkout.new(@options.dup.merge({:repo => name, :'git-ref' => 'master'})).run
40
40
  Tasks::Setup.new(@options).run unless @skip_setup
@@ -139,8 +139,9 @@ module Fhcap
139
139
  open(filename, 'wb') do |file|
140
140
  file << open(url).read
141
141
  end
142
- cmd = "tar xf #{filename} -C #{repo_dir}"
142
+ cmd = "tar xf #{filename} --warning=no-timestamp -C #{repo_dir}"
143
143
  run_inside_repo_dir(repo_dir, cmd)
144
+ run_inside_repo_dir(repo_dir, "rm -f #{filename}")
144
145
  end
145
146
  end
146
147
  end
@@ -22,7 +22,7 @@ module Fhcap
22
22
  thor.remove_file repo_dir
23
23
  end
24
24
  config[:repos].delete(name.to_sym)
25
- thor.create_file(config.default_config_file, JSON.pretty_generate(config.data), :force => true)
25
+ thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
26
26
  config.reload
27
27
  Tasks::Setup.new(@options).run unless @skip_setup
28
28
  end
@@ -41,7 +41,7 @@ module Fhcap
41
41
  end
42
42
 
43
43
  def create_fhcap_config
44
- thor.create_file(config.default_config_file, JSON.pretty_generate(@fhcap_config))
44
+ thor.create_file(config.config_file, JSON.pretty_generate(@fhcap_config))
45
45
  config.reload
46
46
  end
47
47
 
data/lib/fhcap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fhcap
2
- VERSION = "0.4.12"
2
+ VERSION = "0.4.13"
3
3
  end
data/lib/fhcap.rb CHANGED
@@ -3,7 +3,7 @@ require "pathname"
3
3
 
4
4
  module Fhcap
5
5
  GEM_DIR = File.expand_path '..', File.dirname(__FILE__)
6
- TEMPLATE_NAMES = %w{single core-3node mbaas-3node core-mbaas-6node core-small-9node nginx-test single-blank farm-3node farm-5node farm-single ose-single ose-multi-node}.sort
6
+ TEMPLATE_NAMES = %w{single core-3node mbaas-3node core-mbaas-6node core-small-9node nginx-test single-blank farm-3node farm-5node farm-single ose-single oscp-5node oscp-7node}.sort
7
7
 
8
8
  class << self
9
9
  def source_root
@@ -29,7 +29,7 @@ describe Fhcap::Tasks::Chef::Cookbook::UpdateArtifact do
29
29
 
30
30
  describe "#initialize" do
31
31
  specify { expect(subject.name).to eq('testname') }
32
- specify { expect(subject.cookbook).to eq('testname') }
32
+ specify { expect(subject.cookbook).to eq(nil) }
33
33
  specify { expect(subject.version).to eq('9.9.9') }
34
34
  specify { expect(subject.build).to eq('999') }
35
35
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require "fhcap/tasks/chef/environments/update_attributes"
3
+
4
+ describe Fhcap::Tasks::Chef::Environments::UpdateAttributes do
5
+
6
+ subject {
7
+ Fhcap::Tasks::Chef::Environments::UpdateAttributes.new(options)
8
+ }
9
+
10
+ let(:thor) do
11
+ DummyThor.new
12
+ end
13
+
14
+ let(:config) do
15
+ {}
16
+ end
17
+
18
+ let(:options) do
19
+ {
20
+ :config => config,
21
+ :thor => thor,
22
+ :environment => 'testenv',
23
+ :attributes => {:attr1 => 'val1'}
24
+ }
25
+ end
26
+
27
+ describe "#initialize" do
28
+ specify { expect(subject.environment).to eq('testenv') }
29
+ specify { expect(subject.attributes).to eq({:attr1 => 'val1'}) }
30
+ specify { expect(subject.type).to eq('default') }
31
+ end
32
+
33
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require "fhcap/tasks/cluster/update_environment_attributes"
3
+
4
+ describe Fhcap::Tasks::Cluster::UpdateEnvironmentAttributes do
5
+
6
+ subject {
7
+ Fhcap::Tasks::Cluster::UpdateEnvironmentAttributes.new(options)
8
+ }
9
+
10
+ let(:thor) do
11
+ DummyThor.new
12
+ end
13
+
14
+ let(:config) do
15
+ DummyConfig.new
16
+ end
17
+
18
+ let(:options) do
19
+ {
20
+ :config => config,
21
+ :thor => thor,
22
+ :name => 'testcluster',
23
+ :attributes => {},
24
+ :type => 'default',
25
+ :'cluster-config' => {
26
+ :id => 'testcluster',
27
+ :repo => 'testrepo',
28
+ :template => 'template',
29
+ :domain => 'testdomain',
30
+ :chef_server => 'test',
31
+ :provider_id => 'test'
32
+ }
33
+ }
34
+ end
35
+
36
+ describe "#initialize" do
37
+ specify { expect(subject.name).to eq(options[:name]) }
38
+ end
39
+
40
+ end