FAB CLI Commands¶
Note
The CLI commands below are sourced from the FAB provider by Airflow 2.9.0+. Previously, they were part of core Airflow, so if you are using Airflow below 2.9.0 please see the core Airflow documentation for the list of CLI commands and parameters available.
Usage: airflow [-h] GROUP_OR_COMMAND ...
Positional Arguments¶
- GROUP_OR_COMMAND
Possible choices: users, roles, sync-perm, fab-db
Sub-commands¶
users¶
Manage users
airflow users [-h] COMMAND ...
Positional Arguments¶
- COMMAND
Possible choices: add-role, create, delete, export, import, list, remove-role, reset-password
Sub-commands¶
add-role¶
Add role to a user
airflow users add-role [-h] [-e EMAIL] -r ROLE [-u USERNAME] [-v]
Named Arguments¶
- -e, --email
Email of the user
- -r, --role
Role of the user. Existing roles include Admin, User, Op, Viewer, and Public
- -u, --username
Username of the user
- -v, --verbose
Make logging output more verbose
Default: False
create¶
Create a user
airflow users create [-h] -e EMAIL -f FIRSTNAME -l LASTNAME [-p PASSWORD] -r
ROLE [--use-random-password] -u USERNAME [-v]
Named Arguments¶
- -e, --email
Email of the user
- -f, --firstname
First name of the user
- -l, --lastname
Last name of the user
- -p, --password
Password of the user, required to create a user without –use-random-password
- -r, --role
Role of the user. Existing roles include Admin, User, Op, Viewer, and Public
- --use-random-password
Do not prompt for password. Use random string instead. Required to create a user without –password
Default: False
- -u, --username
Username of the user
- -v, --verbose
Make logging output more verbose
Default: False
examples: To create an user with “Admin” role and username equals to “admin”, run:
- $ airflow users create
–username admin –firstname FIRST_NAME –lastname LAST_NAME –role Admin –email admin@example.org
delete¶
Delete a user
airflow users delete [-h] [-e EMAIL] [-u USERNAME] [-v]
Named Arguments¶
- -e, --email
Email of the user
- -u, --username
Username of the user
- -v, --verbose
Make logging output more verbose
Default: False
export¶
Export all users
airflow users export [-h] [-v] FILEPATH
Positional Arguments¶
- FILEPATH
Export all users to JSON file
Named Arguments¶
- -v, --verbose
Make logging output more verbose
Default: False
import¶
Import users
airflow users import [-h] [-v] FILEPATH
Positional Arguments¶
- FILEPATH
Import users from JSON file. Example format:
[ { "email": "foo@bar.org", "firstname": "Jon", "lastname": "Doe", "roles": ["Public"], "username": "jondoe" } ]
Named Arguments¶
- -v, --verbose
Make logging output more verbose
Default: False
list¶
List users
airflow users list [-h] [-o table, json, yaml, plain] [-v]
Named Arguments¶
- -o, --output
Possible choices: table, json, yaml, plain
Output format. Allowed values: json, yaml, plain, table (default: table)
Default: “table”
- -v, --verbose
Make logging output more verbose
Default: False
remove-role¶
Remove role from a user
airflow users remove-role [-h] [-e EMAIL] -r ROLE [-u USERNAME] [-v]
Named Arguments¶
- -e, --email
Email of the user
- -r, --role
Role of the user. Existing roles include Admin, User, Op, Viewer, and Public
- -u, --username
Username of the user
- -v, --verbose
Make logging output more verbose
Default: False
reset-password¶
Reset a user’s password
airflow users reset-password [-h] [-e EMAIL] [-p PASSWORD]
[--use-random-password] [-u USERNAME] [-v]
Named Arguments¶
- -e, --email
Email of the user
- -p, --password
Password of the user, required to create a user without –use-random-password
- --use-random-password
Do not prompt for password. Use random string instead. Required to create a user without –password
Default: False
- -u, --username
Username of the user
- -v, --verbose
Make logging output more verbose
Default: False
examples: To reset an user with username equals to “admin”, run:
- $ airflow users reset-password
–username admin
roles¶
Manage roles
airflow roles [-h] COMMAND ...
Positional Arguments¶
- COMMAND
Possible choices: add-perms, create, del-perms, delete, export, import, list
Sub-commands¶
add-perms¶
Add roles permissions
airflow roles add-perms [-h] -a [ACTION ...] -r [RESOURCE ...] [-v] [role ...]
Positional Arguments¶
- role
The name of a role
Named Arguments¶
- -a, --action
The action of permissions
- -r, --resource
The name of permissions
- -v, --verbose
Make logging output more verbose
Default: False
create¶
Create role
airflow roles create [-h] [-v] [role ...]
Positional Arguments¶
- role
The name of a role
Named Arguments¶
- -v, --verbose
Make logging output more verbose
Default: False
del-perms¶
Delete roles permissions
airflow roles del-perms [-h] [-a [ACTION ...]] -r [RESOURCE ...] [-v]
[role ...]
Positional Arguments¶
- role
The name of a role
Named Arguments¶
- -a, --action
The action of permissions
- -r, --resource
The name of permissions
- -v, --verbose
Make logging output more verbose
Default: False
delete¶
Delete role
airflow roles delete [-h] [-v] [role ...]
Positional Arguments¶
- role
The name of a role
Named Arguments¶
- -v, --verbose
Make logging output more verbose
Default: False
export¶
Export roles (without permissions) from db to JSON file
airflow roles export [-h] [-p] [-v] file
Positional Arguments¶
- file
Export all roles to JSON file
Named Arguments¶
- -p, --pretty
Format output JSON file by sorting role names and indenting by 4 spaces
Default: False
- -v, --verbose
Make logging output more verbose
Default: False
import¶
Import roles (without permissions) from JSON file to db
airflow roles import [-h] [-v] file
Positional Arguments¶
- file
Import roles from JSON file
Named Arguments¶
- -v, --verbose
Make logging output more verbose
Default: False
list¶
List roles
airflow roles list [-h] [-o table, json, yaml, plain] [-p] [-v]
Named Arguments¶
- -o, --output
Possible choices: table, json, yaml, plain
Output format. Allowed values: json, yaml, plain, table (default: table)
Default: “table”
- -p, --permission
Show role permissions
Default: False
- -v, --verbose
Make logging output more verbose
Default: False
sync-perm¶
Update permissions for existing roles and optionally DAGs
airflow sync-perm [-h] [--include-dags] [-v]
Named Arguments¶
- --include-dags
If passed, DAG specific permissions will also be synced.
Default: False
- -v, --verbose
Make logging output more verbose
Default: False
fab-db¶
Manage FAB
airflow fab-db [-h] COMMAND ...
Positional Arguments¶
- COMMAND
Possible choices: downgrade, migrate, reset
Sub-commands¶
downgrade¶
Downgrade the schema of the FAB metadata database. You must provide either –to-revision or –to-version. To print but not execute commands, use option –show-sql-only. If using options –from-revision or –from-version, you must also use –show-sql-only, because if actually running migrations, we should only migrate from the current Alembic revision.
airflow fab-db downgrade [-h] [--from-revision FROM_REVISION]
[--from-version FROM_VERSION] [-s] [-r TO_REVISION]
[-n TO_VERSION] [-v] [-y]
Named Arguments¶
- --from-revision
(Optional) If generating sql, may supply a from Alembic revision
- --from-version
(Optional) If generating sql, may supply a from version
- -s, --show-sql-only
Don’t actually run migrations; just print out sql scripts for offline migration. Required if using either –from-revision or –from-version.
Default: False
- -r, --to-revision
The Alembic revision to downgrade to. Note: must provide either –to-revision or –to-version.
- -n, --to-version
(Optional) If provided, only run migrations up to this version.
- -v, --verbose
Make logging output more verbose
Default: False
- -y, --yes
Do not prompt to confirm. Use with care!
Default: False
migrate¶
Migrate the schema of the FAB metadata database. Create the database if it does not exist To print but not execute commands, use option --show-sql-only
. If using options --from-revision
or --from-version
, you must also use --show-sql-only
, because if actually running migrations, we should only migrate from the current Alembic revision.
airflow fab-db migrate [-h] [--from-revision FROM_REVISION]
[--from-version FROM_VERSION] [-s] [-r TO_REVISION]
[-n TO_VERSION] [-v]
Named Arguments¶
- --from-revision
(Optional) If generating sql, may supply a from Alembic revision
- --from-version
(Optional) If generating sql, may supply a from version
- -s, --show-sql-only
Don’t actually run migrations; just print out sql scripts for offline migration. Required if using either –from-revision or –from-version.
Default: False
- -r, --to-revision
(Optional) If provided, only run migrations up to and including this Alembic revision.
- -n, --to-version
(Optional) The airflow version to upgrade to. Note: must provide either –to-revision or –to-version.
- -v, --verbose
Make logging output more verbose
Default: False
reset¶
Burn down and rebuild the FAB metadata database
airflow fab-db reset [-h] [-s] [-v] [-y]
Named Arguments¶
- -s, --skip-init
Only remove tables; do not perform db init.
Default: False
- -v, --verbose
Make logging output more verbose
Default: False
- -y, --yes
Do not prompt to confirm. Use with care!
Default: False