]> git.arvados.org - arvados.git/blob - tools/ansible/install-test-env.yml
22563: Add arvados_compute 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 February 2025 this has been tested to work on Debian 11 and Debian 12.
10 # A few tests fail on Debian 12 because they haven't been adapted to newer
11 # software yet.
12 #
13 # In order to use this playbook, you must write an Arvados `config.yml` with
14 # PostgreSQL connection details for the `zzzzz` cluster.
15 # `files/default-test-config.yml` has the default credentials used by tests.
16 # You can copy that file and edit `dbname`, `user`, and `password` to taste.
17 # Pass the path of your file to `ansible-playbook` with
18 # `-e arvados_config_file=config.yml`.
19
20 - name: Load Arvados configuration
21   hosts: all
22   tasks:
23     - name: Load Arvados configuration file
24       delegate_to: localhost
25       ansible.builtin.include_vars:
26         name: arvados_config
27         file: "{{ arvados_config_file }}"
28     - name: Load Arvados cluster configuration
29       ansible.builtin.set_fact:
30         arvados_cluster: "{{ arvados_config.Clusters.zzzzz }}"
31       failed_when: arvados_cluster is undefined
32
33 - hosts: all
34   vars:
35     arvados_dev_user: "{{ ansible_user_id }}"
36     arvados_nodejs_version: "14.21.3"
37     arvados_nodejs_destdir: "/opt/node-v{{ arvados_nodejs_version }}-linux-x64"
38
39   tasks:
40     - name: Bootstrap packages required for Ansible
41       become: yes
42       ansible.builtin.raw: "apt-get -o DPkg::Lock::Timeout=300 -qy {{ item }}"
43       loop:
44         - update
45         - install acl gnupg python3-apt python3-debian python3-psycopg2 xz-utils
46     - name: Install all required development packages
47       become: yes
48       ansible.builtin.apt:
49         name:
50           # Common build and test tools
51           - bison
52           - ca-certificates
53           - curl
54           - diffutils
55           - g++
56           - git
57           - jq
58           - libnss-systemd
59           - make
60           - nginx
61           - postgresql-client
62           - python3-dev
63           - python3-venv
64           - ruby
65           - ruby-dev
66           # Common libraries
67           - libcurl4-openssl-dev
68           - libssl-dev
69           # build/run-tests.sh
70           - bsdextrautils
71           - net-tools
72           # build/run-build-packages*.sh
73           - createrepo-c
74           - dpkg-dev
75           # doc
76           - linkchecker
77           # lib/controller
78           - rsync
79           # lib/pam
80           - libpam-dev
81           # sdk/java-v2
82           - default-jdk-headless
83           - gradle
84           # sdk/R
85           - libfontconfig1-dev
86           - libfreetype6-dev
87           - libfribidi-dev
88           - libharfbuzz-dev
89           - libjpeg-dev
90           - libpng-dev
91           - libtiff5-dev
92           - libxml2-dev
93           - r-base
94           - r-cran-testthat
95           # services/api
96           - libnsl2
97           - libpq-dev
98           - locales
99           - procps
100           - shared-mime-info
101           - zlib1g-dev
102           # services/fuse
103           - fuse
104           - libfuse-dev
105           # services/keep-web
106           - cadaver
107           - mime-support
108           # services/workbench2
109           # <https://docs.cypress.io/app/get-started/install-cypress#Linux-Prerequisites>
110           - firefox-esr
111           - libasound2
112           - libgbm-dev
113           - libgtk-3-0
114           - libgtk2.0-0
115           - libnotify-dev
116           - libnss3
117           - libxss1
118           - libxtst6
119           - xauth
120           - xvfb
121
122     - ansible.builtin.include_role:
123         name: arvados_go
124     - ansible.builtin.include_role:
125         name: arvados_compute
126       vars:
127         arvados_compute_packages: []
128         arvados_compute_docker: true
129         arvados_compute_singularity: true
130
131     # RailsAPI tests depend on the en_US.UTF-8 locale.
132     # It must be generated before starting the PostgreSQL server.
133     - name: Configure en_US.UTF-8 locale
134       become: yes
135       ansible.builtin.lineinfile:
136         path: /etc/locale.gen
137         regexp: "^[# ]*en_US.UTF-8 +UTF-8 *$"
138         line: en_US.UTF-8 UTF-8
139       register: locale_gen
140     - name: Run locale-gen
141       when: locale_gen.changed
142       become: yes
143       ansible.builtin.command:
144         cmd: locale-gen
145     - ansible.builtin.include_role:
146         name: arvados_postgresql
147       vars:
148         arvados_postgresql_hba_users: "{{ arvados_cluster.PostgreSQL.Connection.user }}"
149         arvados_postgresql_hba_databases: "{{ arvados_cluster.PostgreSQL.Connection.dbname }}"
150         arvados_postgresql_hba_sources:
151           - "127.0.0.1/24"
152           - "::1/128"
153
154     # Workbench build dependencies
155     - name: Install Node.js
156       become: yes
157       ansible.builtin.unarchive:
158         src: "https://nodejs.org/dist/v{{ arvados_nodejs_version }}/node-v{{ arvados_nodejs_version }}-linux-x64.tar.xz"
159         dest: "{{ arvados_nodejs_destdir|dirname }}"
160         remote_src: yes
161         creates: "{{ (arvados_nodejs_destdir, 'bin/node')|path_join }}"
162     - name: Install yarn
163       become: yes
164       ansible.builtin.command:
165         cmd: npm install -g yarn
166         creates: "{{ (arvados_nodejs_destdir, 'bin/yarn')|path_join }}"
167       environment:
168         PATH: "{{ (arvados_nodejs_destdir, 'bin')|path_join }}:{{ ansible_env.PATH }}"
169     - name: Add Node commands to PATH
170       become: yes
171       ansible.builtin.file:
172         state: link
173         src: "{{ (arvados_nodejs_destdir, 'bin', item)|path_join }}"
174         dest: "{{ ('/usr/local/bin', item)|path_join }}"
175       loop:
176         - node
177         - npm
178         - yarn
179         - yarnpkg
180     # Configuration to run Workbench
181     - name: Check fs.inotify.max_user_watches sysctl value
182       ansible.builtin.command:
183         cmd: /sbin/sysctl --values fs.inotify.max_user_watches
184       register: max_user_watches_value
185     - name: Increase fs.inotify.max_user_watches
186       vars:
187         max_user_watches_wanted: 524288
188       when: "max_user_watches_value.stdout|int < max_user_watches_wanted"
189       become: yes
190       ansible.builtin.command:
191         argv:
192           - sysctl
193           - "fs.inotify.max_user_watches={{ max_user_watches_wanted }}"
194       register: max_user_watches_set
195     - name: Set fs.inotify.max_user_watches permanently
196       when: max_user_watches_set.changed
197       become: yes
198       ansible.builtin.copy:
199         content: |
200           ### This file is managed by Ansible
201           # React sets many inotify watchers and needs the limit increased.
202           {{ max_user_watches_set.stdout }}
203         dest: /etc/sysctl.d/arvados-workbench.conf
204         owner: root
205         group: root
206         mode: 0644
207
208     - ansible.builtin.include_role:
209         name: arvados_database
210       vars:
211         arvados_database_name: "{{ arvados_cluster.PostgreSQL.Connection.dbname }}"
212         arvados_database_user_name: "{{ arvados_cluster.PostgreSQL.Connection.user }}"
213         arvados_database_user_password: "{{ arvados_cluster.PostgreSQL.Connection.password }}"
214         # Let the test user drop and recreate the database wholesale
215         arvados_database_role_attr_flags: CREATEDB
216
217     - name: Set up Arvados development user
218       become: yes
219       ansible.builtin.user:
220         name: "{{ arvados_dev_user }}"
221         groups:
222           - docker
223         append: yes
224       register: dev_user
225     - name: Set up .config/arvados
226       become: yes
227       become_user: "{{ arvados_dev_user }}"
228       ansible.builtin.file:
229         path: "{{ (dev_user.home, item)|path_join }}"
230         state: directory
231       loop:
232         - .config
233         - .config/arvados
234     - name: Write arvados/config.yml for testing
235       become: yes
236       become_user: "{{ arvados_dev_user }}"
237       ansible.builtin.copy:
238         src: "{{ arvados_config_file }}"
239         dest: "{{ (dev_user.home, '.config/arvados/config.yml')|path_join }}"
240         mode: 0600
241     - name: Add Arvados test configuration to profile.d
242       become: yes
243       ansible.builtin.copy:
244         content: |
245           if [ -z "${CONFIGSRC:-}" ] && [ -e ~/.config/arvados/config.yml ]; then
246             export CONFIGSRC="$HOME/.config/arvados"
247           fi
248         dest: /etc/profile.d/arvados-test.sh