ci / test (push) Successful in 28s
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
58 lines
2.3 KiB
YAML
58 lines
2.3 KiB
YAML
# NEX-Websuche (SearXNG) in k3s (D6-Umzugstest). Läuft auf ops: ansible-playbook playbooks/nex-searxng-k3s.yml
|
|
# Secret SEARXNG_SECRET wird einmal erzeugt und bleibt im Cluster (nicht im Repo, nicht auf ops).
|
|
- name: SearXNG nach k3s
|
|
hosts: localhost
|
|
connection: local
|
|
gather_facts: false
|
|
vars:
|
|
manifests: "{{ playbook_dir }}/../../../../deploy/k8s/nex-searxng"
|
|
tasks:
|
|
- name: Namespace nex
|
|
ansible.builtin.command: kubectl apply -f {{ playbook_dir }}/../../../../deploy/k8s/nex-speech/namespace.yaml
|
|
register: ns
|
|
changed_when: "'created' in ns.stdout"
|
|
|
|
- name: Secret vorhanden?
|
|
ansible.builtin.command: kubectl -n nex get secret nex-searxng
|
|
register: secret
|
|
failed_when: false
|
|
changed_when: false
|
|
|
|
- name: Secret anlegen (zufällig, 64 Hex-Zeichen)
|
|
ansible.builtin.shell: kubectl -n nex create secret generic nex-searxng --from-literal=SEARXNG_SECRET=$(openssl rand -hex 32)
|
|
when: secret.rc != 0
|
|
no_log: true
|
|
|
|
- name: ConfigMap aus settings.yml
|
|
ansible.builtin.shell: >
|
|
kubectl -n nex create configmap nex-searxng-settings --from-file=settings.yml={{ manifests }}/settings.yml
|
|
--dry-run=client -o yaml | kubectl apply -f -
|
|
register: cm
|
|
changed_when: "'configured' in cm.stdout or 'created' in cm.stdout"
|
|
|
|
- name: Deployment und Service
|
|
ansible.builtin.command: kubectl apply -f {{ manifests }}/deployment.yaml
|
|
register: dep
|
|
changed_when: "'configured' in dep.stdout or 'created' in dep.stdout"
|
|
|
|
- name: Neustart, wenn sich die Einstellungen geändert haben
|
|
ansible.builtin.command: kubectl -n nex rollout restart deployment/nex-searxng
|
|
when: cm.changed and not dep.changed
|
|
|
|
- name: Warten, bis bereit
|
|
ansible.builtin.command: kubectl -n nex rollout status deployment/nex-searxng --timeout=300s
|
|
changed_when: false
|
|
|
|
- name: Suchtest über NodePort (Knoten k3s)
|
|
ansible.builtin.uri:
|
|
url: "http://{{ hostvars['k3s'].ansible_host }}:30880/search?q=Proxmox&format=json"
|
|
return_content: true
|
|
register: probe
|
|
until: probe.status == 200 and (probe.json.results | length) > 0
|
|
retries: 6
|
|
delay: 5
|
|
|
|
- name: Ergebnis
|
|
ansible.builtin.debug:
|
|
msg: "{{ probe.json.results | length }} Treffer, erster: {{ probe.json.results[0].url }}"
|