Skip to content

Commit 16bfdde

Browse files
committed
WIP podman
1 parent 85558f2 commit 16bfdde

File tree

7 files changed

+141
-9
lines changed

7 files changed

+141
-9
lines changed

locations/pktpls.yml

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,99 @@ hosts:
1212
role: corerouter
1313
model: "x86-64"
1414
openwrt_version: snapshot
15+
imagebuilder_config:
16+
CONFIG_TARGET_ROOTFS_PARTSIZE: 256
17+
# host__disabled_services__to_merge:
18+
# - bgpdisco
19+
host__packages__to_merge:
20+
- podman conmon crun catatonit netavark external-protocol
21+
host__rclocal__to_merge:
22+
- "sed -i 's|#firewall_driver|firewall_driver|g' /etc/containers/containers.conf"
23+
# - "mount /dev/nvme0n1p1 /mnt/data"
24+
host__files__to_merge:
25+
# podman run -it --net bridge:ip6=2001:bf7:750:5503::2,ip=10.31.174.146 --dns 10.31.174.145 --no-hosts docker.io/library/alpine:edge
26+
- path: /etc/init.d/hway-buildbot1
27+
mode: 0755
28+
content: |
29+
#!/bin/sh /etc/rc.common
30+
USE_PROCD=1
31+
START=99
32+
STOP=1
33+
password="trustno1"
34+
name="hway-buildbot1"
35+
ip6="2001:bf7:750:5503::2"
36+
ip4="10.31.174.146"
37+
dns="10.31.174.145"
38+
start_service() {
39+
podman build -t buildworker /usr/share/buildworker
40+
procd_open_instance
41+
procd_set_param command /usr/bin/podman run -it --net bridge:ip6=$ip6,ip=$ip4 --dns $dns --no-hosts --name $name buildworker
42+
procd_set_param respawn 60 10 0 # respawn indefinitely, wait 10s before retry
43+
procd_set_param env \
44+
BUILDWORKER_NAME=$name \
45+
BUILDWORKER_PASSWORD=$password \
46+
BUILDWORKER_MASTER=buildbot.berlin.freifunk.net \
47+
BUILDWORKER_ADMIN=pktpls@systemli.org \
48+
BUILDWORKER_DESCRIPTION=Container testing
49+
procd_close_instance
50+
}
51+
- path: /usr/share/buildworker/Dockerfile
52+
mode: 0644
53+
content: |
54+
FROM docker.io/library/debian:11
55+
MAINTAINER pktpls@systemli.org
56+
ARG DEBIAN_FRONTEND=noninteractive
57+
ARG BUILDBOT_VERSION=2.10.1
58+
USER root
59+
RUN apt-get update && apt-get install -y build-essential ccache curl file gawk g++-multilib gcc-multilib genisoimage git-core gosu libdw-dev libelf-dev libncurses5-dev locales pv pwgen python3 python3-venv python3-pip python3-pyelftools python3-cryptography qemu-utils rsync signify-openbsd subversion swig unzip wget zstd && apt-get clean && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
60+
RUN python3 -m venv /opt/venv
61+
ENV PATH="/opt/venv/bin:$PATH"
62+
RUN pip3 install -U pip
63+
RUN pip3 install "buildbot-worker==$BUILDBOT_VERSION" pyelftools pyOpenSSL service_identity
64+
ENV LANG=en_US.utf8
65+
COPY entry.sh /entry.sh
66+
COPY start.sh /start.sh
67+
RUN groupadd buildbot && useradd --create-home --home-dir /builder --comment "Freifunk Berlin buildbot" --gid buildbot --shell /bin/bash buildbot && chown buildbot:buildbot /builder && chmod 0755 /entry.sh /start.sh
68+
VOLUME [ "/builder" ]
69+
ENTRYPOINT [ "/entry.sh" ]
70+
CMD [ "/start.sh" ]
71+
- path: /usr/share/buildworker/entry.sh
72+
mode: 0755
73+
content: |
74+
#!/usr/bin/env bash
75+
chown buildbot:buildbot /builder
76+
/usr/sbin/gosu buildbot "$@"
77+
- path: /usr/share/buildworker/start.sh
78+
mode: 0755
79+
content: |
80+
#!/usr/bin/env bash
81+
cleanup_buildworker_env_variables() {
82+
for var in "${!BUILDWORKER_@}"; do
83+
unset "$var"
84+
done
85+
}
86+
[ -n "$BUILDWORKER_NAME" ] || {
87+
echo "Please supply a name via --env BUILDWORKER_NAME=XXX" >&2
88+
exit 1
89+
}
90+
[ -n "$BUILDWORKER_PASSWORD" ] || {
91+
echo "Please supply a password via --env BUILDWORKER_PASSWORD=XXX" >&2
92+
exit 2
93+
}
94+
rm -f /builder/buildbot.tac
95+
/opt/venv/bin/buildbot-worker create-worker \
96+
--force \
97+
--umask="0o22" \
98+
${BUILDWORKER_TLS:+--connection-string="SSL:$BUILDWORKER_MASTER"} \
99+
/builder \
100+
"$BUILDWORKER_MASTER" \
101+
"$BUILDWORKER_NAME" \
102+
"$BUILDWORKER_PASSWORD"
103+
echo "$BUILDWORKER_ADMIN" > /builder/info/admin
104+
echo "$BUILDWORKER_DESCRIPTION" > /builder/info/host
105+
cleanup_buildworker_env_variables
106+
rm -f /builder/twistd.pid
107+
exec /opt/venv/bin/buildbot-worker start --nodaemon /builder
15108
16109
# Custom APK feed: snapshot
17110
# feed: "file:///home/user/w/ff/falter-packages/out/main/x86_64/falter/packages.adb"
@@ -27,7 +120,7 @@ location__packages__to_merge:
27120
# 10.31.174.128/26 - pktpls+bbb@systemli.org
28121
# - 10.31.174.128/29 - mgmt
29122
# - 10.31.174.136/29 - mesh
30-
# - 10.31.174.144/28 - prdhcp
123+
# - 10.31.174.144/28 - podman
31124
# - 10.31.174.160/27 - dhcp
32125
ipv6_prefix: 2001:bf7:750:5500::/56
33126

