Le dorsal confie chaque application cliente au role de son environnement (app_python, app_statique) ; le controleur lit son depot a la forge du site (scripts/app_source.py) et le depose au commit exact. Une sonde app-<application> par application remplace apps-servies et sites-servis. Une application cliente ne nomme plus son dorsal (instancier, P67). En production chez Chezlepro : monregistraire (nom interne, par l'edge) et le site web de Chezlepro (offre.chezlepro.ca, par le web frontal). serveur_powerdns vide le cache de l'Unbound colocalise quand une zone a bouge, ou quand son empreinte _plancher differe de celle de l'autoritatif. Pas 5 (applications-clientes.md 7) : make applications-porter, et make publier apres le genome, portent le depot de chaque application a la forge du site qui heberge la releve, prive, en avance rapide seulement. Pose vers TechnoLibre. Le runner lit aussi les depots de ses applications (forge_cles, forge_etancheite). CHANGELOG 259 a 265. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
146 lines
5.4 KiB
YAML
146 lines
5.4 KiB
YAML
---
|
|
# LES DEPENDANCES VIENNENT DE DEBIAN, PAR LE CACHE DU SITE (D-92). Avec `livrees`, des roues du
|
|
# depot, installees sans index : jamais Internet au deploiement.
|
|
- name: "Python : paquets Debian du contrat — {{ app_python_application.nom }}"
|
|
ansible.builtin.apt:
|
|
name: "{{ ['python3'] + (app_python_contrat.paquets | default([])) + (['python3-venv'] if app_python_livrees | bool else []) }}"
|
|
state: present
|
|
update_cache: true
|
|
cache_valid_time: 3600
|
|
register: app_python_paquets
|
|
|
|
- name: "Python : environnement des roues livrees — {{ app_python_application.nom }}"
|
|
ansible.builtin.command:
|
|
argv: [python3, -m, venv, --system-site-packages, "{{ app_python_venv }}"]
|
|
creates: "{{ app_python_venv }}/bin/python"
|
|
when:
|
|
- app_python_livrees | bool
|
|
- not ansible_check_mode
|
|
register: app_python_venv_cree
|
|
|
|
- name: "Python : les roues du depot — {{ app_python_application.nom }}"
|
|
ansible.builtin.find:
|
|
paths: "{{ app_python_application.dossier }}/{{ app_python_contrat.roues }}"
|
|
patterns: "*.whl"
|
|
register: app_python_roues
|
|
when: app_python_livrees | bool
|
|
|
|
- name: "Python : installer les roues, sans index — {{ app_python_application.nom }}"
|
|
ansible.builtin.command:
|
|
argv: >-
|
|
{{ [app_python_venv ~ '/bin/pip', 'install', '--no-index', '--find-links',
|
|
app_python_application.dossier ~ '/' ~ app_python_contrat.roues]
|
|
+ (app_python_roues.files | map(attribute='path') | list) }}
|
|
creates: "{{ app_python_venv }}/.setops-roues"
|
|
when:
|
|
- app_python_livrees | bool
|
|
- not ansible_check_mode
|
|
register: app_python_pip
|
|
|
|
- name: "Python : marquer les roues installees — {{ app_python_application.nom }}"
|
|
ansible.builtin.file:
|
|
path: "{{ app_python_venv }}/.setops-roues"
|
|
state: touch
|
|
modification_time: preserve
|
|
access_time: preserve
|
|
mode: "0644"
|
|
when:
|
|
- app_python_livrees | bool
|
|
- not ansible_check_mode
|
|
|
|
# L'ETAT VIT HORS DU CODE (`serveur_web_dorsal_etat_racine`) et systemd le monte la ou le contrat
|
|
# le place : l'application ecrit `data/` comme chez son developpeur, le code reste a root.
|
|
- name: "Python : son etat — {{ app_python_application.nom }}"
|
|
ansible.builtin.file:
|
|
path: "{{ app_python_etat_racine }}/{{ app_python_application.nom }}"
|
|
state: directory
|
|
owner: "{{ app_python_utilisateur }}"
|
|
group: "{{ app_python_utilisateur }}"
|
|
mode: "0750"
|
|
when: app_python_dossier_etat | length > 0
|
|
|
|
- name: "Python : le point de montage de son etat — {{ app_python_application.nom }}"
|
|
ansible.builtin.file:
|
|
path: "{{ app_python_application.dossier }}/{{ app_python_dossier_etat }}"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: "0755"
|
|
when:
|
|
- app_python_dossier_etat | length > 0
|
|
- not ansible_check_mode
|
|
|
|
- name: "Python : dossier des secrets — {{ app_python_application.nom }}"
|
|
ansible.builtin.file:
|
|
path: "{{ app_python_secrets_racine }}"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: "0700"
|
|
when: app_python_contrat.secrets | default([]) | length > 0
|
|
|
|
# SEULS LES NOMS QUE LE CONTRAT DECLARE : une valeur de trop dans la voute ne fuit pas ici.
|
|
- name: "Python : ses secrets, lisibles par root seul — {{ app_python_application.nom }}"
|
|
ansible.builtin.template:
|
|
src: secrets.env.j2
|
|
dest: "{{ app_python_secrets_racine }}/{{ app_python_application.nom }}.env"
|
|
owner: root
|
|
group: root
|
|
mode: "0600"
|
|
no_log: true
|
|
register: app_python_env
|
|
when: app_python_contrat.secrets | default([]) | length > 0
|
|
|
|
- name: "Python : unite systemd — {{ app_python_application.nom }}"
|
|
ansible.builtin.template:
|
|
src: app.service.j2
|
|
dest: "/etc/systemd/system/{{ app_python_unite }}.service"
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
register: app_python_service
|
|
|
|
- name: "Python : vhost nginx local — {{ app_python_application.nom }}"
|
|
ansible.builtin.template:
|
|
src: proxy.conf.j2
|
|
dest: "/etc/nginx/sites-available/{{ app_python_unite }}"
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
register: app_python_vhost
|
|
|
|
- name: "Python : activer le vhost — {{ app_python_application.nom }}"
|
|
ansible.builtin.file:
|
|
src: "/etc/nginx/sites-available/{{ app_python_unite }}"
|
|
dest: "/etc/nginx/sites-enabled/{{ app_python_unite }}"
|
|
state: link
|
|
force: "{{ ansible_check_mode }}"
|
|
register: app_python_lien
|
|
|
|
# PAS DE HANDLER : ce role est inclus une fois par application, et un handler ne verrait que les
|
|
# variables de la derniere. La bascule se fait ici, application par application.
|
|
- name: "Python : nginx accepte-t-il sa configuration ? — {{ app_python_application.nom }}"
|
|
ansible.builtin.command:
|
|
argv: [nginx, -t, -q]
|
|
changed_when: false
|
|
when:
|
|
- app_python_vhost is changed or app_python_lien is changed
|
|
- not ansible_check_mode
|
|
|
|
- name: "Python : recharger nginx — {{ app_python_application.nom }}"
|
|
ansible.builtin.systemd:
|
|
name: nginx
|
|
state: reloaded
|
|
when:
|
|
- app_python_vhost is changed or app_python_lien is changed
|
|
- not ansible_check_mode
|
|
|
|
- name: "Python : demarrer, ou redemarrer sur changement — {{ app_python_application.nom }}"
|
|
ansible.builtin.systemd:
|
|
name: "{{ app_python_unite }}"
|
|
enabled: true
|
|
daemon_reload: "{{ app_python_service is changed }}"
|
|
state: >-
|
|
{{ 'restarted' if (app_python_service is changed or app_python_env is changed
|
|
or app_python_paquets is changed or app_python_pip is changed) else 'started' }}
|
|
when: not ansible_check_mode
|