add property lwrp

This commit is contained in:
Robert 2013-05-27 12:12:49 +09:00
parent ae33695e4a
commit 08b4a74c90
4 changed files with 78 additions and 0 deletions

View File

@ -77,3 +77,5 @@ default['pacemaker']['colocation']['c-cinder-volume']['active'] = "#{pacemaker['
default['pacemaker']['order']['o-lvm']['priority'] = "inf"
default['pacemaker']['order']['o-lvm']['resources'] = ['drbd-cluster', 'clvm-clone', 'vip', 'cinder-volume']
default['pacemaker']['order']['o-lvm']['active'] = "#{pacemaker['nodes']}"
default['pacemaker']['property']['no-quorum-policy'] = "ignore"

44
providers/property.rb Normal file
View File

@ -0,0 +1,44 @@
# Author:: Robert Choi
# Cookbook Name:: pacemaker
# Provider:: property
#
# Copyright:: 2013, Robert Choi
#
# 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.
#
require ::File.join(::File.dirname(__FILE__), 'helper')
action :create do
name = new_resource.name
val = new_resource.value
unless resource_exists?(name)
cmd = "crm configure property #{name}=#{val}"
cmd_ = Mixlib::ShellOut.new(cmd)
cmd_.environment['HOME'] = ENV.fetch('HOME', '/root')
cmd_.run_command
begin
cmd_.error!
if resource_exists?(name)
new_resource.updated_by_last_action(true)
Chef::Log.info "Successfully configured property '#{name}'."
else
Chef::Log.error "Failed to configure property #{name}."
end
rescue
Chef::Log.error "Failed to configure property #{name}."
end
end
end

View File

@ -106,3 +106,10 @@ node['pacemaker']['order'].each do |name, attr|
only_if { attr['active'].include?(node.name.partition(".")[0]) }
end
end
node['pacemaker']['property'].each do |name, val|
pacemaker_property name do
value val
action :create
end
end

25
resources/property.rb Normal file
View File

@ -0,0 +1,25 @@
# Author:: Robert Choi
# Cookbook Name:: pacemaker
# Resource:: property
#
# Copyright:: 2013, Robert Choi
#
# 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.
#
actions :create
default_action :create
attribute :name, :kind_of => String, :name_attribute => true
attribute :value, :kind_of => String