@@ -58,10 +151,17 @@ networks:
58151
assignments:
59152
pktpls-core: 1
60153

154+
- role: podman
155+
ifname: podman0
156+
prefix: 10.31.174.144/28
157+
ipv6_subprefix: 3
158+
assignments:
159+
pktpls-buildbot1: 2
160+
161+
# DHCP is available on both eth0.50 and eth1 in the MV
61162
# - vid: 50
62163
# role: uplink
63164
# untagged: false
64-
65165
- vid: 50
66166
ifname: eth1
67167
role: uplink

roles/cfg_openwrt/templates/common/config/bgpdisco_nameservice.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config static-entry
2424
{% for host, ip_num in network['assignments'].items() if host != inventory_hostname %}
2525
config static-entry
2626
option host '{{ host }}'
27+
{# TODO: ipv6 address #}
2728
list ip '{{ network['prefix'] | ansible.utils.ipaddr(ip_num) | ansible.utils.ipaddr('address') }}'
2829

2930
{% endfor %}

roles/cfg_openwrt/templates/common/config/network.j2

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ config interface '{{ name }}'
7777
{% else %}
7878
option proto 'none'
7979
{% endif %}
80-
{% endif %}
81-
{% if role == 'corerouter' and ipv6_prefix is defined %}
82-
{% if 'ipv6_subprefix' in network %}
83-
{% set subprefix = ipv6_prefix | ansible.utils.ipsubnet('64', network['ipv6_subprefix']) %}
80+
{% if role == 'corerouter' and ipv6_prefix is defined %}
81+
{% if 'ipv6_subprefix' in network %}
82+
{% set subprefix = ipv6_prefix | ansible.utils.ipsubnet('64', network['ipv6_subprefix']) %}
8483
option ip6addr '{{ subprefix | ansible.utils.ipaddr(1) | ansible.utils.ipaddr('address') }}/{{ '128' if network['role'] == 'mesh' else '64' }}'
84+
{% endif %}
8585
{% endif %}
8686
{% endif %}
8787

@@ -95,6 +95,12 @@ config device
9595
list ports '{{ libnetwork.getPortIfname(network) }}'
9696
{% endif %}
9797

98+
{% if role == 'corerouter' and network['role'] == 'podman' %}
99+
config interface '{{ name }}'
100+
option device '{{ network['ifname'] }}'
101+
option proto 'external'
102+
{% endif %}
103+
98104
{% endfor %}
99105
{% for i in mac_override|default({}) %}
100106
config device '{{ i }}_dev'

roles/cfg_openwrt/templates/corerouter/config/dhcp.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ config domain '{{ host | replace('-', '_') }}_olsr'
2727
{% endfor %}
2828
{% endfor %}
2929

30-
{% for network in networks | rejectattr('role', 'in', ['uplink', 'mesh', 'tunnel', 'ext']) %}
30+
{% for network in networks | rejectattr('role', 'in', ['uplink', 'mesh', 'tunnel', 'ext', 'podman']) %}
3131
{% set name = network['name'] if 'name' in network else network['role'] %}
3232

3333
config dhcp 'dhcp_{{ name }}'

roles/cfg_openwrt/templates/corerouter/config/firewall.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ config zone 'zone_freifunk'
1919
{% endfor %}
2020
list device 'wg_+'
2121
list device 'ts_+'
22+
list device 'podman+'
2223

2324
{% for i in l3_networks | selectattr('inbound_filtering') %}
2425
config zone 'zone_{{ i['name'] }}'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "podman",
3+
"id": "4899b42442372b0a1788ff4a94df70be628ca5c228f64eea518e59b797d6d3e1",
4+
"driver": "bridge",
5+
"network_interface": "podman0",
6+
"created": "2024-12-23T00:00:00.000000000Z",
7+
"subnets": [
8+
{
9+
"subnet": "10.31.174.144/28",
10+
"gateway": "10.31.174.145"
11+
},
12+
{
13+
"subnet": "2001:bf7:750:5503::/64",
14+
"gateway": "2001:bf7:750:5503::1"
15+
}
16+
],
17+
"ipv6_enabled": true,
18+
"internal": false,
19+
"dns_enabled": false,
20+
"ipam_options": {
21+
"driver": "host-local"
22+
}
23+
}

