feat: wire multi-node billing deployment config

This commit is contained in:
Haitao Pan 2026-04-12 13:14:41 +08:00
parent d2531f6a22
commit 335ee6ef81
7 changed files with 26 additions and 0 deletions

View File

@ -9,6 +9,11 @@
billing_service_exporter_base_url: >- billing_service_exporter_base_url: >-
{{ lookup('ansible.builtin.env', 'EXPORTER_BASE_URL') {{ lookup('ansible.builtin.env', 'EXPORTER_BASE_URL')
| default('http://127.0.0.1:8080', true) }} | default('http://127.0.0.1:8080', true) }}
billing_service_exporter_sources_json: >-
{{ lookup('ansible.builtin.env', 'EXPORTER_SOURCES_JSON')
| default('', true) }}
billing_service_internal_service_token: >-
{{ lookup('ansible.builtin.vars', 'INTERNAL_SERVICE_TOKEN', default=lookup('ansible.builtin.env', 'INTERNAL_SERVICE_TOKEN') | default('', true)) }}
billing_service_database_url: >- billing_service_database_url: >-
{{ lookup('ansible.builtin.env', 'DATABASE_URL') {{ lookup('ansible.builtin.env', 'DATABASE_URL')
| default('', true) }} | default('', true) }}
@ -40,5 +45,11 @@
- billing_service_database_url | length > 0 - billing_service_database_url | length > 0
fail_msg: "DATABASE_URL must be exported before running this playbook." fail_msg: "DATABASE_URL must be exported before running this playbook."
success_msg: "DATABASE_URL found" success_msg: "DATABASE_URL found"
- name: Validate INTERNAL_SERVICE_TOKEN is present
ansible.builtin.assert:
that:
- billing_service_internal_service_token | length > 0
fail_msg: "INTERNAL_SERVICE_TOKEN must be exported before running this playbook."
success_msg: "INTERNAL_SERVICE_TOKEN found"
roles: roles:
- roles/vhosts/billing-service - roles/vhosts/billing-service

View File

@ -23,6 +23,12 @@
| default('https://accounts.svc.plus', true) }} | default('https://accounts.svc.plus', true) }}
xray_exporter_internal_service_token: >- xray_exporter_internal_service_token: >-
{{ lookup('ansible.builtin.vars', 'INTERNAL_SERVICE_TOKEN', default=lookup('ansible.builtin.env', 'INTERNAL_SERVICE_TOKEN') | default('', true)) }} {{ lookup('ansible.builtin.vars', 'INTERNAL_SERVICE_TOKEN', default=lookup('ansible.builtin.env', 'INTERNAL_SERVICE_TOKEN') | default('', true)) }}
xray_exporter_snapshot_store_path: >-
{{ lookup('ansible.builtin.env', 'SNAPSHOT_STORE_PATH')
| default('/var/lib/xray-exporter/snapshots.db', true) }}
xray_exporter_snapshot_retention: >-
{{ lookup('ansible.builtin.env', 'SNAPSHOT_RETENTION')
| default('72h', true) }}
xray_exporter_listen_addr: >- xray_exporter_listen_addr: >-
{{ lookup('ansible.builtin.env', 'XRAY_EXPORTER_LISTEN_ADDR') {{ lookup('ansible.builtin.env', 'XRAY_EXPORTER_LISTEN_ADDR')
| default('127.0.0.1:8080', true) }} | default('127.0.0.1:8080', true) }}

View File

@ -15,6 +15,8 @@ billing_service_env_path: "{{ billing_service_env_dir }}/billing-service"
billing_service_listen_addr: "127.0.0.1:8081" billing_service_listen_addr: "127.0.0.1:8081"
billing_service_exporter_base_url: "http://127.0.0.1:8080" billing_service_exporter_base_url: "http://127.0.0.1:8080"
billing_service_exporter_sources_json: ""
billing_service_internal_service_token: ""
billing_service_database_url: "" billing_service_database_url: ""
billing_service_collect_interval: "1m" billing_service_collect_interval: "1m"
billing_service_default_region: "" billing_service_default_region: ""

View File

@ -1,4 +1,6 @@
EXPORTER_BASE_URL={{ billing_service_exporter_base_url }} EXPORTER_BASE_URL={{ billing_service_exporter_base_url }}
EXPORTER_SOURCES_JSON={{ billing_service_exporter_sources_json }}
INTERNAL_SERVICE_TOKEN={{ billing_service_internal_service_token }}
DATABASE_URL={{ billing_service_database_url }} DATABASE_URL={{ billing_service_database_url }}
LISTEN_ADDR={{ billing_service_listen_addr }} LISTEN_ADDR={{ billing_service_listen_addr }}
COLLECT_INTERVAL={{ billing_service_collect_interval }} COLLECT_INTERVAL={{ billing_service_collect_interval }}

View File

@ -21,3 +21,5 @@ xray_exporter_stats_url: "http://127.0.0.1:49227/debug/vars"
xray_exporter_stats_token: "" xray_exporter_stats_token: ""
xray_exporter_accounts_base_url: "https://accounts.svc.plus" xray_exporter_accounts_base_url: "https://accounts.svc.plus"
xray_exporter_internal_service_token: "" xray_exporter_internal_service_token: ""
xray_exporter_snapshot_store_path: "/var/lib/xray-exporter/snapshots.db"
xray_exporter_snapshot_retention: "72h"

View File

@ -50,6 +50,7 @@
loop: loop:
- "{{ xray_exporter_app_dir }}" - "{{ xray_exporter_app_dir }}"
- "{{ xray_exporter_env_dir }}" - "{{ xray_exporter_env_dir }}"
- "{{ xray_exporter_snapshot_store_path | dirname }}"
- name: Sync xray-exporter source tree - name: Sync xray-exporter source tree
ansible.posix.synchronize: ansible.posix.synchronize:

View File

@ -2,6 +2,8 @@ XRAY_STATS_URL={{ xray_exporter_stats_url }}
XRAY_STATS_TOKEN={{ xray_exporter_stats_token }} XRAY_STATS_TOKEN={{ xray_exporter_stats_token }}
ACCOUNTS_BASE_URL={{ xray_exporter_accounts_base_url }} ACCOUNTS_BASE_URL={{ xray_exporter_accounts_base_url }}
INTERNAL_SERVICE_TOKEN={{ xray_exporter_internal_service_token }} INTERNAL_SERVICE_TOKEN={{ xray_exporter_internal_service_token }}
SNAPSHOT_STORE_PATH={{ xray_exporter_snapshot_store_path }}
SNAPSHOT_RETENTION={{ xray_exporter_snapshot_retention }}
EXPORTER_NODE_ID={{ xray_exporter_node_id }} EXPORTER_NODE_ID={{ xray_exporter_node_id }}
EXPORTER_ENV={{ xray_exporter_env_name }} EXPORTER_ENV={{ xray_exporter_env_name }}
SCRAPE_INTERVAL={{ xray_exporter_scrape_interval }} SCRAPE_INTERVAL={{ xray_exporter_scrape_interval }}