crowbar/crowbar-openstack

View on GitHub
chef/cookbooks/monasca/recipes/monasca_log_transformer.rb

Summary

Maintainability
A
55 mins
Test Coverage
#
# Cookbook Name:: monasca
# Recipe:: monasca-log-transformer
#
# Copyright 2018, SUSE Linux GmbH.
#
# 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.
#

package "openstack-monasca-log-transformer"

monasca_node = search(:node, "roles:monasca-server")[0]
monasca_net_ip = MonascaHelper.get_host_for_monitoring_url(monasca_node)

template "/etc/monasca-log-transformer/monasca-log-transformer.conf" do
  source "monasca-log-transformer.conf.erb"
  owner node[:monasca][:log_transformer][:user]
  group node[:monasca][:log_transformer][:group]
  mode "0640"
  variables(
    zookeeper_hosts: monasca_net_ip,
    kafka_hosts: "#{monasca_net_ip}:#{node[:monasca][:kafka][:port]}"
  )
  notifies :restart, "service[openstack-monasca-log-transformer]"
end

service "openstack-monasca-log-transformer" do
  supports status: true, restart: true, start: true, stop: true
  action [:enable, :start]
end