Zmienne środowiskowe

Konfiguruj AnsibleForms za pomocą zmiennych środowiskowych


Dla administratorów, którzy wdrażają AnsibleForms: zmienne środowiskowe odczytywane przez serwer, pogrupowane tematycznie.

AnsibleForms dostraja się zmiennymi środowiskowymi, niezależnie od tego, czy działa z Docker Compose, na Kubernetes, czy ze źródeł.


Skąd pochodzą wartości

Serwer odczytuje każdą zmienną z pierwszego z tych źródeł, które ją ustawia, więc wartość wyżej na liście zawsze wygrywa:

  1. Środowisko procesu: environment: i env_file: w docker-compose (tak przekazywany jest .env projektu), env i envFrom na Kubernetes albo powłoka, która uruchamia node.
  2. persistent/.env, plik zapisywany przez strony ustawień (data/.env w projekcie docker-compose, inna ścieżka przy MANAGED_ENV_PATH). Jest odczytywany przy każdym uruchomieniu, także w produkcji, i nigdy nie nadpisuje zmiennej, która jest już ustawiona.
  3. server/.env.<NODE_ENV>, np. .env.development. Odczytywany tylko wtedy, gdy NODE_ENV nie jest production (lub z FORCE_DOTENV=1), w praktyce przy uruchamianiu ze źródeł w trybie deweloperskim.
  4. Wbudowana wartość domyślna, pokazana w tabelach każdej grupy.

Strony ustawień, w Ustawienia > Ogólne, pokazują obowiązującą wartość i zapisują zmiany w persistent/.env. Wiele zmiennych działa od razu po zapisaniu; pozostałe są zapisywane, ale wymagają restartu, a strona wymienia je po zapisie. Zmiennej ustawionej w środowisku procesu nie można tam zmienić: strona pokazuje ją jako Ustawione w środowisku, więc nie można tego tutaj zmienić. Kilku zmiennych, takich jak ENCRYPTION_SECRET i ACCESS_TOKEN_SECRET, nigdy nie można zmienić ze strony.

Zmiennych odczytywanych przez RTE, takich jak AF_ROLE, RTE_MODE, CONTROLLER_URL czy RTE_MAX_JOBS, w ogóle nie ma na stronach ustawień: kontroler ich nie używa, więc ustaw je w środowisku, w którym działa RTE. Wyjątkiem są zmienne RTE_* odczytywane przez sam kontroler, RTE_QUEUE_MINUTES i RTE_FILES_MAX_MB, które zostają na stronach. Cztery zmienne RTE, RTE_MAX_JOBS, RTE_CACHE_MB, RTE_FILES i RTE_DRAIN_SECONDS, można zamiast tego ustawić dla każdego RTE na jego stronie runnera, gdzie wartość wygrywa ze zmienną (zobacz Ustawienia RTE).

Przy ALLOW_ENV_EDIT=0 strony tylko pokazują wartości, a zapis jest odrzucany. Używaj tego, gdy środowisko jest zadeklarowane w manifeście, jak opisano w Edycja i audyt.

Config seed nie ustawia żadnych zmiennych środowiskowych. Deklaruje obiekty przechowywane w bazie danych, a odwołania ${ENV_VAR} w nim są rozwiązywane ze środowiska działającego serwera.

Kilka zmiennych jest odczytywanych tylko ze środowiska i nie ma ich w tabelach: MANAGED_ENV_PATH i FORCE_DOTENV, opisane wyżej, oraz systemowe zmienne proxy HTTPS_PROXY i NO_PROXY (odczytywane też małymi literami). RTE w trybie wychodzącym łączy się z aplikacją przez HTTPS_PROXY, a RTE w trybie przychodzącym wysyła przez nie swoje wywołanie rejestracji, chyba że host aplikacji jest w NO_PROXY (nazwy hostów, sufiksy .domain lub * dla każdego hosta).

Zmienne oznaczone Sekret zawierają hasło, token lub klucz: trzymaj je poza systemem kontroli wersji, np. w Secret Kubernetes lub w pliku .env, który nie jest commitowany.


W tej sekcji

Zmienne są pogrupowane tematycznie, z jedną stroną na grupę:

Strona Czego dotyczy
Server and database The web server, trusted proxies, the MySQL connection, the admin account, and what each process runs (controller, worker or RTE)
Paths Where the configuration, forms, playbooks, workflows, uploads and backups live
Backups and retention The backup commands, the backup before an upgrade, and how long backups, jobs and audit records are kept
Features The designer, MCP, chat, launch validation, the jobs list, metrics, the AWX API and query logging
Configuration The config seed, where the configuration is kept, git and ytt
Security variables Sign-in limits, passwords, single sign-on, tokens, encryption, the browser policy, outbound REST and jq limits, masking, and the VAULT_* variables, read once to import a secret store
Logging Log levels, the log format, files and how long they are kept, syslog and console colours
System tasks When the system tasks under Jobs run, from the nightly cleanups and backup to the runner hub’s loops

Inne zmienne

Poniższe zmienne nie są jeszcze przypisane do żadnej grupy:

Zmienna Opcje/Wartości domyślne Komentarze
CONFIG_SEED_RELOAD_ENABLED
boolean
added in version 7.9.0
Domyślnie:
true

Config seed reload on
true, false

Whether the Config seed reload system task runs on its schedule (CONFIG_SEED_RELOAD_CRON). Turned off, the seed applies at startup only; it replaces CONFIG_SEED_RELOAD_SECONDS=0, deprecated. Turned off, Run now on the task’s page still runs it. false or 0 turns it off. Changed on the task’s own page, Jobs > System > the task > Schedule, which saves it to the managed settings file and applies it at once on every node, without a restart. Set in the real environment (or with ALLOW_ENV_EDIT=0), the page shows it read only.

JOB_CLEANUP_ENABLED
boolean
added in version 7.9.0
Domyślnie:
true

Job cleanup on
true, false

Whether the Job cleanup system task runs on its schedule (JOB_CLEANUP_CRON). Turn it off to keep every finished job, or where they are cleaned up another way. Turned off, Run now on the task’s page still runs it. false or 0 turns it off. Changed on the task’s own page, Jobs > System > the task > Schedule, which saves it to the managed settings file and applies it at once on every node, without a restart. Set in the real environment (or with ALLOW_ENV_EDIT=0), the page shows it read only.

AUDIT_CLEANUP_ENABLED
boolean
added in version 7.9.0
Domyślnie:
true

Audit log cleanup on
true, false

Whether the Audit log cleanup system task runs on its schedule (AUDIT_CLEANUP_CRON). Turn it off to keep the audit log forever (shipped to a syslog server, for instance). Turned off, Run now on the task’s page still runs it. false or 0 turns it off. Changed on the task’s own page, Jobs > System > the task > Schedule, which saves it to the managed settings file and applies it at once on every node, without a restart. Set in the real environment (or with ALLOW_ENV_EDIT=0), the page shows it read only.

TOKEN_CLEANUP_ENABLED
boolean
added in version 7.9.0
Domyślnie:
true

Expired tokens on
true, false

Whether the Expired tokens system task runs on its schedule (TOKEN_CLEANUP_CRON). Only housekeeping: an expired token is refused anyway. Turned off, Run now on the task’s page still runs it. false or 0 turns it off. Changed on the task’s own page, Jobs > System > the task > Schedule, which saves it to the managed settings file and applies it at once on every node, without a restart. Set in the real environment (or with ALLOW_ENV_EDIT=0), the page shows it read only.

STORED_JOB_CLEANUP_ENABLED
boolean
added in version 7.9.0
Domyślnie:
true

Stored jobs cleanup on
true, false

Whether the Stored jobs cleanup system task runs on its schedule (STORED_JOB_CLEANUP_CRON). Turn it off to keep every stored job until it is deleted. Turned off, Run now on the task’s page still runs it. false or 0 turns it off. Changed on the task’s own page, Jobs > System > the task > Schedule, which saves it to the managed settings file and applies it at once on every node, without a restart. Set in the real environment (or with ALLOW_ENV_EDIT=0), the page shows it read only.

NIGHTLY_BACKUP_ENABLED
boolean
added in version 7.9.0
Domyślnie:
true

Nightly backup on
true, false

Whether the Nightly backup system task runs on its schedule (NIGHTLY_BACKUP_CRON). Turn it off where the instance is backed up another way (volume snapshots, a managed database with its own backups). Turned off, Run now on the task’s page still runs it. false or 0 turns it off. Changed on the task’s own page, Jobs > System > the task > Schedule, which saves it to the managed settings file and applies it at once on every node, without a restart. Set in the real environment (or with ALLOW_ENV_EDIT=0), the page shows it read only.

LOG_VIEW_LINES
number
added in version 7.7.0
Domyślnie:
1000

Lines on the Server log page
a whole number of at least 1

The number of last lines of today’s server log the Server log page shows and searches, and the most the log endpoint (GET /api/v2/log) answers, whatever a request asks: the whole day’s file is the page’s Download. No upper limit, but the page reads that many lines every 2 seconds, and many lines can make it slow or unresponsive. Takes effect at once, without a restart.