Skip to content

Commit f0e1327

Browse files
committed
test(tmachine): let environments add gateway driver settings
An environment can write settings to /etc/openshell-test/driver.toml, and the installers add them to the active driver's table in gateway.toml. The binaries installer renders them into its gateway.toml for Docker and Podman. The packaged installer writes the service user's operator gateway.toml only when an environment supplies settings, so lanes without them keep using the package defaults. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent e470b17 commit f0e1327

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎tests/tmachine/ansible/roles/openshell_gateway/tasks/detect.yaml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@
2020
and not tmachine_container_runtime_is_rootless else tmachine_container_runtime_tmachine_uid.stdout }}
2121
openshell_gateway_bind_address: "{{ '127.0.0.1:17670' if tmachine_container_runtime_name == 'docker' else '0.0.0.0:17670' }}"
2222
openshell_runtime_socket: "{{ tmachine_container_runtime_socket }}"
23+
24+
# An environment can add settings to the active driver's gateway.toml table,
25+
# such as `allow_driver_config`, by writing them to this file in the guest.
26+
- name: Check for environment driver settings
27+
ansible.builtin.stat:
28+
path: /etc/openshell-test/driver.toml
29+
register: openshell_gateway_driver_file
30+
31+
- name: Read environment driver settings
32+
ansible.builtin.slurp:
33+
src: /etc/openshell-test/driver.toml
34+
register: openshell_gateway_driver_slurp
35+
when: openshell_gateway_driver_file.stat.exists
36+
37+
- name: Select environment driver settings
38+
ansible.builtin.set_fact:
39+
openshell_gateway_driver_settings: >-
40+
{{ openshell_gateway_driver_slurp.content | b64decode | trim
41+
if openshell_gateway_driver_file.stat.exists else '' }}

‎tests/tmachine/ansible/roles/openshell_gateway/templates/gateway-docker.toml.j2‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ socket_path = "{{ openshell_runtime_socket }}"
77
image_pull_policy = "if_not_present"
88
sandbox_label = "tmachine"
99
grpc_endpoint = "http://127.0.0.1:17670"
10+
{% if openshell_gateway_driver_settings %}
11+
{{ openshell_gateway_driver_settings }}
12+
{% endif %}
1013
{% endblock %}

‎tests/tmachine/ansible/roles/openshell_gateway/templates/gateway-podman.toml.j2‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ stop_timeout_secs = 15
1111
{% if openshell_gateway_podman_driver_settings %}
1212
{{ openshell_gateway_podman_driver_settings }}
1313
{% endif %}
14+
{% if openshell_gateway_driver_settings %}
15+
{{ openshell_gateway_driver_settings }}
16+
{% endif %}
1417
{% endblock %}

‎tests/tmachine/ansible/roles/openshell_packaged_gateway/tasks/main.yaml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@
4141
group: "{{ openshell_gateway_user }}"
4242
mode: "0700"
4343

44+
# The package's service reads this operator-owned file when it exists, so write
45+
# it only for an environment that adds driver settings (see detect.yaml). The
46+
# images and driver still come from the environment file below.
47+
- name: Configure environment driver settings
48+
become: true
49+
ansible.builtin.copy:
50+
dest: "{{ openshell_gateway_home }}/.config/openshell/gateway.toml"
51+
owner: "{{ openshell_gateway_user }}"
52+
group: "{{ openshell_gateway_user }}"
53+
mode: "0600"
54+
content: |
55+
[openshell]
56+
version = 2
57+
58+
[openshell.drivers.{{ openshell_gateway_driver }}]
59+
{{ openshell_gateway_driver_settings }}
60+
when: openshell_gateway_driver_settings | length > 0
61+
4462
# Exercise the package-owned service's environment-file mechanism without
4563
# generating operator-owned gateway TOML. Preflight and startup must resolve
4664
# the same candidate runtime images.

0 commit comments

Comments
 (0)