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_one_target`. Hosts in this group
18 # will have enough software to build Arvados istribution packages. It's
19 # meant to run inside Docker containers for different target distributions.
25 # dev.arvados.example:
27 # # See files/default-test-config.yml for an example.
28 # # You can change the Arvados database configuration and this playbook
29 # # will set up PostgreSQL to match.
30 # arvados_config_file: /home/example/path/arvados/config.yml
34 # $ ansible-playbook -Ki YOUR-INVENTORY.yml install-dev-tools.yml
38 # This documentation is aimed at Arvados developers building tooling with
41 # The pattern of group names is `arvados_build_COMPONENT` and
42 # `arvados_test_COMPONENT`. The `build` group installs everything you need
43 # to "build" the component from source. (Exactly what that means varies by
44 # language.) `arvados_test_COMPONENT` adds everything you need to run that
45 # component's tests. Any host in an `arvados_test` group is automatically
46 # added to its corresponding `arvados_build` group.
48 # See the `core_components` variable below for the list of components. In
49 # general, it is the name of a language we have multiple components in; or
50 # the name of a component that can be tested independently in `run-tests.sh`.
52 - name: Bootstrap nodes
56 # The `arvados_build_one_target` group will be expanded to the
57 # `arvados_build_NAME` group for every name in this list.
58 # This corresponds to the components we build distribution packages for.
65 # `arvados_test_all` works similarly with additional components.
67 # `arvados_build_all_targets` installs Docker+Ansible to build and run
68 # package build/test Docker images.
69 # `arvados_test_all_targets` installs additional tools necessary to
70 # orchestrate the package test Docker containers.
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_one_target group
90 ansible.builtin.add_host:
92 groups: "{{ core_components|map('replace', '', 'arvados_build_', 1) }}"
93 loop: "{{ groups.arvados_build_one_target|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 # Most arvados ansible roles don't currently have dnf tasks, support RHEL
139 # configuration paths, etc.
140 - name: Check distribution support
141 when: "ansible_pkg_mgr != 'apt'"
142 ansible.builtin.fail:
143 msg: Install test prerequisites is currently only supported on Debian and Ubuntu
145 - name: Add host to prerequisite build groups
146 ansible.builtin.add_host:
150 - arvados_build_python
152 loop: "{{ ansible_play_hosts }}"
154 - name: Load Arvados configuration file
155 delegate_to: localhost
156 ansible.builtin.include_vars:
158 file: "{{ arvados_config_file }}"
160 - name: Load Arvados cluster configuration
161 ansible.builtin.set_fact:
162 arvados_cluster: "{{ arvados_config.Clusters.zzzzz }}"
163 failed_when: arvados_cluster is undefined
165 - name: Install shared test dependencies
172 # Direct dependencies of run-tests.sh
176 # Tests assume the underlying database uses en_US.UTF-8.
177 # It must be generated before starting the PostgreSQL server.
178 - name: Configure en_US.UTF-8 locale
180 ansible.builtin.lineinfile:
181 path: /etc/locale.gen
182 regexp: "^[# ]*en_US.UTF-8 +UTF-8 *$"
183 line: en_US.UTF-8 UTF-8
186 - name: Run locale-gen
187 when: locale_gen.changed
189 ansible.builtin.command:
192 - ansible.builtin.include_role:
193 name: arvados_postgresql
195 arvados_postgresql_config: {}
196 arvados_postgresql_hba_sources:
200 - ansible.builtin.include_role:
201 name: arvados_database
203 arvados_database_login_host: ""
204 # Let the test user drop and recreate the database wholesale
205 arvados_database_role_attr_flags: CREATEDB
207 - name: Set up .config/arvados
209 become_user: "{{ dev_user.name }}"
210 ansible.builtin.file:
211 path: "{{ (dev_user.home, item)|path_join }}"
217 - name: Write arvados/config.yml for testing
219 become_user: "{{ dev_user.name }}"
220 ansible.builtin.copy:
221 src: "{{ arvados_config_file }}"
222 dest: "{{ (dev_user.home, '.config/arvados/config.yml')|path_join }}"
225 - name: Add Arvados test configuration to profile.d
227 ansible.builtin.copy:
229 if [ -z "${CONFIGSRC:-}" ] && [ -e ~/.config/arvados/config.yml ]; then
230 export CONFIGSRC="$HOME/.config/arvados"
232 dest: /etc/profile.d/arvados-test.sh
234 ### Core language build dependencies
236 - hosts: arvados_build_go
238 - ansible.builtin.include_role:
241 - ansible.builtin.include_role:
242 name: distro_packages
244 task_name: Install Go build dependencies
248 - hosts: arvados_build_python
250 - ansible.builtin.include_role:
251 name: distro_packages
253 task_name: Install Python build requirements
256 - libcurl4-openssl-dev
264 - hosts: arvados_build_ruby
266 - ansible.builtin.include_role:
272 - ansible.builtin.include_role:
273 name: distro_packages
275 task_name: Install Ruby build requirements
279 - libcurl4-openssl-dev
292 - name: Install bundler gem
294 community.general.gem:
299 ### Distribution package dependencies
300 # These are ordered here because they depend on the core language
301 # dependencies above, but some of the language test suites later expand the
302 # Docker installation.
304 - hosts: arvados_build_one_target
306 - name: Get Ruby version
307 ansible.builtin.command:
312 register: ruby_version
314 # This is a dependency of fpm that dropped support for Ruby 2.7
315 # in its 3.0 release.
316 - name: Install dotenv gem
317 when: "ruby_version.stdout is version('3.0.0', operator='<')"
319 community.general.gem:
324 - name: Install fpm gem
326 community.general.gem:
331 - name: Install rpm-build
332 when: "ansible_pkg_mgr == 'dnf'"
338 - hosts: arvados_build_all_targets
340 - ansible.builtin.include_role:
341 name: arvados_ansible
343 arvados_ansible_galaxy_user: "{{ dev_user.name }}"
345 - ansible.builtin.include_role:
348 - name: Add development user to docker group
350 ansible.builtin.user:
351 name: "{{ dev_user.name }}"
356 - hosts: arvados_test_all_targets
358 - name: Install package test dependencies
366 ### Core language test dependencies
368 - hosts: arvados_test_cwl:arvados_test_go
370 - ansible.builtin.include_role:
371 name: arvados_compute
373 arvados_compute_packages: []
374 arvados_compute_docker: true
375 arvados_compute_singularity: "{{ 'arvados_test_go' in group_names }}"
377 - name: Add development user to docker group
379 ansible.builtin.user:
380 name: "{{ dev_user.name }}"
385 - hosts: arvados_test_go
387 - name: Install Go test dependencies
397 ### Individual component dependencies
399 - hosts: arvados_build_doc
401 - name: Install doc build requirements
408 - hosts: arvados_test_doc
410 - name: Install doc test requirements
416 - hosts: arvados_build_java
418 - name: Install Java build requirements
422 - default-jdk-headless
425 - hosts: arvados_build_R
427 - name: Install R build requirements
443 - hosts: arvados_test_R
445 - name: Install R test requirements
451 - hosts: arvados_build_workbench
453 - ansible.builtin.include_role:
456 - hosts: arvados_test_workbench
458 - name: Install Workbench test requirements
462 # <https://docs.cypress.io/app/get-started/install-cypress#Linux-Prerequisites>
475 - name: Check fs.inotify.max_user_watches sysctl value
476 ansible.builtin.command:
477 cmd: /sbin/sysctl --values fs.inotify.max_user_watches
478 register: max_user_watches_value
480 - name: Increase fs.inotify.max_user_watches
482 max_user_watches_wanted: 524288
483 when: "max_user_watches_value.stdout|int < max_user_watches_wanted"
485 ansible.builtin.command:
488 - "fs.inotify.max_user_watches={{ max_user_watches_wanted }}"
489 register: max_user_watches_set
491 - name: Set fs.inotify.max_user_watches permanently
492 when: max_user_watches_set.changed
494 ansible.builtin.copy:
496 ### This file is managed by Ansible
497 # React sets many inotify watchers and needs the limit increased.
498 {{ max_user_watches_set.stdout }}
499 dest: /etc/sysctl.d/arvados-workbench.conf