roles/cfg_openwrt/templates/libraries/network.j2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
{% macro isBridgeNeeded(network) %}
4848
{{- (getUciIfname(network) in getWirelessNetworks()
4949
or (role == 'ap' and network.get('mesh_ap') == inventory_hostname)
50-
or (role == 'corerouter' and network['role'] == 'uplink' and network.get('uplink_mode') != 'direct')) | to_json -}}
50+
or (role == 'corerouter' and network['role'] == 'uplink' and network.get('uplink_mode') != 'direct')
51+
or (role == 'corerouter' and network['role'] == 'podman')) | to_json -}}
5152
{% endmacro %}
5253

5354
{# Do we need to configure a port or is this network only connected local (e.g. Mesh Endpoint on the core router)
5455
# Warning: returns a bool. Use |from_json filter when calling #}
5556
{% macro isPortNeeded(network) %}
56-
{{- (not (role == 'corerouter' and network.get('mesh_ap') == inventory_hostname)) | to_yaml -}}
57+
{{- (not (role == 'corerouter' and (network.get('mesh_ap') == inventory_hostname or network['role'] == 'podman'))) | to_yaml -}}
5758
{% endmacro %}
5859

5960
{# Retrieve the networks which shall be bridged to wifi

0 commit comments

Comments
 (0)