Files
ansible-pull/roles/omada-controller/tasks/main.yml
T
rene 97c64189c5 apt: use deb822_repository only on ansible-core >= 2.15
ansible.builtin.deb822_repository was added in ansible-core 2.15. Hosts
running an older ansible-core cannot use it at all, so gate the choice of
module on the runtime version.

Introduce the shared role apt_repos (tasks_from: add) which takes a
single structured apt_repo dict and:
- uses deb822_repository when ansible_version.full >= 2.15 and removes
  the legacy .list file,
- falls back to apt_repository (still available before its removal in
  2.25) and builds the equivalent 'deb [opts] uri suite components' line
  otherwise.

All six repository definitions now go through the role, keeping the
deb822 and legacy representations in sync from one source of truth. The
backup role's repository task keeps its tags via apply, and its tailscale
install updates the apt cache explicitly since the previously notified
'update apt cache' handler does not exist.
2026-10-23 09:13:42 +02:00

83 lines
2.8 KiB
YAML
Executable File

# SPDX-License-Identifier: MIT-0
---
# tasks file for roles/omada-controller
# roles/omada-controller/tasks/main.yml
- name: Install dependencies for Omada Controller
# Der Controller benötigt Java, jsvc (Java Service Wrapper) und curl.
ansible.builtin.apt:
name:
- "{{ omada_controller_java_package }}"
- jsvc
- gnupg # Benötigt für gpg --dearmor
- curl
- apt-transport-https
- python3-debian # Benötigt für deb822_repository
state: present
update_cache: true
register: apt_install
retries: 3
until: apt_install is success
- name: Download MongoDB GPG key
ansible.builtin.get_url:
url: "https://www.mongodb.org/static/pgp/server-{{ omada_controller_mongodb_version }}.asc"
dest: "/tmp/mongodb-server-{{ omada_controller_mongodb_version }}.asc"
mode: '0644'
- name: Dearmor MongoDB GPG key and place in /usr/share/keyrings
ansible.builtin.command:
cmd: "gpg --dearmor -o /usr/share/keyrings/mongodb-archive-keyring.gpg /tmp/mongodb-server-{{ omada_controller_mongodb_version }}.asc"
creates: /usr/share/keyrings/mongodb-archive-keyring.gpg
# Hinweis: Der Pfad /usr/share/keyrings/ ist der empfohlene Ort für Schlüssel, die mit 'signed-by' verwendet werden.
- name: Add MongoDB repository
include_role:
name: apt_repos
tasks_from: add
vars:
apt_repo:
name: "mongodb-org-{{ omada_controller_mongodb_version }}"
uris: "https://repo.mongodb.org/apt/debian"
suites: "{{ omada_controller_mongodb_repo_release }}/mongodb-org/{{ omada_controller_mongodb_version }}"
components:
- main
architectures:
- amd64
- arm64
signed_by: /usr/share/keyrings/mongodb-archive-keyring.gpg
# Der 'signed-by'-Parameter verweist auf den zuvor dearmored Schlüssel.
- name: Install MongoDB server
# Der Omada Controller benötigt MongoDB >= 3.0.0.
ansible.builtin.apt:
name: mongodb-org-server
state: present
update_cache: true
register: mongodb_install
retries: 3
until: mongodb_install is success
- name: Check if Omada Controller package 'tpeap' is already installed (using command)
ansible.builtin.command: dpkg-query -W -f='${Status}' tpeap
register: omada_pkg_status
# Fail silently if package is not found, and never report a change.
failed_when: false
changed_when: false
- name: Install Omada Controller from URL
ansible.builtin.apt:
deb: "{{ omada_controller_deb_url }}"
state: present
when: "'install ok installed' not in omada_pkg_status.stdout"
register: omada_install
retries: 3
until: omada_install is success
notify: Restart Omada Controller
- name: Ensure Omada Controller service (tpeap) is running and enabled on boot
ansible.builtin.service:
name: tpeap
state: started
enabled: true