Project

General

Profile

Hacking prerequisites » History » Version 79

Brett Smith, 01/08/2025 04:03 PM
expand Ansible database details

1 1 Tom Clegg
{{>toc}}
2
3
h1. Hacking prerequisites
4
5
The Arvados test suite can run in a Docker container, a VM, or your workstation -- provided a few prerequisites are satisfied.
6
7
h2. Host options
8
9
h3. Starting on your workstation
10
11 70 Ward Vandewege
If your workstation is a debian buster system -- and you don't mind installing a bunch of packages on your workstation, some of them without apt -- the easiest way to get running is to run tests on bare metal. Skip to "Dependencies".
12 1 Tom Clegg
13
Other linux distributions should work too with some modifications, but it's probably easier to use a VM.
14
15
h3. Starting on a VM
16
17 71 Ward Vandewege
Another option is to create a virtual machine using something like Xen or VirtualBox, and run debian buster on it. The instructions below assume you have just a few basic requirements:
18 1 Tom Clegg
* SSH server
19
* sudo (@apt-get install sudo@)
20
* A user account with sudo privileges
21
22
h3. Starting in a docker container
23
24 55 Peter Amstutz
_[[Arvbox]] provides a preinstalled Docker-based dev environment.  The following instructions are for creating a dev environment inside Docker from scratch._
25
26 1 Tom Clegg
This can get you started quickly, but (unlike the above options) you'll need to remember to use something like @docker commit@ to save your state before shutting down your container.
27
28
See http://docker.io for more about installing docker. On debian it looks something like this.
29
30
<pre>
31 54 Tom Clegg
sudo apt-get install docker-ce
32 1 Tom Clegg
sudo adduser $USER docker
33
# {log out & log back in}
34
groups
35
# {should include "docker"}
36
</pre>
37
38 69 Ward Vandewege
Start up a new container with debian 10 (buster), make a new user and log in as that user:
39 1 Tom Clegg
40
<pre>
41 69 Ward Vandewege
docker run -it --privileged debian:10 bash
42 1 Tom Clegg
apt-get update
43 34 Tom Clegg
apt-get -y install sudo
44 1 Tom Clegg
adduser me
45 33 Tom Clegg
adduser me sudo
46 1 Tom Clegg
sudo -u me -i
47
</pre>
48 12 Joshua Randall
49 15 Tom Clegg
The &quot;--privileged&quot; is required in order for /dev/fuse to be accessible (without it, no tests that require FUSE will work).
50 1 Tom Clegg
51
h2. Install dev environment
52
53 78 Brett Smith
h3. With Ansible
54
55
This is a prototype still in development, but initial development was done in January 2025 and it can automate much of the process for you.
56
57
h4. Install Ansible
58
59
The simplest thing to do is @pip install@ Ansible inside a virtualenv:
60
61
<pre><code class="shell">sudo apt install python3-venv
62
python3 -m venv ~/arvados-ansible
63
~/arvados-ansible/bin/pip install "ansible~=8.7"
64
</code></pre>
65
66
If that works, you're done and you can go on to the next section. For background:
67
68
* The Arvados Ansible playbooks are tested with Ansible 8, which we use for its Python version compatibility. Older versions are known not to work. You're welcome to try newer versions if you want to for any reason, but they haven't been tested.
69
70
* There are "other installation options":https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html if you can't do this for some reason.
71
72
h4. Write an Arvados database configuration
73
74
Next, write an Arvados configuration file that defines how you want to set up the PostgreSQL database. Write a file @~/arvados-ansible/zzzzz.yml@ like this:
75
76
<pre><code class="yaml">Clusters:
77
  zzzzz:
78
    PostgreSQL:
79
      Connection:
80
        user: arvados
81
        password: GoodPasswordHere
82
        dbname: arvados_development
83
        host: localhost
84
        port: "5432"
