diff --git a/.forgejo/workflows/release-pipeline.yml b/.forgejo/workflows/release-pipeline.yml index b4e018a..e815b8c 100644 --- a/.forgejo/workflows/release-pipeline.yml +++ b/.forgejo/workflows/release-pipeline.yml @@ -52,6 +52,7 @@ jobs: - metadata - agent - dhcp + - two-hostsvc uses: ./.forgejo/workflows/build.yml with: tag: ${{ needs.set-release-target.outputs.release_cible }} @@ -80,6 +81,8 @@ jobs: name: dhcp@.service - path: systemd/metadata@.service name: metadata@.service + - path: systemd/two-hostsvc.service + name: two-hostsvc.service steps: - uses: actions/checkout@v3 - name: Move asset diff --git a/scripts/deploy.sh b/scripts/deploy.sh index c431697..c3574b6 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -116,7 +116,7 @@ start_services () { profile_units () { case "${1}" in - kvm) echo "agent.service dnsmasq@.service dhcp@.service metadata@.service" ;; + kvm) echo "two-hostsvc.service agent.service dnsmasq@.service dhcp@.service metadata@.service" ;; intel) echo "" ;; *) return 1 ;; esac @@ -124,7 +124,7 @@ profile_units () { profile_binaries () { case "${1}" in - kvm) echo "agent metadata dhcp run-dnsmasq-in-netns.sh run-dhcp-in-netns.sh" ;; + kvm) echo "agent metadata dhcp two-hostsvc run-dnsmasq-in-netns.sh run-dhcp-in-netns.sh" ;; intel) echo "" ;; *) return 1 ;; esac diff --git a/systemd/two-hostsvc.service b/systemd/two-hostsvc.service new file mode 100644 index 0000000..6250689 --- /dev/null +++ b/systemd/two-hostsvc.service @@ -0,0 +1,25 @@ +[Unit] +Description=two DNS and NTP relay of the VPCs +After=network.target +Before=agent.service + +[Service] +Type=simple +ExecStart=/opt/two/bin/two-hostsvc +Restart=on-failure +RuntimeDirectory=two/hostsvc +RuntimeDirectoryMode=0700 +RuntimeDirectoryPreserve=yes +CapabilityBoundingSet=CAP_SYS_ADMIN CAP_NET_BIND_SERVICE CAP_DAC_READ_SEARCH +NoNewPrivileges=yes +ProtectSystem=strict +ProtectHome=yes +PrivateTmp=yes +PrivateDevices=yes +ProtectKernelModules=yes +ProtectControlGroups=yes +LockPersonality=yes +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK + +[Install] +WantedBy=multi-user.target diff --git a/test/e2e/build.sh b/test/e2e/build.sh index 992c7ae..abba46f 100755 --- a/test/e2e/build.sh +++ b/test/e2e/build.sh @@ -4,25 +4,26 @@ E2E_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="$(cd "${E2E_DIR}/../.." && pwd)" BIN_DIR="${BIN_DIR:-${E2E_DIR}/topologies/bin}" SCRIPTS_DIR="${SCRIPTS_DIR:-${E2E_DIR}/topologies/scripts}" -BINARIES="agent dhcp metadata" +BINARIES="agent dhcp metadata two-hostsvc" +UNITS="two-hostsvc.service" SCRIPTS="bootstrap_kvm.sh" usage () { cat >&2 <&2 (cd "${REPO_DIR}" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${BIN_DIR}/${binary}" "./cmd/${binary}") || return 1 done + for unit in ${UNITS}; do + cp "${REPO_DIR}/systemd/${unit}" "${BIN_DIR}/${unit}" || return 1 + done for script in ${SCRIPTS}; do echo "== ${script}" >&2 cp "${REPO_DIR}/scripts/${script}" "${SCRIPTS_DIR}/${script}" || return 1 done - (cd "${BIN_DIR}" && sha256sum ${BINARIES} 2>/dev/null || shasum -a 256 ${BINARIES}) + (cd "${BIN_DIR}" && sha256sum ${BINARIES} ${UNITS} 2>/dev/null || shasum -a 256 ${BINARIES} ${UNITS}) } main () { diff --git a/test/e2e/topologies/evpn-2hv.yml b/test/e2e/topologies/evpn-2hv.yml index c89f668..890ec1a 100644 --- a/test/e2e/topologies/evpn-2hv.yml +++ b/test/e2e/topologies/evpn-2hv.yml @@ -36,10 +36,10 @@ nodes: segments: [underlay, lan], addresses: { underlay: 192.168.14.11, lan: 10.33.0.11 }, frr: frr/hv1.conf, provision: provision/hypervisor.sh, post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin, scripts: scripts }, - services: [agent.service] } + services: [two-hostsvc.service, agent.service] } hv2: { role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay, lan], addresses: { underlay: 192.168.14.12, lan: 10.33.0.12 }, frr: frr/hv2.conf, provision: provision/hypervisor.sh, post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin, scripts: scripts }, - services: [agent.service] } + services: [two-hostsvc.service, agent.service] } diff --git a/test/e2e/topologies/evpn-3hv.yml b/test/e2e/topologies/evpn-3hv.yml index d3b5d2c..a6eca62 100644 --- a/test/e2e/topologies/evpn-3hv.yml +++ b/test/e2e/topologies/evpn-3hv.yml @@ -36,18 +36,18 @@ nodes: segments: [underlay, lan], addresses: { underlay: 192.168.14.11, lan: 10.33.0.11 }, frr: frr/hv1.conf, provision: provision/hypervisor.sh, post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin, scripts: scripts }, - services: [agent.service] } + services: [two-hostsvc.service, agent.service] } hv2: { role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay, lan], addresses: { underlay: 192.168.14.12, lan: 10.33.0.12 }, frr: frr/hv2.conf, provision: provision/hypervisor.sh, post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin, scripts: scripts }, - services: [agent.service] } + services: [two-hostsvc.service, agent.service] } hv3: { role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay], addresses: { underlay: 192.168.14.13 }, frr: frr/hv3.conf, provision: provision/hypervisor.sh, post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin, scripts: scripts }, - services: [agent.service] } + services: [two-hostsvc.service, agent.service] } bd1: { role: host, image: debian12, cpus: 1, memory: 1024, segments: [underlay], addresses: { underlay: 192.168.14.21 }, frr: frr/bd1.conf, provision: provision/border.sh } diff --git a/test/e2e/topologies/provision/hypervisor.sh b/test/e2e/topologies/provision/hypervisor.sh index adff075..0990355 100755 --- a/test/e2e/topologies/provision/hypervisor.sh +++ b/test/e2e/topologies/provision/hypervisor.sh @@ -38,7 +38,17 @@ fi for binary in "${LAB_FILES}"/bin/*; do [ -f "${binary}" ] || continue name=$(basename "${binary}") + case "${name}" in *.service) continue ;; esac install -D -m 0755 "${binary}" "/opt/two/local/bin/${name}" ln -sfn "/opt/two/local/bin/${name}" "/opt/two/bin/${name}" echo "lab: ${name} compilé en local remplace celui de la release ${RELEASE}" done +for unit in "${LAB_FILES}"/bin/*.service; do + [ -f "${unit}" ] || continue + name=$(basename "${unit}") + install -m 0644 "${unit}" "/etc/systemd/system/${name}" + systemctl daemon-reload + systemctl enable "${name}" + systemctl restart "${name}" + echo "lab: unité ${name} de l'arbre local installée par-dessus la release ${RELEASE}" +done