-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply
More file actions
executable file
·57 lines (44 loc) · 1.64 KB
/
apply
File metadata and controls
executable file
·57 lines (44 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env sh
# shellcheck disable=SC1091
set -e
script_dir="$(dirname "$(readlink -f "$0")")"
git_dir="$script_dir/.git"
state_file="$script_dir/.state"
. "$script_dir/lib/utils.sh"
if [ ! -f "$script_dir/.bootstrapped" ]; then
print_info ".bootstrapped not found. Running the bootstrap script first..."
sh "$script_dir/bootstrap"
fi
if ! command -v "$MINIT_UV" > /dev/null; then
print_error "uv executable not found at $MINIT_UV"
exit 1
fi
if [ -f "$state_file" ]; then
state_commit="$(cat "$state_file")"
else
state_commit=""
fi
if git_diff_since "$git_dir" "$state_commit" "$script_dir/uv.lock"; then
"$MINIT_UV" --directory "$script_dir" sync
fi
. "$script_dir/.venv/bin/activate"
ansible_dir="$script_dir/.ansible"
export ANSIBLE_CALLBACK_FORMAT_PRETTY=true
export ANSIBLE_CALLBACK_RESULT_FORMAT=yaml
export ANSIBLE_COLLECTIONS_PATH="$ansible_dir/collections"
export ANSIBLE_COLLECTIONS_SCAN_SYS_PATH=False
export ANSIBLE_INVENTORY="$ansible_dir/inventory.yml"
export ANSIBLE_INVENTORY_ENABLED="ini,yaml"
export ANSIBLE_LOCALHOST_WARNING=False
export ANSIBLE_ROLES_PATH="$script_dir/roles"
export MINIT_TMP_DIR="$ansible_dir/tmp"
if git_diff_since "$git_dir" "$state_commit" "$ansible_dir/collections.yml"; then
print_info "Updating Galaxy collections..."
ansible-galaxy collection install -Ur "$ansible_dir/collections.yml"
fi
current_commit="$(git --git-dir "$git_dir" rev-parse HEAD)"
if [ "$current_commit" != "$state_commit" ]; then
print_info "Saving state..."
printf '%s\n' "$current_commit" > "$state_file"
fi
ansible-playbook "$ansible_dir/playbook.yml" "$@" ${ask_become_pass:+"--ask-become-pass"}