-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better UI for command execution; Fix some templates;
- Loading branch information
Showing
15 changed files
with
482 additions
and
79 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import json | ||
import json | ||
import glob | ||
from hcl2.parser import hcl2 | ||
|
||
def flatten(l): | ||
return [item for sublist in l for item in sublist] | ||
|
||
if len(sys.argv) > 1: | ||
sources = sys.argv[1:] | ||
else: | ||
prefix = os.environ.get("CLUSTER_DIR", "./") | ||
sources = [ os.path.join(prefix, "variable*.tf") ] | ||
|
||
|
||
variables = [] | ||
for f in flatten([ glob.glob(i) for i in sources ]): | ||
with open(f, 'r') as f: | ||
data = hcl2.parse(f.read()) | ||
for v in data.get('variable', []): | ||
variables.append(v) | ||
|
||
variables = sorted(variables, key=lambda a: tuple(a.keys())[0]) | ||
print(json.dumps(variables)) | ||
|
||
def read_var(v): | ||
if v['default'] != null: | ||
return v | ||
return v | ||
|
||
for v in variables: | ||
v = read_var(v) | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
source /etc/profile.d/getup.sh | ||
|
||
user=$(get_tf_config SSH_USER ssh_user) | ||
|
||
if [ -z "$user" ]; then | ||
user=centos | ||
fi | ||
|
||
hosts=all | ||
remote_src=false | ||
|
||
src=$1 | ||
dest=$2 | ||
shift 2 | ||
|
||
src_host=${src%%:*} | ||
dest_host=${dest%%:*} | ||
src=${src#*:} | ||
dest=${dest#*:} | ||
|
||
if [ -n "$src_host" -a -n "$dest_host" ] || [ -z "$src_host$dest_host" ]; then | ||
echo "Usage:" | ||
echo " Upload: $0 local-file hosts:remote-file" | ||
echo " Download: $0 host:remote-file local-file" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$src_host" ]; then | ||
# downloading | ||
hosts=$src_host | ||
remote_src=true | ||
elif [ -n "$dest_host" ]; then | ||
# uploading | ||
hosts=$dest_host | ||
fi | ||
|
||
echo "See available flags in https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html" >&2 | ||
|
||
execute_command ansible $hosts -i $INVENTORY_FILE --become --user $user -m copy -a "src=$src dest=$dest remote_src=$remote_src $*" |
Oops, something went wrong.