This repository has been archived on 2020-05-07. You can view files and clone it, but cannot push or open issues or pull requests.
dokku-ansible-deploy/scripts/predeploy.py
2020-04-13 10:26:21 +02:00

48 lines
1.3 KiB
Python

#!/usr/bin/env python3
from subprocess import check_output
from os.path import exists
from ruamel.yaml import YAML
from argparse import ArgumentParser
yaml = YAML()
def yaml_load_file(target):
"""Load a YAML file."""
try:
with open(target, "r") as handle:
return yaml.load(handle.read())
except Exception as exception:
msg = "-----> Failed to load {}, saw {}".format(target, str(exception))
print(msg)
def load_config(app_config_path):
"""Load the config.yml if it exists."""
config = "{}/vault/config.yml".format(app_config_path)
if exists(config):
print("-----> Loading {}".format(config))
return yaml_load_file(config)
print("-----> No {} discovered, moving on".format(config))
def pre_deploy(app, app_config_path, plugin_path):
"""Pre-deploy steps."""
config = load_config(app_config_path)
cmd = [
"ansible-playbook",
""
]
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument("--app", help="app name")
parser.add_argument("--app-config-path", help="app config path")
parser.add_argument("--plugin-path", help="plugin path")
args = parser.parse_args()
pre_deploy(args.app, args.app_config_path, args.plugin_path)