File openstack-monasca-log-transformer.spec of Package openstack-monasca-log-transformer
#
# spec file for package openstack-monasca-log-transformer
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright 2017 Fujitsu LIMITED
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define mlt_cfg_dir %{_sysconfdir}/%{sname}
%define mlt_log_dir /var/log/%{sname}
%define sname monasca-log-transformer
%define username %{sname}
%define groupname logstash
Name: openstack-%{sname}
Version: 0.0.1
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: https://github.com/FujitsuEnablingSoftwareTechnologyGmbH/
Source0: %{sname}.logrotate
Source1: %{sname}.conf.sample
Source2: %{name}.service
Summary: Consumes logs from Kafka, transforms them, and publishes them to Kafka
License: Apache-2.0
Group: Monitoring/Tools
BuildRequires: logstash >= 2.3.0
BuildRequires: openstack-macros
Requires: logrotate
Requires: logstash >= 2.3.0
Provides: %{sname}
BuildArch: noarch
%description
Consumes logs from Kafka, transforms them, and publishes them to Kafka
%prep
# no-op
%build
# no-op
%install
# etc
%{__install} -D -m 644 %{S:0} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%{__install} -D -m 644 %{S:1} %{buildroot}%{mlt_cfg_dir}/%{sname}.conf.sample
# var
%{__install} -d -m 750 %{buildroot}%{mlt_log_dir}
# service file
%{__install} -D -m 644 %{S:2} %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
# sedding...;)
sed -e "
s|__MLT_USER__|%{username}|g;
s|__MLT_GROUP__|%{groupname}|g;
s|__MLT_CONFIG__|%{mlt_cfg_dir}/%{sname}.conf|g;
s|__MLT_LOGDIR__|%{mlt_log_dir}|g;
" -i %{buildroot}%{_unitdir}/%{name}.service
sed -e "
s|__MLT_USER__|%{username}|g;
s|__MLT_GROUP__|%{groupname}|g;
s|__MLT_LOGDIR__|%{mlt_log_dir}|g;
" -i %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%pre
%openstack_pre_user_group_create %{username} %{groupname}
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
cat <<EOF
================================================================================
In order to start transforming logs, following configuration bits
needs to be established:
1) zookeeper nodes addresses
2) kafka brokers addresses
3) name of the topic, monasca-log-transformer sends logs to
4) name of the topic, logs are sent to from monasca-log-api
Copy sample file to the correct location and make your changes:
1) cp %{mlt_cfg_dir}/%{name}.conf.sample %{mlt_cfg_dir}/%{name}.conf
2) vi %{mlt_cfg_dir}/%{name}.conf
================================================================================
EOF
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
if [ $1 -eq 0 ] ; then
getent password %{username} > /dev/null
if [ "$?" == "0" ] ; then
userdel %{username}
fi
fi
%files
%defattr(-,root,root)
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%defattr(-,root,root)
%dir %{mlt_cfg_dir}
%attr(-,%{username},%{groupname}) %dir %{mlt_log_dir}
%config(noreplace) %{mlt_cfg_dir}/%{sname}.conf.sample
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%changelog