Skip to content

Instantly share code, notes, and snippets.

@alexwoolford
Last active February 4, 2020 12:16
Show Gist options
  • Save alexwoolford/114abe063eb27d9023c0b6d8347edaac to your computer and use it in GitHub Desktop.
Save alexwoolford/114abe063eb27d9023c0b6d8347edaac to your computer and use it in GitHub Desktop.
superset setup

superset setup

The following ansible playbook installs the pre-requisites for superset on a CentOS 7.4 host:

- hosts: superset
  user: root
  vars:
    mysql_root_password: ********

  tasks:
    - name: yum update
      yum: name=*
           state=latest

    - name: install epel, mlocate, ntp, pip, gcc, etc.
      yum: name={{ item }}
           state=installed
      with_items:
        - epel-release
        - mlocate
        - ntp
        - bind-utils
        - python-pip
        - mysql-devel
        - python-devel
        - openssl-devel
        - gcc
        - gcc-c++
        - cyrus-sasl-devel
        - lsof
        - supervisor

    - name: upgrade pip
      shell: pip install --upgrade pip

    - name: install mysqldb Python package
      pip: name={{ item }}
      with_items:
        - MySQL-python
        - superset

    - name: enable ntpd and supervisord
      service: name={{ item }}
               state=running
               enabled=yes
      with_items:
        - ntpd
        - supervisord

    - name: create superset database
      mysql_db: login_user=root
                login_password={{ mysql_root_password }}
                name=superset
                encoding=utf8
                state=present

    - name: add superset MySQL user
      mysql_user: login_user=root
                  login_password={{ mysql_root_password }}
                  name=superset
                  host=%
                  password={{ mysql_root_password }}
                  priv='superset.*:ALL,GRANT'
                  state=present

    - name: open port 8088
      firewalld:
        port: 8088/tcp
        permanent: true
        state: enabled

    - name: restart firewalld
      service: name=firewalld state=restarted

Note: MySQL was manually installed on this host, and is not part of this playbook because MySQL could be installed anywhere.

Add custom settings to /etc/superset/superset_config.py:

from flask_appbuilder.security.manager import AUTH_LDAP

SQLALCHEMY_DATABASE_URI = 'mysql://superset:********@superset/superset'

AUTH_TYPE = AUTH_LDAP
AUTH_LDAP_SERVER = "ldap://freeipa.woolford.io"
AUTH_LDAP_SEARCH = "cn=accounts,dc=woolford,dc=io"
AUTH_LDAP_BIND_USER = "uid=admin,cn=users,cn=accounts,dc=woolford,dc=io"
AUTH_LDAP_BIND_PASSWORD = "********"
AUTH_LDAP_UID_FIELD = "uid"

Then initialize the superset database tables per the superset docs:

# Create an admin user (you will be prompted to set username, first and last name before setting a password)
fabmanager create-admin --app superset

# Initialize the database
superset db upgrade

# Create default roles and permissions
superset init

To run superset as a service managed by supervisord create a file in /etc/supervisord.d/superset.ini containing:

[program:superset]
environment=SUPERSET_CONFIG_PATH=/etc/superset/superset_config.py
command = /usr/bin/superset runserver
autostart = true
autorestart = true
startretries = 3
stdout_logfile = /var/log/supervisor/superset.log
stdout_logfile_maxbytes = 100MB
stdout_logfile_backups = 5
stderr_logfile = /var/log/supervisor/superset-err.log
stderr_logfile_maxbytes = 100MB
stderr_logfile_backups = 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment