41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
# import gnupg
|
|
import atexit
|
|
import json
|
|
import logging.config
|
|
import os
|
|
import pathlib
|
|
|
|
import gnupg
|
|
from rich.traceback import install
|
|
|
|
install(show_locals=True)
|
|
|
|
logger = logging.getLogger("vm_management")
|
|
|
|
|
|
# Logging is https://www.youtube.com/watch?v=9L77QExPmI0
|
|
def setup_logging():
|
|
config_file = pathlib.Path("logging_configs/config.json")
|
|
with open(config_file, "r") as config_file:
|
|
config = json.load(config_file)
|
|
logging.config.dictConfig(config)
|
|
queue_handler = logging.getHandlerByName("queue_handler")
|
|
if queue_handler is not None:
|
|
queue_handler.listener.start()
|
|
atexit.register(queue_handler.listener.stop)
|
|
|
|
|
|
def main():
|
|
setup_logging()
|
|
gnupg_home = os.path.expanduser("~/.gnupg")
|
|
gpg = gnupg.GPG(gnupghome=gnupg_home)
|
|
gpg.encoding = "utf-8"
|
|
vault_secret_file = os.path.expanduser("~/Downloads/hashicorp_vault_token.gpg")
|
|
with open(vault_secret_file, "rb") as vault_secret_file:
|
|
vault_secret = gpg.decrypt_file(vault_secret_file, passphrase="pw")
|
|
logger.debug("vault secret: %s", vault_secret)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|