Skip to content

Commit 409eca4

Browse files
committed
Add CADT prerelease apt repo support and v2 config format
- Add cadt_apt_prerelease variable to toggle between stable and prerelease (cadt-test) apt repositories, with cleanup of the unused repo - Add v2 config template and auto-detect config format based on version - Add v1/v2 configuration defaults for dual-API support - Fix cloudflare_proxy conditionals to use bool filter - Add /worktrees/ to .gitignore
1 parent b14698a commit 409eca4

File tree

5 files changed

+111
-5
lines changed

5 files changed

+111
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ playbook.yml
44
hosts
55
/vars/
66
*.swp
7+
/worktrees/

cadt/defaults/main.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ climate_apps_domains:
55
- api2.example.com
66
cadt_api_proxy: true
77
cadt_api_version: latest
8+
cadt_apt_prerelease: false
89

910
# Path to the CADT API in the proxy - include leading and trailing slash
1011
cadt_api_proxy_path: "/api/"
@@ -57,6 +58,42 @@ datalayer_http_location: "http://{{ climate_apps_domains | first }}:8575"
5758
# Chia network
5859
cadt_network: "mainnet"
5960

61+
# New config format (>= 1.7.26)
62+
cadt_certificate_folder_path: null
63+
cadt_validate_organization_table_task_interval: 1800
64+
65+
cadt_request_content_limits:
66+
STAGING:
67+
EDIT_DATA_LEN: 200
68+
UNITS:
69+
INCLUDE_COLUMNS_LEN: 200
70+
MARKETPLACE_IDENTIFIERS_LEN: 200
71+
PROJECTS:
72+
INCLUDE_COLUMNS_LEN: 200
73+
PROJECT_IDS_LEN: 200
74+
75+
# V1 configuration - defaults inherit from the single-value variables above
76+
cadt_v1_enable: true
77+
cadt_v1_read_only: "{{ cadt_read_only }}"
78+
cadt_v1_api_key: "{{ cadt_api_key }}"
79+
cadt_v1_is_governance_body: "{{ cadt_is_governance_body }}"
80+
cadt_v1_governance_body_id: "{{ cadt_governance_body_id }}"
81+
cadt_v1_db_username: "{{ cadt_db_username }}"
82+
cadt_v1_db_password: "{{ cadt_db_password }}"
83+
cadt_v1_db_name: "{{ cadt_db_name }}"
84+
cadt_v1_db_host: "{{ cadt_db_host }}"
85+
86+
# V2 configuration - disabled by default, must be explicitly configured
87+
cadt_v2_enable: false
88+
cadt_v2_read_only: false
89+
cadt_v2_api_key: null
90+
cadt_v2_is_governance_body: false
91+
cadt_v2_governance_body_id: null
92+
cadt_v2_db_username: null
93+
cadt_v2_db_password: null
94+
cadt_v2_db_name: null
95+
cadt_v2_db_host: null
96+
6097
# Backups
6198
backup_base_dir: /home/{{ user }}/backup
6299
backup_dir: "{{ backup_base_dir }}/{{ cadt_port }}"

cadt/tasks/main.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
- 'vars'
1010
tags: cadt
1111

12+
- name: Remove unused CADT repository
13+
become: true
14+
ansible.builtin.apt_repository:
15+
repo: "deb [arch={{ cadt_repo_arch }} signed-by=/usr/share/keyrings/chia.gpg] https://repo.chia.net/{{ (cadt_apt_prerelease | bool) | ternary('cadt', 'cadt-test') }}/debian/ stable main"
16+
state: absent
17+
tags: cadt
18+
1219
- name: Add CADT Repository
1320
become: true
1421
ansible.builtin.apt_repository:
15-
repo: deb [arch={{ cadt_repo_arch }} signed-by=/usr/share/keyrings/chia.gpg] https://repo.chia.net/cadt/debian/ stable main
22+
repo: "deb [arch={{ cadt_repo_arch }} signed-by=/usr/share/keyrings/chia.gpg] https://repo.chia.net/{{ (cadt_apt_prerelease | bool) | ternary('cadt-test', 'cadt') }}/debian/ stable main"
1623
update_cache: true
1724
tags: cadt
1825

@@ -39,9 +46,16 @@
3946
state: restarted
4047
tags: cadt
4148

49+
- name: Determine CADT config format
50+
ansible.builtin.set_fact:
51+
cadt_use_v2_config: >-
52+
{{ cadt_api_version == 'latest' or
53+
(cadt_api_version | regex_replace('[-~]rc\d+$', '') is version('1.7.26', '>=')) }}
54+
tags: cadt
55+
4256
- name: Add CADT config file
4357
ansible.builtin.template:
44-
src: "config.yaml.j2"
58+
src: "{{ (cadt_use_v2_config | bool) | ternary('config-v2.yaml.j2', 'config.yaml.j2') }}"
4559
dest: "{{ chia_root }}/cadt/v1/config.yaml"
4660
owner: "{{ user }}"
4761
group: "{{ user }}"

