Commit 78a6632b authored by Jose Luis Salas's avatar Jose Luis Salas
Browse files

Declare service[rsyslog] inside LWRP to make notification work

parent 3dc94ab1
......@@ -39,3 +39,6 @@ suites:
- name: server
run_list:
- recipe[rsyslog_test::server]
- name: input_file_provider
run_list:
- recipe[rsyslog_test::input_file_provider]
module RsyslogCookbook
module Helpers
def declare_rsyslog_service
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 12.04
service_provider = Chef::Provider::Service::Upstart
else
service_provider = nil
end
service node['rsyslog']['service_name'] do
supports :restart => true, :status => true
action [:enable, :start]
provider service_provider
end
end
end
end
......@@ -18,7 +18,11 @@
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']
......@@ -30,7 +34,6 @@ action :create do
'state_file' => new_resource.name,
'severity' => new_resource.severity,
'facility' => new_resource.facility
notifies :nothing, resources('service[rsyslog]')
notifies :restart, resources('service[rsyslog]')
end
end
......@@ -17,6 +17,8 @@
# limitations under the License.
#
::Chef::Recipe.send(:include, RsyslogCookbook::Helpers)
package 'rsyslog'
package 'rsyslog-relp' if node['rsyslog']['use_relp']
......@@ -84,14 +86,4 @@ if platform_family?('omnios')
end
end
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 12.04
service_provider = Chef::Provider::Service::Upstart
else
service_provider = nil
end
service node['rsyslog']['service_name'] do
supports :restart => true, :status => true
action [:enable, :start]
provider service_provider
end
declare_rsyslog_service
rsyslog_file_input 'test-file' do
file '/var/log/boot'
end
@test "the input_file is created" {
test /etc/rsyslog.d/99-test-file.conf
}
@test "the input_file contains given file" {
grep "InputFileName /var/log/boot" /etc/rsyslog.d/99-test-file.conf
}
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