1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 # install-dev-tools.yml - Install Arvados development tooling
9 # This playbook installs and configures software necessary for Arvados
10 # development. It uses host groups from your inventory to select which
11 # dependencies are managed.
13 # The most inclusive group is `arvados_test_all`. Hosts in this group will
14 # have everything they need to clone the Arvados source and run
15 # `build/run-tests.sh`.
17 # Another useful group is `arvados_build_all`. Hosts in this group will have
18 # enough software to build Arvados binaries and language packages like Ruby
19 # gems. This is NOT enough software to run an Arvados cluster; it's mainly
20 # useful for building distribution packages and related tooling.
26 # dev.arvados.example:
28 # # See files/default-test-config.yml for an example.
29 # # You can change the Arvados database configuration and this playbook
30 # # will set up PostgreSQL to match.
31 # arvados_config_file: /home/example/path/arvados/config.yml
35 # $ ansible-playbook -Ki YOUR-INVENTORY.yml install-dev-tools.yml
39 # This documentation is aimed at Arvados developers building tooling with
42 # The pattern of group names is `arvados_build_COMPONENT` and
43 # `arvados_test_COMPONENT`. The `build` group installs everything you need
44 # to "build" the component from source. (Exactly what that means varies by
45 # language.) `arvados_test_COMPONENT` adds everything you need to run that
46 # component's tests. Any host in an `arvados_test` group is automatically
47 # added to its corresponding `arvados_build` group.
49 # See the `core_components` variable below for the list of components. In
50 # general, it is the name of a language we have multiple components in; or
51 # the name of a component that can be tested independently in `run-tests.sh`.
53 - name: Bootstrap nodes
57 # The `arvados_build_all` group will be expanded to the
58 # `arvados_build_NAME` group for every name in this list.
59 # This corresponds to the components we build distribution packages for.
67 # `arvados_test_all` works similarly with additional components.
68 # The primary user of `arvados_build_all` is package build Docker images,
69 # so excluding components we don't package avoids Docker image bloat.
77 - ansible.builtin.include_role:
78 name: distro_bootstrap
80 # If the host is in no `arvados` groups, add it to `arvados_test_all`.
81 - name: Build default group arvados_test_all
82 when: "hostvars[item]['group_names']|map('regex_search', '^arvados_')|select|first is undefined"
83 ansible.builtin.add_host:
87 loop: "{{ ansible_play_hosts }}"
89 - name: Expand arvados_build_all group
90 ansible.builtin.add_host:
92 groups: "{{ core_components|map('replace', '', 'arvados_build_', 1) }}"
93 loop: "{{ groups.arvados_build_all|default([]) }}"
95 - name: Expand arvados_test_all group
96 ansible.builtin.add_host:
98 groups: "{{ (core_components + test_components)|map('replace', '', 'arvados_test_', 1) }}"
99 loop: "{{ groups.arvados_test_all|default([]) }}"
101 - name: Add test hosts to build groups
102 ansible.builtin.add_host:
104 groups: "{{ hostvars[item]['group_names']|map('regex_replace', '^arvados_test_', 'arvados_build_', 1)|list }}"
105 loop: "{{ ansible_play_hosts }}"
107 ### Core dependencies
109 - hosts: arvados_build_*
111 - ansible.builtin.include_role:
112 name: distro_packages
114 task_name: Install common build tools
123 - name: Set up Arvados development user
125 ansible.builtin.user:
126 name: "{{ arvados_dev_user|default(ansible_user_id) }}"
129 # All of these test suites will spin up an entire development cluster, which
131 # * building and running arvados-server
132 # * building Ruby gems and running the API server in test mode
133 # * installing the Python SDK to run `run_test_server.py`
134 # So we take this as one big group, and this is the play where we set up all
135 # the prerequisites to do that.
136 - hosts: arvados_test_cwl:arvados_test_go:arvados_test_python:arvados_test_ruby
138 - name: Add host to prerequisite build groups
139 ansible.builtin.add_host:
143 - arvados_build_python
145 loop: "{{ ansible_play_hosts }}"
147 - name: Load Arvados configuration file
148 delegate_to: localhost
149 ansible.builtin.include_vars:
151 file: "{{ arvados_config_file }}"
153 - name: Load Arvados cluster configuration
154 ansible.builtin.set_fact:
155 arvados_cluster: "{{ arvados_config.Clusters.zzzzz }}"
156 failed_when: arvados_cluster is undefined
158 - name: Install shared test dependencies
164 # Direct dependencies of run-tests.sh
168 # Tests assume the underlying database uses en_US.UTF-8.
169 # It must be generated before starting the PostgreSQL server.
170 - name: Configure en_US.UTF-8 locale
172 ansible.builtin.lineinfile:
173 path: /etc/locale.gen
174 regexp: "^[# ]*en_US.UTF-8 +UTF-8 *$"
175 line: en_US.UTF-8 UTF-8
178 - name: Run locale-gen
179 when: locale_gen.changed
181 ansible.builtin.command:
184 - ansible.builtin.include_role:
185 name: arvados_postgresql
187 arvados_postgresql_config: {}
188 arvados_postgresql_hba_sources:
192 - ansible.builtin.include_role:
193 name: arvados_database
195 arvados_database_login_host: ""
196 # Let the test user drop and recreate the database wholesale
197 arvados_database_role_attr_flags: CREATEDB
199 - name: Set up .config/arvados
201 become_user: "{{ dev_user.name }}"
202 ansible.builtin.file:
203 path: "{{ (dev_user.home, item)|path_join }}"
209 - name: Write arvados/config.yml for testing
211 become_user: "{{ dev_user.name }}"
212 ansible.builtin.copy:
213 src: "{{ arvados_config_file }}"
214 dest: "{{ (dev_user.home, '.config/arvados/config.yml')|path_join }}"
217 - name: Add Arvados test configuration to profile.d
219 ansible.builtin.copy:
221 if [ -z "${CONFIGSRC:-}" ] && [ -e ~/.config/arvados/config.yml ]; then
222 export CONFIGSRC="$HOME/.config/arvados"
224 dest: /etc/profile.d/arvados-test.sh
226 ### Core language build dependencies
228 - hosts: arvados_build_go
230 - ansible.builtin.include_role:
233 - ansible.builtin.include_role:
234 name: distro_packages
236 task_name: Install Go build dependencies
240 - hosts: arvados_build_python
242 - ansible.builtin.include_role:
243 name: distro_packages
245 task_name: Install Python build requirements
248 - libcurl4-openssl-dev
256 - hosts: arvados_build_ruby
258 - ansible.builtin.include_role:
259 name: distro_packages
261 task_name: Install Ruby build requirements
265 - libcurl4-openssl-dev
278 ### Distribution package dependencies
279 # These are ordered here because some of the language test suites later
280 # expand the Docker installation.
282 - hosts: arvados_build_deb:arvados_build_rpm
284 - ansible.builtin.include_role:
285 name: arvados_ansible
287 arvados_ansible_galaxy_user: "{{ dev_user.name }}"
289 - ansible.builtin.include_role:
292 - name: Add development user to docker group
294 ansible.builtin.user:
295 name: "{{ dev_user.name }}"
300 - hosts: arvados_test_deb
302 - name: Install deb test dependencies
309 - hosts: arvados_test_rpm
311 - name: Install RPM test dependencies
317 ### Core language test dependencies
319 - hosts: arvados_test_cwl:arvados_test_go
321 - ansible.builtin.include_role:
322 name: arvados_compute
324 arvados_compute_packages: []
325 arvados_compute_docker: true
326 arvados_compute_singularity: "{{ 'arvados_test_go' in group_names }}"
328 - name: Add development user to docker group
330 ansible.builtin.user:
331 name: "{{ dev_user.name }}"
336 - hosts: arvados_test_go
338 - name: Install Go test dependencies
348 ### Individual component dependencies
350 - hosts: arvados_build_doc
352 - name: Install doc build requirements
359 - hosts: arvados_test_doc
361 - name: Install doc test requirements
367 - hosts: arvados_build_java
369 - name: Install Java build requirements
373 - default-jdk-headless
376 - hosts: arvados_build_R
378 - name: Install R build requirements
394 - hosts: arvados_test_R
396 - name: Install R test requirements
402 - hosts: arvados_build_workbench
404 - ansible.builtin.include_role:
407 - hosts: arvados_test_workbench
409 - name: Install Workbench test requirements
413 # <https://docs.cypress.io/app/get-started/install-cypress#Linux-Prerequisites>
426 - name: Check fs.inotify.max_user_watches sysctl value
427 ansible.builtin.command:
428 cmd: /sbin/sysctl --values fs.inotify.max_user_watches
429 register: max_user_watches_value
431 - name: Increase fs.inotify.max_user_watches
433 max_user_watches_wanted: 524288
434 when: "max_user_watches_value.stdout|int < max_user_watches_wanted"
436 ansible.builtin.command:
439 - "fs.inotify.max_user_watches={{ max_user_watches_wanted }}"
440 register: max_user_watches_set
442 - name: Set fs.inotify.max_user_watches permanently
443 when: max_user_watches_set.changed
445 ansible.builtin.copy:
447 ### This file is managed by Ansible
448 # React sets many inotify watchers and needs the limit increased.
449 {{ max_user_watches_set.stdout }}
450 dest: /etc/sysctl.d/arvados-workbench.conf