Files
2026-10-29 16:53:11 -04:00

56 lines
3.2 KiB
YAML
Executable File

---
- name: Validate required and constrained Discourse settings
ansible.builtin.assert:
that:
- discourse_namespace is match('^[a-z0-9]([-a-z0-9]*[a-z0-9])?$')
- discourse_namespace != discourse_migration_source_namespace or not (discourse_migration_mode | bool)
- discourse_name is match('^[a-z0-9]([-a-z0-9]*[a-z0-9])?$')
- discourse_hostname | length > 0
- discourse_hostname is match('^[A-Za-z0-9.-]+$')
- discourse_developer_emails is sequence and discourse_developer_emails is not string
- discourse_developer_emails | length > 0
- discourse_image | length > 0 or discourse_build_enabled | bool
- discourse_replicas | int == 1
- discourse_service_type in ['ClusterIP', 'NodePort', 'LoadBalancer']
- discourse_postgres_image | length > 0
- discourse_redis_image | length > 0
- not (discourse_migration_mode | bool) or discourse_migration_source_namespace | length > 0
- not (discourse_build_enabled | bool) or discourse_application_version | length > 0
- not (discourse_build_enabled | bool) or discourse_image | length > 0
- discourse_database_password | length > 0
- discourse_redis_password | length > 0
- (discourse_smtp_address | length == 0) == (discourse_smtp_username | length == 0)
- (discourse_smtp_address | length == 0) == (discourse_smtp_password | length == 0)
- not (discourse_ingress_enabled | bool) or discourse_tls_secret_name | length > 0
- discourse_extra_environment is mapping
- discourse_plugins is sequence and discourse_plugins is not string
- discourse_image_pull_secrets is sequence and discourse_image_pull_secrets is not string
- discourse_migration_mode | bool == (discourse_migration_source_namespace | length > 0)
- not (discourse_migration_mode | bool) or discourse_migration_backup_verified | bool
- not (discourse_migration_cutover | bool) or discourse_migration_mode | bool
fail_msg: >-
Provide a hostname, image (or build settings), initial administrator email,
non-empty database/Redis credentials, and valid Kubernetes settings. A
migration must name its source namespace and deploy into a different namespace.
- name: Validate Discourse plugin declarations
ansible.builtin.assert:
that:
- item.name is match('^[a-zA-Z0-9_-]+$')
- item.repository is match('^https://[A-Za-z0-9._/-]+(?:[.]git)?$')
- item.ref is defined and item.ref is match('^[A-Za-z0-9._/-]+$')
fail_msg: "Invalid plugin declaration for {{ item.name | default('unnamed plugin') }}"
loop: "{{ discourse_plugins }}"
loop_control:
label: "{{ item.name | default('unnamed plugin') }}"
- name: Validate extra environment variable names
ansible.builtin.assert:
that:
- item.key is match('^[A-Z][A-Z0-9_]*$')
- item.key not in ['DISCOURSE_HOSTNAME', 'DISCOURSE_DEVELOPER_EMAILS', 'DISCOURSE_DB_PASSWORD', 'DISCOURSE_REDIS_PASSWORD', 'DISCOURSE_SMTP_PASSWORD']
fail_msg: "Invalid or secret-bearing environment override: {{ item.key }}"
loop: "{{ discourse_extra_environment | dict2items }}"
loop_control:
label: "{{ item.key }}"