]> git.arvados.org - arvados.git/blob - tools/ansible/install-test-env.yml
22958: Refactor NodeJS installation to a role
[arvados.git] / tools / ansible / install-test-env.yml
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4 #
5 # install-test-env.yml - Ansible playbook to set up a host to run Arvados tests
6 #
7 # After you run this playbook on a host, you should be able to clone the
8 # Arvados git repository and run `build/run-tests.sh`.
9 # As of April 2025 this has been tested to work on Debian 12.
10 #
11 # In order to use this playbook, you must write an Arvados `config.yml` with
12 # PostgreSQL connection details for the `zzzzz` cluster.
13 # `files/default-test-config.yml` has the default credentials used by tests.
14 # You can copy that file and edit `dbname`, `user`, and `password` to taste.
15 # Pass the path of your file to `ansible-playbook` with
16 # `-e arvados_config_file=config.yml`.
17
18 - name: Bootstrap nodes
19   hosts: all
20   gather_facts: no
21   tasks:
22     - name: Load Arvados configuration file
23       delegate_to: localhost
24       ansible.builtin.include_vars:
25         name: arvados_config
26         file: "{{ arvados_config_file }}"
27     - name: Load Arvados cluster configuration
28       ansible.builtin.set_fact:
29         arvados_cluster: "{{ arvados_config.Clusters.zzzzz }}"
30       failed_when: arvados_cluster is undefined
31     - ansible.builtin.include_role:
32         name: distro_bootstrap
33
34 - hosts: all
35   vars:
36     arvados_dev_user: "{{ ansible_user_id }}"
37
38   tasks:
39     - name: Install all required development packages
40       become: yes
41       ansible.builtin.apt:
42         name:
43           # Common build and test tools
44           - bison
45           - ca-certificates
46           - curl
47           - diffutils
48           - g++
49           - git
50           - jq
51           - libnss-systemd
52           - make
53           - nginx
54           - postgresql-client
55           - python3-dev
56           - python3-venv
57           - ruby
58           - ruby-dev
59           # Common libraries
60           - libcurl4-openssl-dev
61           - libssl-dev
62           # build/run-tests.sh
63           - bsdextrautils
64           - net-tools
65           # build/run-build-packages*.sh
66           - apt-utils
67           - createrepo-c
68           - dpkg-dev
69           # doc
70           - linkchecker
71           # lib/controller
72           - rsync
73           # lib/pam
74           - libpam-dev
75           # sdk/java-v2
76           - default-jdk-headless
77           - gradle
78           # sdk/R
79           - libfontconfig1-dev
80           - libfreetype6-dev
81           - libfribidi-dev
82           - libharfbuzz-dev
83           - libjpeg-dev
84           - libpng-dev
85           - libtiff5-dev
86           - libxml2-dev
87           - r-base
88           - r-cran-testthat
89           # services/api
90           - libnsl2
91           - libpq-dev
92           - libyaml-dev
93           - locales
94           - procps
95           - shared-mime-info
96           - zlib1g-dev
97           # services/fuse
98           - fuse
99           - libfuse-dev
100           # services/keep-web
101           - cadaver
102           - mime-support
103           # services/workbench2
104           # <https://docs.cypress.io/app/get-started/install-cypress#Linux-Prerequisites>
105           - firefox-esr
106           - libasound2
107           - libgbm-dev
108           - libgtk-3-0
109           - libgtk2.0-0
110           - libnotify-dev
111           - libnss3
112           - libxss1
113           - libxtst6
114           - xauth
115           - xvfb
116
117     - ansible.builtin.include_role:
118         name: arvados_go
119     - ansible.builtin.include_role:
120         name: arvados_compute
121       vars:
122         arvados_compute_packages: []
123         arvados_compute_docker: true
124         arvados_compute_singularity: true
125
126     # RailsAPI tests depend on the en_US.UTF-8 locale.
127     # It must be generated before starting the PostgreSQL server.
128     - name: Configure en_US.UTF-8 locale
129       become: yes
130       ansible.builtin.lineinfile:
131         path: /etc/locale.gen
132         regexp: "^[# ]*en_US.UTF-8 +UTF-8 *$"
133         line: en_US.UTF-8 UTF-8
134       register: locale_gen
135     - name: Run locale-gen
136       when: locale_gen.changed
137       become: yes
138       ansible.builtin.command:
139         cmd: locale-gen
140     - ansible.builtin.include_role:
141         name: arvados_postgresql
142       vars:
143         arvados_postgresql_config: {}
144         arvados_postgresql_hba_sources:
145           - "127.0.0.0/24"
146           - "::1/128"
147
148
149     - ansible.builtin.include_role:
150         name: arvados_nodejs
151     # Configuration to run Workbench
152     - name: Check fs.inotify.max_user_watches sysctl value
153       ansible.builtin.command:
154         cmd: /sbin/sysctl --values fs.inotify.max_user_watches
155       register: max_user_watches_value
156     - name: Increase fs.inotify.max_user_watches
157       vars:
158         max_user_watches_wanted: 524288
159       when: "max_user_watches_value.stdout|int < max_user_watches_wanted"
160       become: yes
161       ansible.builtin.command:
162         argv:
163           - sysctl
164           - "fs.inotify.max_user_watches={{ max_user_watches_wanted }}"
165       register: max_user_watches_set
166     - name: Set fs.inotify.max_user_watches permanently
167       when: max_user_watches_set.changed
168       become: yes
169       ansible.builtin.copy:
170         content: |
171           ### This file is managed by Ansible
172           # React sets many inotify watchers and needs the limit increased.
173           {{ max_user_watches_set.stdout }}
174         dest: /etc/sysctl.d/arvados-workbench.conf
175         owner: root
176         group: root
177         mode: 0644
178
179     - ansible.builtin.include_role:
180         name: arvados_database
181       vars:
182         arvados_database_login_host: ""
183         # Let the test user drop and recreate the database wholesale
184         arvados_database_role_attr_flags: CREATEDB
185
186     - name: Set up Arvados development user
187       become: yes
188       ansible.builtin.user:
189         name: "{{ arvados_dev_user }}"
190         groups:
191           - docker
192         append: yes
193       register: dev_user
194     - name: Set up .config/arvados
195       become: yes
196       become_user: "{{ arvados_dev_user }}"
197       ansible.builtin.file:
198         path: "{{ (dev_user.home, item)|path_join }}"
199         state: directory
200       loop:
201         - .config
202         - .config/arvados
203     - name: Write arvados/config.yml for testing
204       become: yes
205       become_user: "{{ arvados_dev_user }}"
206       ansible.builtin.copy:
207         src: "{{ arvados_config_file }}"
208         dest: "{{ (dev_user.home, '.config/arvados/config.yml')|path_join }}"
209         mode: 0600
210     - name: Add Arvados test configuration to profile.d
211       become: yes
212       ansible.builtin.copy:
213         content: |
214           if [ -z "${CONFIGSRC:-}" ] && [ -e ~/.config/arvados/config.yml ]; then
215             export CONFIGSRC="$HOME/.config/arvados"
216           fi
217         dest: /etc/profile.d/arvados-test.sh
218
219     - ansible.builtin.include_role:
220         name: arvados_ansible
221       vars:
222         arvados_ansible_galaxy_user: "{{ arvados_dev_user }}"