Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/buildenv/ansible/roles/openj9-build-environment/tasks/main.yml
13608 views
1
###############################################################################
2
# Copyright (c) 2018, 2018 Pavel Samolysov
3
#
4
# This program and the accompanying materials are made available under
5
# the terms of the Eclipse Public License 2.0 which accompanies this
6
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
# or the Apache License, Version 2.0 which accompanies this distribution and
8
# is available at https://www.apache.org/licenses/LICENSE-2.0.
9
#
10
# This Source Code may also be made available under the following
11
# Secondary Licenses when the conditions for such availability set
12
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
# General Public License, version 2 with the GNU Classpath
14
# Exception [1] and GNU General Public License, version 2 with the
15
# OpenJDK Assembly Exception [2].
16
#
17
# [1] https://www.gnu.org/software/classpath/license.html
18
# [2] http://openjdk.java.net/legal/assembly-exception.html
19
#
20
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
###############################################################################
22
# Copyright (c) 2020, 2021 IBM Corp. and others
23
###############################################################################
24
---
25
- name: Create a build folder
26
file:
27
dest: "{{ build_dir }}"
28
mode: 0755
29
state: directory
30
tags:
31
- buildenv
32
- name: Get script to build docker image
33
get_url:
34
dest: "{{ build_dir }}/mkdocker.sh"
35
url: "https://raw.githubusercontent.com/eclipse-openj9/openj9/master/buildenv/docker/mkdocker.sh"
36
mode: 0644
37
validate_certs: no
38
tags:
39
- buildenv
40
- name: Build the docker image for the building environment
41
command: bash mkdocker.sh --tag=openj9-{{ version }}-build --dist=ubuntu --version=16.04 --build
42
tags:
43
- buildenv
44
- name: Create a build result folder
45
file:
46
dest: "{{ host_dir }}"
47
mode: 0755
48
state: directory
49
tags:
50
- buildenv
51
- name: Start the building environment as a docker container
52
docker_container:
53
name: "openj9-{{ version }}-build"
54
image: "openj9-{{ version }}-build:latest"
55
state: started
56
restart: yes # without restart, the container wouldn't be able to touch any file in the host_dir folder
57
interactive: yes # without interactive, the container would be stopped just after it has been started
58
volumes: "{{ host_dir }}:/root/hostdir"
59
tags:
60
- buildenv
61
- name: Get the ansible user
62
command: whoami
63
register: ansible_user
64
tags:
65
- buildenv
66
- build
67
- name: Get the ansible uid
68
shell: "id {{ ansible_user.stdout }} | awk -F'uid=' '{printf \"%d\", $2}'"
69
register: ansible_uid
70
tags:
71
- buildenv
72
- name: Get the ansible group
73
shell: "groups {{ ansible_user.stdout }} | awk -F' ' '{printf \"%s\", $3}'"
74
register: ansible_group
75
tags:
76
- buildenv
77
- build
78
- name: Get the ansible gid
79
shell: "id {{ ansible_user.stdout }} | awk -F'gid=' '{printf \"%d\", $2}'"
80
register: ansible_gid
81
tags:
82
- buildenv
83
- name: Add the container to inventory
84
add_host:
85
name: "openj9-{{ version }}-build"
86
ansible_connection: docker
87
ansible_user: root
88
changed_when: false
89
tags:
90
- buildenv
91
- build
92
- name: Install python to the container if there is no one
93
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
94
delegate_to: "openj9-{{ version }}-build"
95
tags:
96
- buildenv
97
- name: Add group "{{ target.group }}"
98
group:
99
name: "{{ target.group }}"
100
gid: "{{ target.groupid }}"
101
delegate_to: "openj9-{{ version }}-build"
102
tags:
103
- buildenv
104
- name: Add user "{{ target.user }}"
105
user:
106
name: "{{ target.user }}"
107
uid: "{{ target.userid }}"
108
group: "{{ target.group }}"
109
createhome: no
110
shell: /sbin/nologin
111
delegate_to: "openj9-{{ version }}-build"
112
tags:
113
- buildenv
114
- name: Add group "{{ ansible_group.stdout }}"
115
group:
116
name: "{{ ansible_group.stdout }}"
117
gid: "{{ ansible_gid.stdout }}"
118
delegate_to: "openj9-{{ version }}-build"
119
tags:
120
- buildenv
121
- name: Add user "{{ ansible_user.stdout }}"
122
user:
123
name: "{{ ansible_user.stdout }}"
124
uid: "{{ ansible_uid.stdout }}"
125
group: "{{ ansible_group.stdout }}"
126
createhome: no
127
shell: /sbin/nologin
128
delegate_to: "openj9-{{ version }}-build"
129
tags:
130
- buildenv
131
132