cadt/templates/config-v2.yaml.j2

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
APP:
2+
CW_PORT: {{ cadt_port }}
3+
BIND_ADDRESS: {{ cadt_bind_address }}
4+
DATALAYER_URL: https://localhost:{{ chia_data_layer_rpc_port }}
5+
WALLET_URL: https://localhost:{{ chia_wallet_rpc_port }}
6+
USE_SIMULATOR: false
7+
CHIA_NETWORK: {{ cadt_network }}
8+
USE_DEVELOPMENT_MODE: false
9+
DEFAULT_FEE: {{ cadt_default_fee }}
10+
DEFAULT_COIN_AMOUNT: {{ cadt_default_coin_amount }}
11+
CERTIFICATE_FOLDER_PATH: {{ cadt_certificate_folder_path }}
12+
DATALAYER_FILE_SERVER_URL: {{ datalayer_http_location }}
13+
AUTO_SUBSCRIBE_FILESTORE: {{ cadt_auto_subscribe_filestore }}
14+
AUTO_MIRROR_EXTERNAL_STORES: {{ cadt_auto_mirror_external_stores }}
15+
LOG_LEVEL: {{ cadt_log_level }}
16+
TASKS:
17+
GOVERNANCE_SYNC_TASK_INTERVAL: {{ cadt_governance_sync_task_interval }}
18+
ORGANIZATION_META_SYNC_TASK_INTERVAL: {{ cadt_organization_meta_sync_task_interval }}
19+
PICKLIST_SYNC_TASK_INTERVAL: {{ cadt_picklist_sync_task_interval }}
20+
MIRROR_CHECK_TASK_INTERVAL: {{ cadt_mirror_check_task_interval }}
21+
VALIDATE_ORGANIZATION_TABLE_TASK_INTERVAL: {{ cadt_validate_organization_table_task_interval }}
22+
REQUEST_CONTENT_LIMITS:
23+
STAGING:
24+
EDIT_DATA_LEN: {{ cadt_request_content_limits.STAGING.EDIT_DATA_LEN }}
25+
UNITS:
26+
INCLUDE_COLUMNS_LEN: {{ cadt_request_content_limits.UNITS.INCLUDE_COLUMNS_LEN }}
27+
MARKETPLACE_IDENTIFIERS_LEN: {{ cadt_request_content_limits.UNITS.MARKETPLACE_IDENTIFIERS_LEN }}
28+
PROJECTS:
29+
INCLUDE_COLUMNS_LEN: {{ cadt_request_content_limits.PROJECTS.INCLUDE_COLUMNS_LEN }}
30+
PROJECT_IDS_LEN: {{ cadt_request_content_limits.PROJECTS.PROJECT_IDS_LEN }}
31+
V1:
32+
ENABLE: {{ cadt_v1_enable }}
33+
READ_ONLY: {{ cadt_v1_read_only }}
34+
CADT_API_KEY: {{ cadt_v1_api_key }}
35+
IS_GOVERNANCE_BODY: {{ cadt_v1_is_governance_body }}
36+
GOVERNANCE:
37+
GOVERNANCE_BODY_ID: {{ cadt_v1_governance_body_id }}
38+
MIRROR_DB:
39+
DB_USERNAME: {{ cadt_v1_db_username }}
40+
DB_PASSWORD: {{ cadt_v1_db_password }}
41+
DB_NAME: {{ cadt_v1_db_name }}
42+
DB_HOST: {{ cadt_v1_db_host }}
43+
V2:
44+
ENABLE: {{ cadt_v2_enable }}
45+
READ_ONLY: {{ cadt_v2_read_only }}
46+
CADT_API_KEY: {{ cadt_v2_api_key }}
47+
IS_GOVERNANCE_BODY: {{ cadt_v2_is_governance_body }}
48+
GOVERNANCE:
49+
GOVERNANCE_BODY_ID: {{ cadt_v2_governance_body_id }}
50+
MIRROR_DB:
51+
DB_USERNAME: {{ cadt_v2_db_username }}
52+
DB_PASSWORD: {{ cadt_v2_db_password }}
53+
DB_NAME: {{ cadt_v2_db_name }}
54+
DB_HOST: {{ cadt_v2_db_host }}

climate-nginx-base/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@
6868
src: cloudflare-update-ip-ranges.sh
6969
dest: /usr/local/bin/cloudflare-update-ip-ranges.sh
7070
mode: '0755'
71-
when: cloudflare_proxy
71+
when: cloudflare_proxy | bool
7272
tags: climate-nginx-base
7373

7474
# Run Cloudflare IP address retrieval script if proxying through cloudflare
7575
- name: Run Cloudflare IP address retrieval script
7676
become: true
7777
ansible.builtin.shell:
7878
cmd: /usr/local/bin/cloudflare-update-ip-ranges.sh
79-
when: cloudflare_proxy
79+
when: cloudflare_proxy | bool
8080
tags: climate-nginx-base
8181

8282
# If proxying through cloudflare, set crontab to run the cloudflare-update-ip-ranges.sh script once a week
@@ -90,7 +90,7 @@
9090
day: "*"
9191
month: "*"
9292
weekday: "1"
93-
when: cloudflare_proxy
93+
when: cloudflare_proxy | bool
9494
tags: climate-nginx-base
9595

9696
# Remove blocklist file if nginx_blocklist is empty

0 commit comments

Comments
 (0)