1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 # privilege-nspawn-vm.yml - Add privileges to a systemd-nspawn VM to run
8 # Run this playbook on a host with systemd-nspawn installed. It will configure a
9 # named VM container with all of the privileges necessary to run different Arvados
12 # You MUST run this playbook with the `container_name` variable set to the name
13 # of the VM to configure.
15 # By default the playbook grants privileges required for all Arvados components.
16 # You can revoke the privileges for a component by setting any of the variables
17 # `docker_privileges`, `fuse_privileges`, or `singularity_privileges` to the
18 # string 'absent'. For example, if you're building a compute node VM that only
19 # uses the Docker compute engine, you could set `singularity_privileges=absent`
20 # to avoid granting privileges that are only required for Singularity.
22 - name: Add privileges to systemd-nspawn VM
27 docker_privileges: present
28 fuse_privileges: present
29 singularity_privileges: present
30 nspawn_container_conffile: "/etc/systemd/nspawn/{{ container_name }}.nspawn"
31 nspawn_service_conffile: "/etc/systemd/system/systemd-nspawn@{{ container_name }}.service.d/arvados-ansible.conf"
34 community.general.ini_file:
43 - name: Create systemd-nspawn drop-in directory
46 path: "{{ nspawn_service_conffile|dirname }}"
51 - name: Control access to FUSE device
52 community.general.ini_file:
53 state: "{{ fuse_privileges }}"
54 path: "{{ nspawn_service_conffile }}"
60 - name: Control access to block loop devices
61 community.general.ini_file:
62 state: "{{ singularity_privileges }}"
63 path: "{{ nspawn_service_conffile }}"
66 value: "block-loop rwm"
68 - name: Control block loop device ordering
69 community.general.ini_file:
70 state: "{{ singularity_privileges }}"
71 path: "{{ nspawn_service_conffile }}"
74 value: "modprobe@loop.service"
80 - name: Filter system calls for Docker
81 community.general.ini_file:
82 state: "{{ docker_privileges }}"
83 path: "{{ nspawn_container_conffile }}"
85 option: SystemCallFilter
92 - name: Map private users for Singularity
93 community.general.ini_file:
94 state: "{{ singularity_privileges }}"
95 path: "{{ nspawn_container_conffile }}"
100 - name: Bind FUSE device
101 community.general.ini_file:
102 state: "{{ fuse_privileges }}"
103 path: "{{ nspawn_container_conffile }}"
108 - name: Bind block loop control device
109 community.general.ini_file:
110 state: "{{ singularity_privileges }}"
111 path: "{{ nspawn_container_conffile }}"
114 value: /dev/loop-control
117 - name: daemon-reload
118 ansible.builtin.systemd_service: