c58da15b06044c3b2ccbc5c03b00c922ed33cc54
[ta/caas-lcm.git] / rpmbuild.spec
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 %define COMPONENT lcm
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 1.0.0
18 %define RPM_MINOR_VERSION 3
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define LCM_PATH /opt/caas_lcm
21 %define DEPLOY_PATH %{LCM_PATH}/deploy
22 %define SU_PATH %{LCM_PATH}/su
23
24 Name:           %{RPM_NAME}
25 Version:        %{RPM_MAJOR_VERSION}
26 Release:        %{RPM_MINOR_VERSION}%{?dist}
27 Summary:        Containers as a Service Life Cycle Managemnet workflows
28 License:        %{_platform_license}
29 BuildArch:      x86_64
30 Vendor:         %{_platform_vendor}
31 Source0:        %{name}-%{version}.tar.gz
32
33 Requires: rsync >= 3.1.0
34
35 %description
36 This RPM contains Life Cycle Managemnet workflows for the CaaS subsystem.
37
38 %prep
39 %autosetup
40
41 %build
42
43 %install
44 mkdir -p %{buildroot}/%{SU_PATH}/
45 rsync -av su/* %{buildroot}/%{SU_PATH}/
46
47 mkdir -p %{buildroot}/%{DEPLOY_PATH}/
48 rsync -av deploy/* %{buildroot}/%{DEPLOY_PATH}/
49
50 mkdir -p %{buildroot}/%{_playbooks_path}/
51 rsync -av ansible/playbooks/pre_config_lcm.yaml %{buildroot}/%{_playbooks_path}/
52
53 mkdir -p %{buildroot}/%{_roles_path}/
54 rsync -av ansible/roles/pre_config_lcm %{buildroot}/%{_roles_path}/
55
56 # ------- set lcm path inside deploy
57 sed -i 's|{{ lcm_path }}|%{LCM_PATH}|g' %{buildroot}/%{DEPLOY_PATH}/roles/bm_onboard/tasks/main.yml
58 sed -i 's|{{ lcm_path }}|%{LCM_PATH}|g' %{buildroot}/%{DEPLOY_PATH}/roles/list_application_deployments/tasks/main.yml
59 sed -i 's|{{ lcm_path }}|%{LCM_PATH}|g' %{buildroot}/%{DEPLOY_PATH}/roles/list_application_packages/tasks/main.yml
60 sed -i 's|{{ lcm_path }}|%{LCM_PATH}|g' %{buildroot}/%{DEPLOY_PATH}/roles/list_docker_images/tasks/main.yml
61 sed -i 's|{{ caas_manifest_path }}|%{_caas_manifest_path}|g' %{buildroot}/%{DEPLOY_PATH}/group_vars/controller-1.caas_master/params.yml
62 # ------- set lcm path inside roles
63 sed -i 's|{{ lcm_path }}|%{LCM_PATH}|g' %{buildroot}/%{_roles_path}/pre_config_lcm/tasks/main.yml
64 # -------
65
66 %files
67 %{SU_PATH}
68 %{DEPLOY_PATH}
69 %{_playbooks_path}/pre_config_lcm.yaml
70 %{_roles_path}/pre_config_lcm
71
72 %preun
73
74 %post
75 mkdir -p %{_postconfig_path}/
76 ln -sf %{_playbooks_path}/pre_config_lcm.yaml %{_postconfig_path}/
77
78 %postun
79 if [ $1 -eq 0 ]; then
80     rm -f %{_postconfig_path}/pre_config_lcm.yaml
81 fi
82
83 %clean
84 rm -rf ${buildroot}
85