foreman_chef 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6796ab6f6a1582885cb7501e0a21f1b13d494a8a
4
- data.tar.gz: ab358480f7a3e94647b4cd9faed9799229968bb0
3
+ metadata.gz: 34baa9fbd879b204ef8fd14c6bc7b10718a0325c
4
+ data.tar.gz: 09983b5418b094d2821a7d51fb43bac42a53291e
5
5
  SHA512:
6
- metadata.gz: 7d5a31b0b6cf7ff354f00d037407d58ae24e4f670fe8bf813f3c1ad88ec71393e33704fa37e75639cee30473314c1ecb4c227a8e5fb1e5fa36103116856bc66b
7
- data.tar.gz: 510e7db1c35c2499bc185838acb178ff678cb9b869ff6517de3e7202ddac7fbc243a847e05e8d90c9f4a46385e1643d118b356f7f8dde67bb80dfb7d82b738d5
6
+ metadata.gz: 046f7031449f7bf4724d463d4986604bcd844dc7df446ea09f30ce9a4d50bedf6a0418f217f18c376167fdaa71553c96332961d154ace1e3d846e6befe574abf
7
+ data.tar.gz: 241ecedcb2ee2d5df74cc6e4af89a36c8d7fccdee8de3c16f7020b680d61bf450f0925aa80dfdce8ee2daf8fd163d77bf626a2614cbe208dce875aab97e02941
data/README.md CHANGED
@@ -1,29 +1,27 @@
1
1
  # ForemanChef
2
2
 
