def envvar_constructor(loader, node):
value = loader.construct_python_unicode(node)<EOL>data = value.split('<STR_LIT>', <NUM_LIT:1>)<EOL>if len(data) == <NUM_LIT:2>:<EOL><INDENT>var, default = data<EOL>return os.environ.get(var, default)<EOL><DEDENT>else:<EOL><INDENT>return os.environ[value]<EOL><DEDENT>
Tag constructor to use environment variables in YAML files. Usage:

    - !TAG VARIABLE
        raise while loading the document if variable does not exists
    - !TAG VARIABLE:=DEFAULT_VALUE

    For instance:

        credentials:
            user: !env USER:=root
            group: !env GROUP:= root