From 5a800e46f9bd5123996525854605fcd6dc14a686 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <ynerant@crans.org>
Date: Fri, 14 Jan 2022 18:48:36 +0100
Subject: [PATCH] [constellation] Replace ComnPay configuration by Stripe, add
 Note Kfet configuration

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
---
 group_vars/constellation.yml                  | 16 ++++++----
 host_vars/constellation-dev.adm.crans.org.yml | 32 +++++++++++--------
 .../constellation/settings_local.py.j2        | 15 +++++++++
 3 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/group_vars/constellation.yml b/group_vars/constellation.yml
index 30709052..f560fc2d 100644
--- a/group_vars/constellation.yml
+++ b/group_vars/constellation.yml
@@ -1,6 +1,6 @@
 ---
 glob_constellation:
-  django_secret_key: "{{ vault.constellation_django_secret_key }}"
+  django_secret_key: "{{ vault.constellation.django_secret_key }}"
   admins:
     - ('Root', 'root@crans.org')
   allowed_hosts:
@@ -18,7 +18,7 @@ glob_constellation:
     host: "{{ query('ldap', 'ip', 'tealc', 'adm') | ipv4 | first }}"
     port: 5432
     user: 'constellation'
-    password: "{{ vault.constellation_django_db_password }}"
+    password: "{{ vault.constellation.django_db_password }}"
     name: 'constellation'
   front: true
   crontab: true
@@ -32,12 +32,16 @@ glob_constellation:
     - 'member'
     - 'topography'
     - 'unix'
-  comnpay:
-    tpe: 'VAD-941-415'
-    secret: '{{ vault.comnpay_secret }}'
+  stripe:
+    private_key: '{{ vault.constellation.stripe.live.private_key }}'
+    public_key: '{{ vault.constellation.stripe.live.public_key }}'
+  note:
+    url: 'https://note.crans.org/'
+    client_id: '{{ vault.constellation.note.client_id }}'
+    client_secret: '{{ vault.constellation.note.client_secret }}'
   debug: false
   owner: root
   group: _nounou
-  version: master
+  version: main
   settings_local_owner: www-data
   settings_local_group: _nounou
diff --git a/host_vars/constellation-dev.adm.crans.org.yml b/host_vars/constellation-dev.adm.crans.org.yml
index 3cb7621d..fe0fcc4d 100644
--- a/host_vars/constellation-dev.adm.crans.org.yml
+++ b/host_vars/constellation-dev.adm.crans.org.yml
@@ -9,19 +9,23 @@ loc_constellation:
   database:
     user: 'constellation-dev'
     name: 'constellation-dev'
-    applications:
-      - 'access'
-      - 'billing'
-      - 'dnsmanager'
-      - 'firewall'
-      - 'layers'
-      - 'management'
-      - 'member'
-      - 'topography'
-      - 'unix'
-      - 'debug'
-  comnpay:
-    tpe: 'HOM-832-854'
-    secret: '{{ vault.comnpay_homologation_secret }}'
+  applications:
+    - 'access'
+    - 'billing'
+    - 'debug'
+    - 'dnsmanager'
+    - 'firewall'
+    - 'layers'
+    - 'management'
+    - 'member'
+    - 'topography'
+    - 'unix'
+  stripe:
+    private_key: '{{ vault.constellation.stripe.test.private_key }}'
+    public_key: '{{ vault.constellation.stripe.test.public_key }}'
+  note:
+    url: 'https://note-dev.crans.org/'
+    client_id: '{{ vault.constellation.note.client_id }}'
+    client_secret: '{{ vault.constellation.note.client_secret }}'
   debug: true
   version: dev
diff --git a/roles/constellation/templates/constellation/settings_local.py.j2 b/roles/constellation/templates/constellation/settings_local.py.j2
index a396676f..b55d1e36 100644
--- a/roles/constellation/templates/constellation/settings_local.py.j2
+++ b/roles/constellation/templates/constellation/settings_local.py.j2
@@ -55,6 +55,21 @@ EMAIL_HOST_USER = '{{ constellation.email.user }}'
 EMAIL_HOST_PASSWORD = '{{ constellation.email.password }}'
 SERVER_EMAIL = '{{ constellation.email.from }}'
 DEFAULT_FROM_EMAIL = '{{ constellation.email.from_full }}'
+{% if constellation.front %}
+{% if constellation.comnpay is defined %}
 
 COMNPAY_ID_TPE = '{{ constellation.comnpay.tpe }}'
 COMNPAY_SECRET_KEY = '{{ constellation.comnpay.secret }}'
+{% endif %}
+{% if constellation.stripe is defined %}
+
+STRIPE_PRIVATE_KEY = "{{ constellation.stripe.private_key }}"
+STRIPE_PUBLIC_KEY = "{{ constellation.stripe.public_key }}"
+{% endif %}
+{% if constellation.note is defined %}
+
+NOTE_KFET_URL = "{{ constellation.note.url }}"
+NOTE_KFET_CLIENT_ID = "{{ constellation.note.client_id }}"
+NOTE_KFET_CLIENT_SECRET = "{{ constellation.note.client_secret }}"
+{% endif %}
+{% endif %}
-- 
GitLab