-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (166 loc) · 6.18 KB
/
Copy pathMakefile
File metadata and controls
183 lines (166 loc) · 6.18 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
.PHONY: help build config clean post-setup install-client smoke-test smoke-test-cleanup install-deps install uninstall status
# Default data directory (can be overridden via environment variable or .env file)
export HOTSTACK_DATA_DIR ?= /var/lib/hotstack-os
# Directory for user-facing extra-vars files written by post-setup
# (cloud-secret.yaml, hotstack-os-overrides.yaml)
HOTSTACK_ENV_DIR ?= $(HOME)
# Script directory
SCRIPT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/scripts
# Reusable root privilege check
# Usage: $(call require-root,target-name)
define require-root
@if [ "$$(id -u)" -ne 0 ]; then \
echo "Error: This command requires root privileges."; \
echo "Please run: sudo make $(1)"; \
exit 1; \
fi
endef
help:
@echo "HotsTac(k)os Makefile Commands:"
@echo ""
@echo "Setup:"
@echo " sudo make install-deps - Install system dependencies (packages and services)"
@echo " sudo make build - Build all container images"
@echo " sudo make build PARALLEL=N - Build with N parallel jobs"
@echo " sudo make build VERBOSE=1 - Build with verbose output"
@echo " sudo make install - Install HotsTac(k)os as systemd services"
@echo ""
@echo "Post-Installation:"
@echo " sudo make install-client - Install OpenStack client packages on host (optional)"
@echo " make post-setup - Create hotstack project/user, resources, and images (no sudo)"
@echo ' Writes YAML files to HOTSTACK_ENV_DIR (default: $$HOME)'
@echo " make post-setup YES=1 - Same as above, auto-confirm all prompts (overwrite files)"
@echo " make smoke-test - Run smoke test with Heat stack validation (no sudo)"
@echo ""
@echo "Management:"
@echo " sudo make status - Check status of all services"
@echo " sudo make uninstall - Remove systemd services"
@echo " sudo make clean - Complete data cleanup (run after uninstall)"
@echo ""
@echo "Note: Use systemctl to manage services (start/stop/restart/logs)"
build:
$(call require-root,build)
@if [ ! -f .env ]; then \
echo "Creating .env from .env.example..."; \
cp .env.example .env; \
fi
@ARGS="--env-file .env"; \
[ "$(VERBOSE)" = "1" ] && ARGS="$$ARGS --verbose"; \
[ -n "$(PARALLEL)" ] && ARGS="$$ARGS --parallel $(PARALLEL)"; \
./scripts/build.py $$ARGS
config:
$(call require-root,config)
@./scripts/config.sh
status:
$(call require-root,status)
@./scripts/health-check.sh
install-client:
$(call require-root,install-client)
@echo "Installing OpenStack client packages on host..."
@echo ""
@. /etc/os-release; \
MAJOR=$${VERSION_ID%%.*}; \
if { [ "$$ID" = "centos" ] || [ "$$ID" = "rhel" ]; } && [ "$$MAJOR" -lt 10 ]; then \
if ! rpm -q centos-release-openstack-epoxy >/dev/null 2>&1; then \
echo "Installing OpenStack Epoxy repository..."; \
dnf install -y centos-release-openstack-epoxy; \
else \
echo "[OK] OpenStack Epoxy repository already installed"; \
fi; \
elif [ "$$ID" = "centos" ] || [ "$$ID" = "rhel" ]; then \
echo "Detected EL$$MAJOR (packages available in EPEL)"; \
echo "Enabling CRB repository (required by EPEL)..."; \
if [ -x /usr/bin/crb ]; then \
/usr/bin/crb enable; \
else \
dnf install -y dnf-plugins-core; \
dnf config-manager --set-enabled crb; \
fi; \
else \
echo "Detected Fedora or other distro (packages available in standard repos)"; \
fi
@echo "Installing OpenStack client packages..."
@dnf install -y python3-openstackclient python3-heatclient
@echo ""
@echo "[OK] OpenStack client installation complete"
@echo ""
@echo "You can now run 'make post-setup' directly from the host"
post-setup:
@if ! python3 -c "import openstack" 2>/dev/null; then \
echo "Error: Python OpenStack SDK not found"; \
echo ""; \
echo "The post-setup script requires the OpenStack client packages."; \
echo ""; \
echo "Please install: sudo make install-client"; \
echo ""; \
exit 1; \
fi
@echo "Setting up HotStack resources (project, user, quotas, images)..."
@echo "This will use admin credentials to create shared resources."
@echo "Images will be downloaded from GitHub releases."
@echo ""
./scripts/post-setup.py \
--cloud-secret-path $(HOTSTACK_ENV_DIR)/cloud-secret.yaml \
--overrides-path $(HOTSTACK_ENV_DIR)/hotstack-os-overrides.yaml \
$(if $(filter 1,$(YES)),--yes)
clean: uninstall
$(call require-root,clean)
@echo ""
@echo -e "\033[0;31mWARNING: Complete data cleanup\033[0m"
@echo "This will remove:"
@echo " • All container images"
@echo " • All persistent data (databases, images, volumes, logs)"
@echo -e " • \033[1;33mAll libvirt VMs matching pattern 'notapet-<uuid>'\033[0m"
@echo " • Libvirt session service and hotstack user"
@echo " • Podman network (hotstack-os)"
@echo " • Storage directories"
@echo " • OVS bridges"
@echo ""
@if [ -z "$$HOTSTACK_CLEANUP_CONFIRM" ]; then \
read -p "Proceed with complete cleanup? [y/N] " -n 1 -r; \
echo; \
if [[ ! $$REPLY =~ ^[Yy]$$ ]]; then \
echo "Cancelled."; \
exit 1; \
fi; \
else \
echo "Auto-confirmed via HOTSTACK_CLEANUP_CONFIRM"; \
fi; \
./scripts/clean.sh
smoke-test:
@if ! python3 -c "import openstack" 2>/dev/null; then \
echo "Error: Python OpenStack SDK not found"; \
echo ""; \
echo "The smoke test requires the OpenStack client packages."; \
echo ""; \
echo "Please install: sudo make install-client"; \
echo ""; \
exit 1; \
fi
@echo "Running HotsTac(k)os smoke test..."
@echo "This will create a Heat stack with test resources."
@echo ""
./scripts/smoke-test.py
smoke-test-cleanup:
@if ! python3 -c "import openstack" 2>/dev/null; then \
echo "Error: Python OpenStack SDK not found"; \
echo ""; \
echo "Please install: sudo make install-client"; \
echo ""; \
exit 1; \
fi
@echo "Cleaning up smoke test resources..."
@echo ""
./scripts/smoke-test.py --cleanup-only
install-deps:
$(call require-root,install-deps)
@$(SCRIPT_DIR)/install-deps.sh
create-user:
$(call require-root,create-user)
@$(SCRIPT_DIR)/create-hotstack-user.sh
install: create-user config
$(call require-root,install)
@$(SCRIPT_DIR)/install-systemd.sh
uninstall:
$(call require-root,uninstall)
@$(SCRIPT_DIR)/uninstall-systemd.sh