3
- This plugin adds a Chef fact importer to Foreman. It basically means that when you setup your chef
4
- clients to use foreman handlers (https://github.com/theforeman/chef-handler-foreman) and install
5
- this plugin you receive nested facts from chef-client.
3
+ This plugin adds a Chef support to Foreman. You can find all information
4
+ [in the plugin manual](http://www.theforeman.org/plugins/foreman_chef/0.2)
6
5
 
7
6
  # Installation
8
7
 
9
- If you want to use this in production I recommend to combine this plugin with foreman-background
10
- (https://github.com/ohadlevy/foreman-background) which runs report and facts import as a background
11
- tasks.
8
+ There are two ways to install the plugin:
12
9
 
13
10
  ## Foreman Installer (recommended)
14
11
 
15
- Follow the directions on: http://www.theforeman.org/plugins/foreman_chef/0.1/#2.Installation
12
+ Follow the instructions on: http://www.theforeman.org/plugins/foreman_chef/0.2/#2.Installation
16
13
 
17
14
  ## Manual
18
15
 
19
- This plugin expects foreman to support nested facts which is was added in 1.4.
20
16
  To install this plugin you just have to add this line to your Gemfile.
21
17
 
22
18
  ```ruby
23
19
  gem 'foreman_chef'
24
20
  ```
25
21
 
26
- and run ```bundle install```. Don't forget to restart foreman after this change.
22
+ and run ```bundle install```. Don't forget to restart foreman after this change. You also have
23
+ to run migrations and seed. Note that this plugin requires also plugin on smart proxy and chef-handler-foreman
24
+ on client side.
27
25
 
28
26
  ## License
29
27
 
@@ -11,8 +11,7 @@ module Actions
11
11
  end
12
12
  end
13
13
  rescue => e
14
- Rails.logger.debug "Unable to communicate with Chef proxy, #{e.message}"
15
- Rails.logger.debug e.backtrace.join("\n")
14
+ Foreman::Logging.exception('Unable to communicate with Chef proxy', e)
16
15
  raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
17
16
  end
18
17
 
@@ -16,8 +16,7 @@ module Actions
16
16
  plan_action Actions::ForemanChef::Client::Destroy, host.name, proxy
17
17
  end
18
18
  rescue => e
19
- Rails.logger.debug "Unable to communicate with Chef proxy, #{e.message}"
20
- Rails.logger.debug e.backtrace.join("\n")
19
+ Foreman::Logging.exception('Unable to communicate with Chef proxy', e)
21
20
  raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
22
21
  end
23
22
 
@@ -18,6 +18,10 @@ module ForemanChef
18
18
 
19
19
  attr_accessor :original_facts
20
20
 
21
+ def logger
22
+ Foreman::Logging.logger('foreman_chef')
23
+ end
24
+
21
25
  def add_new_facts
22
26
  @counters[:added] = 0
23
27
  add_missing_facts(Sparser.new.unsparse(original_facts))
@@ -12,8 +12,14 @@ module ForemanChef
12
12
  else
13
13
  major, minor = release.split('.')
14
14
  end
15
- description = facts['lsb::description']
16
- release_name = facts['lsb::codename']
15
+
16
+ if facts['platform'] == 'windows'
17
+ release_name = facts['kernel::name']
18
+ os_name = os_name.capitalize
19
+ else
20
+ description = facts['lsb::description']
21
+ release_name = facts['lsb::codename']
22
+ end
17
23
 
18
24
  begin
19
25
  klass = os_name.constantize
@@ -23,7 +29,7 @@ module ForemanChef
23
29
  end
24
30
 
25
31
  args = { :name => os_name, :major => major.to_s, :minor => minor.to_s }
26
- klass.where(args).first || klass.new(args.merge(:description => description, :release_name => release_name)).save!
32
+ klass.where(args).first || klass.new(args.merge(:description => description, :release_name => release_name)).tap(&:save!)
27
33
  end
28
34
 
29
35
  def environment
@@ -71,6 +77,10 @@ module ForemanChef
71
77
 
72
78
  private
73
79
 
80
+ def logger
81
+ Foreman::Logging.logger('foreman_chef')
82
+ end
83
+
74
84
  # meant to be implemented in inheriting classes
75
85
  # should return hash with indifferent access in following format:
76
86
  # { 'link': 'true',
@@ -7,7 +7,7 @@ module ForemanChef
7
7
  reply = ProxyAPI::ForemanChef::ChefProxy.new(:url => url).show_node(fqdn)
8
8
  JSON.parse(reply)
9
9
  rescue RestClient::ResourceNotFound
10
- logger.debug "Node '#{fqdn}' not found"
10
+ Foreman::Logging.logger('foreman_chef').debug "Node '#{fqdn}' not found"
11
11
  return false
12
12
  end
13
13
 
@@ -23,7 +23,7 @@ module ForemanChef
23
23
  reply = ProxyAPI::ForemanChef::ChefProxy.new(:url => url).show_client(fqdn)
24
24
  JSON.parse(reply)
25
25
  rescue RestClient::ResourceNotFound
26
- logger.debug "Client '#{fqdn}' not found"
26
+ Foreman::Logging.logger('foreman_chef').debug "Client '#{fqdn}' not found"
27
27
  return false
28
28
  end
29
29
 
data/db/seeds.rb CHANGED
@@ -11,7 +11,7 @@ templates = [
11
11
 
12
12
  templates.each do |template|
13
13
  template[:template] = File.read(File.join(ForemanChef::Engine.root, "app/views/foreman/unattended", template.delete(:source)))
14
- ConfigTemplate.find_or_create_by_name(template).update_attributes(defaults.merge(template))
14
+ ProvisioningTemplate.find_or_create_by_name(template).update_attributes(defaults.merge(template))
15
15
  end
16
16
 
17
17
  # Global parameters used in configuration snippets
@@ -26,7 +26,7 @@ module ForemanChef
26
26
 
27
27
  initializer 'foreman_chef.register_plugin', :after => :finisher_hook do |app|
28
28
  Foreman::Plugin.register :foreman_chef do
29
- requires_foreman '>= 1.4'
29
+ requires_foreman '>= 1.9'
30
30
  allowed_template_helpers :chef_bootstrap
31
31
  end
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanChef
2
- VERSION = "0.1.7"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Hulan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails