-
Notifications
You must be signed in to change notification settings - Fork 502
/
Copy pathplaybook.yaml
94 lines (83 loc) · 3.27 KB
/
playbook.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- name: "Install build dependencies"
hosts: localhost
connection: local
# The playbook requires passing 3 variables explicitly:
# - stage: build or release. Different packages are installed depending on
# the chosen stage.
# - arch: aarch64 or amd64. Architecture of the built image and wheels.
# - accelerator: tpu or cuda. Available accelerator.
pre_tasks:
- name: "Validate required variables"
ansible.builtin.assert:
that: "{{ lookup('ansible.builtin.vars', item.name) is regex(item.pattern) }}"
fail_msg: |
"Variable '{{ item.name }} = '{{ lookup('ansible.builtin.vars', item.name) }}' doesn't match pattern '{{ item.pattern }}'"
"Pass the required variable with: --e \"{{ item.name }}=<value>\""
loop:
- name: stage
pattern: ^(build|release)$
- name: arch
pattern: ^(aarch64|amd64)$
- name: accelerator
pattern: ^(tpu|cuda)$
- name: "Include vars from config files"
ansible.builtin.include_vars:
file: "config/{{ item }}"
loop:
# vars.yaml should be the first as other config files depend on it.
- vars.yaml
# cuda_deps should be loaded before apt, since apt depends on it.
- cuda_deps.yaml
- apt.yaml
- pip.yaml
- env.yaml
tags: always # Execute this task even with `--skip-tags` or `--tags` is used.
roles:
- role: bazel
tags: bazel
- role: install_deps
vars:
apt_keys: "{{ apt.signing_keys }}"
# If a variable (like `apt.pkgs.common`) is defined, but not set to
# anything it cannot be concatenated with a list.
# Use `v | default([], true)` to set `v` to an empty array if it evaluates to false.
# See https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-filters.default.
apt_pkgs: "{{
apt.pkgs[stage + '_common'] | default([], true) +
apt.pkgs[stage + '_' + arch] | default([], true) +
apt.pkgs[stage + '_' + accelerator] | default([], true)
}}"
apt_repos: "{{ apt.repos }}"
pip_pkgs: "{{
pip.pkgs[stage + '_common'] | default([], true) +
pip.pkgs[stage + '_' + arch] | default([], true) +
pip.pkgs[stage + '_' + accelerator] | default([], true)
}}"
pip_pkgs_nodeps: "{{
pip.pkgs_nodeps[stage + '_common'] | default([], true) +
pip.pkgs_nodeps[stage + '_' + arch] | default([], true) +
pip.pkgs_nodeps[stage + '_' + accelerator] | default([], true)
}}"
tags: install_deps
- role: fetch_srcs
vars:
src_root: "/src"
tags: fetch_srcs
- role: build_srcs
vars:
src_root: "/src"
env_vars: "{{
build_env.common | default({}, true) |
combine(build_env[arch] | default({}, true)) |
combine(build_env[accelerator] | default({}, true))
}}"
tags: build_srcs
- role: configure_env
vars:
env_vars: "{{
release_env.common | default({}, true) |
combine(release_env[arch] | default({}, true)) |
combine(release_env[accelerator] | default({}, true))
}}"
when: stage == "release"
tags: configure_env