Created
March 9, 2016 04:08
push-to-etcd and pull-from-etcd
This file contains hidden or 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
#!/bin/bash | |
# Pull from etcd the template files. | |
function download() { | |
mkdir -p "$1" | |
pushd "$1" | |
local files="$(etcdctl ls /stoic-etc/$1)" | |
for file in $files; do | |
local filename="$(basename $file)" | |
etcdctl get $file > $filename | |
done | |
chmod +x "*.sh" > /dev/null 2>&1 || true | |
popd | |
} | |
function downloads() { | |
for folder in $1; do | |
download "$folder" | |
done | |
} | |
downloads "bin etc/confd/conf.d etc/confd/templates" | |
# optional: monitoring templates | |
# downloads "etc/beats etc/grafana/dashboards etc/prometheus" |
This file contains hidden or 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
#!/bin/bash | |
# Push to etcd the template files. | |
function upload() { | |
local files=$(ls "$1") | |
for file in $files; do | |
curl http://127.0.0.1:2379/v2/keys/stoic-etc/$1/$file -XPUT --data-urlencode value@$1/$file | |
done | |
} | |
function uploads() { | |
for folder in $1; do | |
upload $folder | |
done | |
} | |
uploads "bin etc/confd/conf.d etc/confd/templates" | |
# optional: monitoring templates | |
# uploads "etc/beats etc/grafana/dashboards etc/prometheus" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment