This commit is contained in:
2026-07-08 05:59:11 -05:00
parent f848420d8f
commit 589462e6d0
27 changed files with 771 additions and 102 deletions
+26 -5
View File
@@ -12,19 +12,28 @@ usage() {
cat <<EOF
Usage: $(basename "$0") [HOST] [OPTIONS]
Deploy application with deploy-apps.yml (Phase 2 stub).
Deploy applications with deploy-apps.yml.
HOST Optional. Limit to one host: adama, roslin, or desktop.
HOST Optional. Limit to one host: adama, roslin, or ai-server-4080.
Options:
--app NAME App to deploy (company_site, dta_service, dta_webapp)
--env ENV Environment: beta or prod
--ref REF Git ref/sha to deploy (default: master)
--check Dry run
--diff Show diffs
--extra-vars V Pass extra vars (e.g. app_ref=abc123)
--extra-vars V Pass raw extra vars
-h, --help Show this help
Examples:
# CI: deploy one app+env at a pinned sha
$(basename "$0") --app company_site --env prod --ref abc123
# Redeploy everything on master (all hosts)
$(basename "$0")
# Dry run for one host
$(basename "$0") adama --check
$(basename "$0") --extra-vars app_ref=master
EOF
}
@@ -34,6 +43,18 @@ while [[ $# -gt 0 ]]; do
usage
exit 0
;;
--app)
EXTRA_VARS+=(-e "app=$2")
shift 2
;;
--env)
EXTRA_VARS+=(-e "app_env=$2")
shift 2
;;
--ref)
EXTRA_VARS+=(-e "app_ref=$2")
shift 2
;;
--check)
EXTRA_ARGS+=(--check)
shift
@@ -46,7 +67,7 @@ while [[ $# -gt 0 ]]; do
EXTRA_VARS+=(-e "$2")
shift 2
;;
adama|roslin|desktop)
adama|roslin|ai-server-4080)
LIMIT="$1"
shift
;;
+56 -2
View File
@@ -13,17 +13,21 @@ Usage: $(basename "$0") [HOST] [OPTIONS]
Provision server(s) with site.yml.
HOST Optional. Limit to one host: adama, roslin, or desktop.
HOST Optional. Limit to one host: adama, roslin, or ai-server-4080.
Omit to run against all webservers.
Options:
--check Dry run (ansible --check)
--diff Show diffs
--ask-pass Prompt for SSH password (bootstrap before ssh-copy-id)
--ask-become-pass Prompt for sudo password
-h, --help Show this help
Examples:
$(basename "$0") adama --check # dry run on adama only
$(basename "$0") adama # provision adama
$(basename "$0") adama --ask-pass --ask-become-pass # first run, password auth
$(basename "$0") ai-server-4080 # provision the control node
$(basename "$0") # provision all hosts
EOF
}
@@ -42,7 +46,15 @@ while [[ $# -gt 0 ]]; do
EXTRA_ARGS+=(--diff)
shift
;;
adama|roslin|desktop)
--ask-pass)
EXTRA_ARGS+=(--ask-pass)
shift
;;
--ask-become-pass)
EXTRA_ARGS+=(--ask-become-pass)
shift
;;
adama|roslin|ai-server-4080)
LIMIT="$1"
shift
;;
@@ -54,6 +66,48 @@ while [[ $# -gt 0 ]]; do
esac
done
ensure_ssh_key() {
local key="${HOME}/.ssh/id_ed25519"
if [[ -f "$key" ]]; then
echo "==> SSH key already exists: $key"
return 0
fi
echo "==> Generating SSH key: $key"
ssh-keygen -t ed25519 -N "" -f "$key" -C "$(whoami)@$(hostname)"
}
ensure_gitea_ssh_config() {
local ssh_dir="${HOME}/.ssh"
local config="${ssh_dir}/config"
mkdir -p "$ssh_dir"
chmod 700 "$ssh_dir"
if [[ -f "$config" ]] && grep -qE '^Host[[:space:]]+git\.aimloperations\.com$' "$config"; then
echo "==> SSH config already has git.aimloperations.com"
return 0
fi
if [[ -f "$config" && -s "$config" ]]; then
printf '\n' >>"$config"
fi
cat >>"$config" <<'EOF'
Host git.aimloperations.com
User git
Port 30009
AddressFamily inet
EOF
chmod 600 "$config"
echo "==> Added git.aimloperations.com to ${config}"
}
ensure_ssh_key
ensure_gitea_ssh_config
CMD=(ansible-playbook playbooks/site.yml "${EXTRA_ARGS[@]}")
if [[ -n "$LIMIT" ]]; then
CMD+=(--limit "$LIMIT")