36501bd82e50c876a1067b658960727e93e38c46
[infra/stack/kubernetes.git] / playbooks / roles / package / tasks / record-shas.yaml
1 ---
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 # NOTE (fdegir): ansible-lint complains due to using command module for
21 # getting git sha and it is suppressed since it is not possible to get
22 # sha using ansible git module
23 - name: Fetch commit shas of repos
24   command: git rev-parse HEAD  # noqa 303
25   register: commit_shas
26   with_items:
27     - engine-kubernetes
28     - engine-kubespray
29     - engine-heat
30     - engine-bifrost
31     - engine
32   args:
33     chdir: "/tmp/autorelease/git/{{ item }}"
34   changed_when: false
35
36 - name: Populate dictionary to map repos to shas
37   set_fact:
38     repos_shas: "{{ repos_shas|default({}) | combine( {item.item | upper | replace('-', '_') + '_SHA': item.stdout} ) }}"
39   with_items: "{{ commit_shas.results }}"
40
41 - name: Log repos and shas to console
42   debug:
43     msg: "{{ item.key }}={{ item.value }}"
44   with_dict: "{{ repos_shas }}"
45
46 - name: Record git SHAs to /tmp/release.properties file
47   lineinfile:
48     path: /tmp/release.properties
49     state: present
50     create: true
51     line: "{{ item.key }}={{ item.value }}"
52   with_dict: "{{ repos_shas }}"
53
54 - name: Copy /tmp/release.properties into offline package
55   copy:
56     src: /tmp/release.properties
57     dest: "{{ offline_pkg_folder }}/release.properties"
58     force: true
59
60 # vim: set ts=2 sw=2 expandtab: