Added seed code for caas-logging.
[ta/caas-logging.git] / SPECS / fluentd.spec
diff --git a/SPECS/fluentd.spec b/SPECS/fluentd.spec
new file mode 100644 (file)
index 0000000..e4d9c3b
--- /dev/null
@@ -0,0 +1,88 @@
+# Copyright 2019 Nokia
+#
+# 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.
+
+%define COMPONENT fluentd
+%define RPM_NAME caas-%{COMPONENT}
+%define RPM_MAJOR_VERSION 1.4.1
+%define RPM_MINOR_VERSION 1
+%define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
+
+Name:           %{RPM_NAME}
+Version:        %{RPM_MAJOR_VERSION}
+Release:        %{RPM_MINOR_VERSION}%{?dist}
+Summary:        Containers as a Service Fluentd component
+License:        %{_platform_license} and MIT license and Apache License and BSD 3-clause New or Revised License and Ruby License and BSD and Mozilla Public License and BSD 3-clause New or Revised License
+URL:            https://github.com/fluent/fluentd
+BuildArch:      x86_64
+Vendor:         %{_platform_vendor} and fluent/fluentd unmodified
+Source0:        %{name}-%{version}.tar.gz
+
+Requires: docker-ce >= 18.09.2
+BuildRequires: docker-ce >= 18.09.2
+
+%description
+This RPM contains the Fluentd container image, and related deployment artifacts for the CaaS subsystem.
+
+%prep
+%autosetup
+
+%build
+docker build \
+  --network=host \
+  --no-cache \
+  --force-rm \
+  --build-arg HTTP_PROXY="${http_proxy}" \
+  --build-arg HTTPS_PROXY="${https_proxy}" \
+  --build-arg NO_PROXY="${no_proxy}" \
+  --build-arg http_proxy="${http_proxy}" \
+  --build-arg https_proxy="${https_proxy}" \
+  --build-arg no_proxy="${no_proxy}" \
+  --build-arg VERSION="%{version}" \
+  --tag %{COMPONENT}:%{IMAGE_TAG} \
+  %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build/%{COMPONENT}/
+
+mkdir -p %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/
+
+docker save %{COMPONENT}:%{IMAGE_TAG} | gzip -c > %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar
+
+docker rmi -f %{COMPONENT}:%{IMAGE_TAG}
+
+%install
+mkdir -p %{buildroot}/%{_caas_container_tar_path}/
+rsync -av %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar %{buildroot}/%{_caas_container_tar_path}/
+
+mkdir -p %{buildroot}/%{_playbooks_path}/
+rsync -av ansible/playbooks/fluentd.yaml %{buildroot}/%{_playbooks_path}/
+
+mkdir -p %{buildroot}/%{_roles_path}/
+rsync -av ansible/roles/fluentd %{buildroot}/%{_roles_path}/
+
+%files
+%{_caas_container_tar_path}/%{COMPONENT}:%{IMAGE_TAG}.tar
+%{_playbooks_path}/fluentd.yaml
+%{_roles_path}/fluentd
+
+%preun
+
+%post
+mkdir -p %{_postconfig_path}/
+ln -sf %{_playbooks_path}/fluentd.yaml %{_postconfig_path}/
+
+%postun
+if [ $1 -eq 0 ]; then
+    rm -f %{_postconfig_path}/fluentd.yaml
+fi
+
+%clean
+rm -rf ${buildroot}