Skip to content

How Do I Access Configuration Values from the airflow.cfg File? #168

@r39132

Description

@r39132

I would like to use include the base_url in emails that I send via from flow. The base_url is defined under the webserver section of the config in airflow.cfg

What's the easiest way to these variables in any operator? Currently, I send email using my own PythonOperator (so that I can send both text and html multipart email). Hence, I access the config using the code below.

    parser = SafeConfigParser()
    parser.read('airflow.cfg')
    base_url = parser.get('webserver', 'base_url')

This works, but I was wondering if there is a more elegant way? Also, this only works for PythonOperators, but what if I need to access a configuration parameter in any operator in a Jinja template?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions