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

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 [ACTION ...]] -r
                        [RESOURCE [RESOURCE ...]] [-v]
                        [role [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 [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 [ACTION ...]]] -r
                        [RESOURCE [RESOURCE ...]] [-v]
                        [role [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 [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

Was this entry helpful?