85
</code></pre>
86
87 79 Brett Smith
The cluster ID must be @zzzzz@. You can change the @user@, @password@, and @dbname@ settings freely. Our Ansible playbook will configure PostgreSQL so your settings here work.
88
89
The playbook will always install the @postgresql@ server package. If you already have this installed and have configured it to listen somewhere other than the default, you may update @host@ and @port@ to reflect that. Note that @port@ is a string containing digits.
90
91 78 Brett Smith
92
h4. Write an Ansible inventory
93
94
An inventory file tells Ansible what host(s) to manage and how to connect to them. If you've installed Ansible on the same system where you want to install a test environment, write this inventory file to @~/arvados-ansible/inventory.ini@:
95
96
<pre><code class="ini">[arvados-test]
97
localhost ansible_connection=local
98
</code></pre>
99
100
If that's sufficient, you can skip to the next section. If you want to do something fancier, like having Ansible install a test environment on one or more remote hosts, refer to the "Ansible inventory documentation":https://docs.ansible.com/ansible/latest/getting_started/get_started_inventory.html to learn how to write your own.
101
102
h4. Run the playbook
103
104
The basic command to run the playbook is:
105
106
<pre><code class="sh">cd arvados/tools/compute-images/ansible
107
~/arvados-ansible/bin/ansible-playbook -e "arvados_config=$HOME/arvados-ansible/zzzzz.yml" -i ~/arvados-ansible/inventory.ini -K install-test-env.yml</code></pre>
108
109
There are some things you should know about how the playbook will work:
110
111
* It will add a user account to the @docker@ group in order to be able to run tests. By default it uses the name of the account running Ansible. If you want to use a different account for Arvados testing, define @arvados_dev_user@ inside the @-e@ argument; e.g., <pre><code class="sh">~/arvados-ansible/bin/ansible-playbook -e "arvados_dev_user=USERNAME arvados_config=$HOME/arvados-ansible/zzzzz.yml" …</code></pre>
112
113
* It will install symlinks for Go, Node, Singularity, and Yarn under @/usr/local/bin@. The actual tools are installed under @/opt@. If you need different versions of these tools for other work, you'll need to customize your @PATH@ environment variable so the Arvados versions are found first when you're doing Arvados work.
114
115
h3. Manually
116 76 Brett Smith
117
Start with Debian 10+ and run the following commands as root.
118 36 Tom Clegg
119 67 Tom Clegg
Note that the last command here ("arvados-server install -type test") installs additional debian packages to your system, along with additional software in /var/lib/arvados/ (such as suitable versions of Ruby and Go) that do not interfere with system packages. It also creates a postgresql database user named "arvados" with an insecure password. Don't expose this postgresql server to the internet or to untrusted users!
120 1 Tom Clegg
121 72 Ward Vandewege
<pre>
122 75 Tom Clegg
apt update
123
apt install wget ca-certificates
124
wget https://apt.arvados.org/bullseye/pool/main/a/arvados-server/arvados-server_2.4.3-1_amd64.deb
125
dpkg -i arvados-server_2.4.3-1_amd64.deb
126
arvados-server install -type test
127 74 Ward Vandewege
</pre>
128 73 Ward Vandewege
129 77 Tom Clegg
Alternatively, install Go &ge; 1.20 (see https://golang.org) and git, and run arvados-server from source.
130 73 Ward Vandewege
131 1 Tom Clegg
<pre>
132 77 Tom Clegg
wget -O- https://go.dev/dl/go1.22.1.linux-amd64.tar.gz | tar -C /usr/local -xzf -
133
ln -s /usr/local/go/bin/* /usr/local/bin/
134
135
apt install git build-essential libpam-dev
136
137 1 Tom Clegg
cd
138
git clone https://git.arvados.org/arvados.git
139 68 Ward Vandewege
cd arvados
140 67 Tom Clegg
go mod download
141 77 Tom Clegg
go run ./cmd/arvados-server install -type test
142 1 Tom Clegg
</pre>
143
144
h2. Start Postgres
145
146
_If you're running in a docker container_ you'll need to start Postgres manually:
147 9 Joshua Randall
148 47 Tom Clegg
<pre>
149 11 Joshua Randall
sudo /etc/init.d/postgresql start
150 60 Peter Amstutz
</pre>
151
152
(If you're on a regular workstation/server/VM, startup scripts have already taken care of that for you.)
153
154
h2. Setup groups
155
156
Make sure the fuse and docker groups exist (create them if necessary) and that the user who will run the tests is a member of them.
157 1 Tom Clegg
158
h2. Run tests
159
160
<pre>
161 67 Tom Clegg
time ~/arvados/build/run-tests.sh WORKSPACE=~/arvados
162 1 Tom Clegg
</pre>
163
164 14 Tom Clegg
During development, you'll probably want something more like this. It reuses the given temp directory, which avoids a lot of repetitive downloading of dependencies, and allows you to save time with @--skip-install@ or @--only-install sdk/ruby@ and so on.
165 1 Tom Clegg
166
<pre>
167 23 Tom Clegg
mkdir -p ~/.cache/arvados-build
168 67 Tom Clegg
time ~/arvados/build/run-tests.sh WORKSPACE=~/arvados --temp ~/.cache/arvados-build
169 1 Tom Clegg
</pre>