Created
March 8, 2021 21:54
-
-
Save rochacbruno/dc569777b67a242dc368d44f0f71609d to your computer and use it in GitHub Desktop.
This file contains 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
from dynaconf import Dynaconf | |
settings = Dynaconf( | |
settings_file="config.toml", # location of config file | |
environments=[ # available modes/environments | |
"ansible", | |
"puppet" | |
], | |
envvar_prefix="TEFLO", # prefix for exporting env vars | |
env_switcher="TEFLO_MODE", # Variable that controls mode switch | |
env="ANSIBLE" # Initial env/mode | |
) | |
if settings.current_env == "ANSIBLE": # this is the initial default | |
assert settings.data_folder == "ansible/.teflo" | |
if settings.current_env == "PUPPET": # only when TEFLO_MODE=puppet | |
assert settings.data_folder == "puppet/.teflo" | |
assert settings.log_level == "debug" # might be exported TEFLO_DEBUG_MODE | |
assert settings.workspace == "." | |
print(settings.data_folder) | |
print(settings['log_remove']) | |
print(settings.get("verbosity")) | |
print(settings.LOG_LEVEL) |
This file contains 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
[default] | |
log_level = "info" | |
workspace= "." | |
data_folder= ".teflo" | |
[ansible] | |
data_folder = "ansible/.teflo" | |
log_remove = true | |
verbosity = "v" | |
[puppet] | |
data_folder = "puppet/.teflo" | |
log_remove = false | |
verbosity = "vvv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment