Commit c696b7d2 authored by Tim Smith's avatar Tim Smith
Browse files

Convert the LWRP to a 12.5 custom_resource

Use compat_resource for compatibility with all 12.X releases
parent 40a2301e
......@@ -15,10 +15,10 @@ Requirements
- OmniOS r151006c
#### Chef
- Chef 11+
- Chef 12+
#### Cookbooks
- none
- compat_resource
#### Other
To use the `recipe[rsyslog::client]` recipe, you'll need to set up the `rsyslog.server_search` or `rsyslog.server_ip` attributes. See the __Recipes__ and __Examples__ sections below.
......
......@@ -11,15 +11,5 @@ module RsyslogCookbook
end
service_provider
end
def declare_rsyslog_service
service_provider = 'ubuntu' == node['platform'] ? find_provider : nil
service node['rsyslog']['service_name'] do
supports restart: true, status: true
action [:enable, :start]
provider service_provider
end
end
end
end
......@@ -19,6 +19,8 @@ supports 'scientific'
supports 'amazon'
supports 'oracle'
depends 'compat_resource'
source_url 'https://github.com/chef-cookbooks/rsyslog' if respond_to?(:source_url)
issues_url 'https://github.com/chef-cookbooks/rsyslog/issues' if respond_to?(:issues_url)
......
# Cookbook Name:: rsyslog
# Provider:: file_input
#
# Copyright 2012-2015, Joseph Holsten
#
# 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.
#
# support whyrun
def whyrun_supported?
true
end
use_inline_resources
include RsyslogCookbook::Helpers
action :create do
declare_rsyslog_service
template "/etc/rsyslog.d/#{new_resource.priority}-#{new_resource.name}.conf" do
mode '0664'
owner node['rsyslog']['user']
group node['rsyslog']['group']
source new_resource.source
cookbook new_resource.cookbook
variables 'file_name' => new_resource.file,
'tag' => new_resource.name,
'state_file' => new_resource.name,
'severity' => new_resource.severity,
'facility' => new_resource.facility
notifies :restart, resources('service[rsyslog]')
end
end
......@@ -17,12 +17,37 @@
#
actions :create
default_action :create
attribute :name, kind_of: String, name_attribute: true, required: true
attribute :file, kind_of: String, required: true
attribute :priority, kind_of: Integer, default: 99
attribute :severity, kind_of: String
attribute :facility, kind_of: String
attribute :cookbook, kind_of: String, default: 'rsyslog'
attribute :source, kind_of: String, default: 'file-input.conf.erb'
property :name, kind_of: String, name_attribute: true, required: true
property :file, kind_of: String, required: true
property :priority, kind_of: Integer, default: 99
property :severity, kind_of: String
property :facility, kind_of: String
property :cookbook, kind_of: String, default: 'rsyslog'
property :source, kind_of: String, default: 'file-input.conf.erb'
include RsyslogCookbook::Helpers
action :create do
service_provider = 'ubuntu' == node['platform'] ? find_provider : nil
service node['rsyslog']['service_name'] do
supports restart: true, status: true
action [:enable, :start]
provider service_provider
end
template "/etc/rsyslog.d/#{new_resource.priority}-#{new_resource.name}.conf" do
mode '0664'
owner node['rsyslog']['user']
group node['rsyslog']['group']
source new_resource.source
cookbook new_resource.cookbook
variables 'file_name' => new_resource.file,
'tag' => new_resource.name,
'state_file' => new_resource.name,
'severity' => new_resource.severity,
'facility' => new_resource.facility
notifies :restart, resources('service[rsyslog]')
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment