Setting Configuration Options¶
The first time you run Airflow, it will create a file called airflow.cfg
in
your $AIRFLOW_HOME
directory (~/airflow
by default). This file contains Airflow’s configuration and you
can edit it to change any of the settings. You can also set options with environment variables by using this format:
$AIRFLOW__{SECTION}__{KEY}
(note the double underscores).
For example, the
metadata database connection string can either be set in airflow.cfg
like this:
or by creating a corresponding environment variable:
You can also derive the connection string at run time by appending _cmd
to
the key like this:
You can also derive the connection string at run time by appending _secret
to
the key like this:
This will retrieve config option from Secret Backends e.g Hashicorp Vault. See Secrets Backends for more details.
The following config options support this _cmd
and _secret
version:
sql_alchemy_conn
in[core]
sectionfernet_key
in[core]
sectionbroker_url
in[celery]
sectionflower_basic_auth
in[celery]
sectionresult_backend
in[celery]
sectionpassword
in[atlas]
sectionsmtp_password
in[smtp]
sectionbind_password
in[ldap]
sectiongit_password
in[kubernetes]
section
The _cmd
config options can also be set using a corresponding environment variable
the same way the usual config options can. For example:
Similarly, _secret
config options can also be set using a corresponding environment variable.
For example:
The idea behind this is to not store passwords on boxes in plain text files.
The universal order of precedence for all configuration options is as follows:
set as an environment variable (
AIRFLOW__CORE__SQL_ALCHEMY_CONN
)set as a command environment variable (
AIRFLOW__CORE__SQL_ALCHEMY_CONN_CMD
)set as a secret environment variable (
AIRFLOW__CORE__SQL_ALCHEMY_CONN_SECRET
)set in
airflow.cfg
command in
airflow.cfg
secret key in
airflow.cfg
Airflow’s built in defaults