Skip to content

Instantly share code, notes, and snippets.

@nehiljain
Created May 24, 2017 14:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nehiljain/0775380f327610ae8b025897716535bd to your computer and use it in GitHub Desktop.
Save nehiljain/0775380f327610ae8b025897716535bd 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.
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