-
-
Save ozgurgul/148bca37dcf8955f0ed409b88285d88c to your computer and use it in GitHub Desktop.
A script to automatically setup a admin user for airflow which can be run at infrastructure setup time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import airflow | |
from airflow import models, settings | |
from airflow.contrib.auth.backends.password_auth import PasswordUser | |
def create_admin_user(uname, pwd, email): | |
user = PasswordUser(models.User()) | |
user.username = uname | |
user.email = email | |
user.password = pwd | |
session = settings.Session() | |
session.add(user) | |
session.commit() | |
session.close() | |
if __name__ == '__main__': | |
# you can generate username password dynamically or parse it using argparser | |
create_admin_user(some_username, some_password, some_email) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment