Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 4 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
54 ohai/README.md
@@ -0,0 +1,54 @@
+Description
+===========
+
+Creates a configured plugin path for distributing custom Ohai plugins, and reloads them via Ohai within the context of a Chef Client run during the compile phase (if needed).
+
+Attributes
+==========
+
+`node['ohai']['plugin_path']` - location to drop off plugins directory, default is `/etc/chef/ohai_plugins`. This is not FHS-compliant, an FHS location would be something like `/var/lib/ohai/plugins`, or `/var/lib/chef/ohai_plugins` or similar.
+
+Neither an FHS location or the default value of this attribute are in the default Ohai plugin path. Set the Ohai plugin path with the config setting "`Ohai::Config[:plugin_path]`" in the Chef config file (the `chef::config` recipe does this automatically for you!). The attribute is not set to the default plugin path that Ohai ships with because we don't want to risk destroying existing essential plugins for Ohai.
+
+Usage
+=====
+
+Put the recipe `ohai` at the start of the node's run list to make sure that custom plugins are loaded early on in the Chef run and data is available for later recipes.
+
+The execution of the custom plugins occurs within the recipe during the compile phase, so you can write new plugins and use the data they return in your Chef recipes.
+
+For information on how to write custom plugins for Ohai, please see the Chef wiki pages.
+
+http://wiki.opscode.com/display/chef/Writing+Ohai+Plugins
+
+*PLEASE NOTE* - This recipe reloads the Ohai plugins a 2nd time during the Chef run if:
+
+* The "`Ohai::Config[:plugin_path]`" config setting has *NOT* been properly set in the Chef config file
+* The "`Ohai::Config[:plugin_path]`" config setting has been properly set in the Chef config file and there are updated plugins dropped off at "`node['ohai']['plugin_path']`".
+
+Changes
+=======
+
+## v1.0.2
+
+- [COOK-463] ohai cookbook default recipe should only reload plugins if there were updates
+
+License and Author
+==================
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: Seth Chisamore (<schisamo@opscode.com>)
+
+Copyright:: 2010-2011, Opscode, Inc
+
+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
21 ohai/attributes/default.rb
@@ -0,0 +1,21 @@
+#
+# Cookbook Name:: ohai
+# Attribute:: default
+#
+# Copyright 2010, Opscode, Inc
+#
+# 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.
+#
+
+# FHS location would be /var/lib/chef/ohai_plugins or similar.
+default["ohai"]["plugin_path"] = "/etc/chef/ohai_plugins"
View
1 ohai/files/default/plugins/README
@@ -0,0 +1 @@
+This directory contains custom plugins for Ohai.
View
5 ohai/files/default/plugins/easybib_php.rb
@@ -1,5 +0,0 @@
-provides 'easybib_php'
-
-easybib_php = Mash.new
-
-easybib_php[:hello] = "world"
View
51 ohai/files/default/plugins/php_easybib.rb
@@ -0,0 +1,51 @@
+provides "php_easybib"
+
+php_easybib Mash.new
+
+php_easybib[:php_bin] = `which php`.strip
+
+if not php_easybib[:php_bin].empty?
+ php_easybib[:pear_bin] = `which pear`.strip
+ php_easybib[:php_extensions] = []
+
+ extensions = `#{php_easybib[:php_bin]} -m`.strip.split("\n")
+ extensions.each do |line|
+ if line.empty? or line[0,1] == '['
+ next
+ end
+
+ php_easybib[:php_extensions].push(line)
+ end
+end
+
+if not php_easybib[:pear_bin].empty?
+
+ php_easybib[:pear] = {}
+ php_easybib[:pear][:bin_dir] = `#{php_easybib[:pear_bin]} config-get bin_dir`.strip
+ php_easybib[:pear][:php_dir] = `#{php_easybib[:pear_bin]} config-get php_dir`.strip
+
+ channel_out = `#{php_easybib[:pear_bin]} list-channels`.split("\n")
+
+ channel_out.shift
+ channel_out.shift
+ channel_out.shift
+ channel_out.pop
+
+ php_easybib[:pear_channels] = []
+
+ channel_out.each do |line|
+ if line[0,4].empty?
+ next
+ end
+
+ l = line.split
+ if l[0].nil? || l[1].nil? || l[0].empty? || l[1].empty?
+ next
+ end
+
+ php_easybib[:pear_channels].push({
+ :uri => l[0],
+ :alias => l[1]
+ })
+ end
+end
View
44 ohai/metadata.json
@@ -0,0 +1,44 @@
+{
+ "name": "ohai",
+ "description": "Distributes a directory of custom ohai plugins",
+ "long_description": "Description\n===========\n\nCreates a configured plugin path for distributing custom Ohai plugins, and reloads them via Ohai within the context of a Chef Client run during the compile phase (if needed).\n\nAttributes\n==========\n\n`node['ohai']['plugin_path']` - location to drop off plugins directory, default is `/etc/chef/ohai_plugins`. This is not FHS-compliant, an FHS location would be something like `/var/lib/ohai/plugins`, or `/var/lib/chef/ohai_plugins` or similar.\n\nNeither an FHS location or the default value of this attribute are in the default Ohai plugin path. Set the Ohai plugin path with the config setting \"`Ohai::Config[:plugin_path]`\" in the Chef config file (the `chef::config` recipe does this automatically for you!). The attribute is not set to the default plugin path that Ohai ships with because we don't want to risk destroying existing essential plugins for Ohai. \n\nUsage\n=====\n\nPut the recipe `ohai` at the start of the node's run list to make sure that custom plugins are loaded early on in the Chef run and data is available for later recipes.\n\nThe execution of the custom plugins occurs within the recipe during the compile phase, so you can write new plugins and use the data they return in your Chef recipes.\n\nFor information on how to write custom plugins for Ohai, please see the Chef wiki pages.\n\nhttp://wiki.opscode.com/display/chef/Writing+Ohai+Plugins\n\n*PLEASE NOTE* - This recipe reloads the Ohai plugins a 2nd time during the Chef run if:\n\n* The \"`Ohai::Config[:plugin_path]`\" config setting has *NOT* been properly set in the Chef config file\n* The \"`Ohai::Config[:plugin_path]`\" config setting has been properly set in the Chef config file and there are updated plugins dropped off at \"`node['ohai']['plugin_path']`\".\n\nChanges\n=======\n\n## v1.0.2\n\n- [COOK-463] ohai cookbook default recipe should only reload plugins if there were updates\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright:: 2010-2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "maintainer": "Opscode, Inc",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ },
+ "dependencies": {
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ "ohai/plugin_path": {
+ "display_name": "Ohai Plugin Path",
+ "description": "Distribute plugins to this path.",
+ "type": "string",
+ "required": "optional",
+ "default": "/etc/chef/ohai_plugins",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "recipes": [
+
+ ]
+ }
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "ohai::default": "Distributes a directory of custom ohai plugins"
+ },
+ "version": "1.0.2"
+}
View
15 ohai/metadata.rb
@@ -0,0 +1,15 @@
+maintainer "Opscode, Inc"
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Distributes a directory of custom ohai plugins"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "1.0.2"
+
+recipe "ohai::default", "Distributes a directory of custom ohai plugins"
+
+attribute "ohai/plugin_path",
+ :display_name => "Ohai Plugin Path",
+ :description => "Distribute plugins to this path.",
+ :type => "string",
+ :required => "optional",
+ :default => "/etc/chef/ohai_plugins"
View
43 ohai/recipes/default.rb
@@ -0,0 +1,43 @@
+#
+# Cookbook Name:: ohai
+# Recipe:: default
+#
+# Copyright 2011, Opscode, Inc
+#
+# 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.
+#
+
+Ohai::Config[:plugin_path] << node['ohai']['plugin_path']
+Chef::Log.info("ohai plugins will be at: #{node['ohai']['plugin_path']}")
+
+rd = remote_directory node['ohai']['plugin_path'] do
+ source 'plugins'
+ owner 'root'
+ group 'root'
+ mode 0755
+ recursive true
+ action :nothing
+end
+
+rd.run_action(:create)
+
+# only reload ohai if new plugins were dropped off OR
+# node['ohai']['plugin_path'] does not exists in client.rb
+if rd.updated? ||
+ !(::IO.read(Chef::Config[:config_file]) =~ /Ohai::Config\[:plugin_path\]\s*<<\s*["']#{node['ohai']['plugin_path']}["']/)
+
+ ohai 'custom_plugins' do
+ action :nothing
+ end.run_action(:reload)
+
+end
View
17 phpunit/recipes/default.rb
@@ -3,18 +3,25 @@
version = node[:phpunit][:version].split('.')
major = "#{version[0]}#{version[1]}"
+ohai "reload_php_easybib" do
+ action :reload
+ plugin "php_easybib"
+end
+
phpunit_location = "/usr/local/phpunit#{major}"
-pear_bin = `pear config-get bin_dir`.strip
-php_dir = `pear config-get php_dir`.strip
+Chef::Log.debug("HELLO: #{node[:php_easybib][:php_bin]}")
+
+pear = node[:php_easybib][:pear_bin]
+pear_bin = node[:php_easybib][:pear][:bin_dir]
+php_dir = node[:php_easybib][:pear][:php_dir]
execute "enable auto_discover" do
- command "pear config-set auto_discover 1"
+ command "#{pear} config-set auto_discover 1"
end
-# ignore failure to make multiple runs painless
execute "install PHPUnit #{node[:phpunit][:version]}" do
- command "pear install -o --installroot #{phpunit_location} pear.phpunit.de/PHPUnit-#{node[:phpunit][:version]}"
+ command "#{pear} install -o --installroot #{phpunit_location} pear.phpunit.de/PHPUnit-#{node[:phpunit][:version]}"
not_if do
File.exist?("#{phpunit_location}#{pear_bin}/phpunit")
end

No commit comments for this range

Something went wrong with that request. Please try again.