#!/bin/bash
# {{ ansible_managed }}
if [[ "$1" == "deploy_challenge" ]]; then
	/bin/systemctl start http-letsencrypt.service
elif [[ "$1" == "clean_challenge" ]]; then
	/bin/systemctl stop http-letsencrypt.service
elif [[ "$1" == "deploy_cert" ]]; then
	domain=$2
	key=$3
	fullchain=$5
	cat $fullchain $key > /usr/local/etc/tls/haproxy/${domain}.pem
        echo "reloading haproxy"
        /bin/systemctl reload haproxy.service
fi
