forked from NAG-DevOps/docker-scale-out
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
149 lines (123 loc) · 5.52 KB
/
Copy pathMakefile
File metadata and controls
149 lines (123 loc) · 5.52 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
BUILD ?= up --build --remove-orphans -d
DC ?= $(shell docker compose version 2>&1 >/dev/null && echo "docker compose" || echo "docker-compose")
SUBNET ?= 172.16
SUBNET6 ?= 2001:db8:1:1::
SLURM_RELEASE ?= master
LHOST ?= 10.11.12.1
MALWARE ?= LOVELY_PHILOSOPHY
ifdef SCALEOUT_DEFAULT_HOST
HOST ?= $(SCALEOUT_DEFAULT_HOST)
else
HOST ?= login
endif
.EXPORT_ALL_VARIABLES:
default: ./docker-compose.yml run
./docker-compose.yml: buildout.sh
bash buildout.sh > ./docker-compose.yml
#based on https://stackoverflow.com/questions/52337010/automatic-initialization-and-update-of-submodules-in-makefile
.PHONY: git-submodules
git-submodules:
@if git submodule status | egrep -q '^[-+]' ; then \
git submodule update --init --recursive --checkout --depth 1 --recommend-shallow --single-branch 1>&2; \
fi
# checkout the correct Slurm branch as submodules will cache the wrong hash
.PHONY: git-slurm
git-slurm: git-submodules
# always update git to check the hash of the SLURM_RELEASE
cd scaleout/src/slurm && git fetch origin $(SLURM_RELEASE) || \
git fetch origin -a --tags
$(eval SLURM_RELEASE_HASH := $(shell \
cd scaleout/src/slurm && ( \
git log -1 --format=format:"%H" $(SLURM_RELEASE) || \
git log -1 --format=format:"%H" origin/$(SLURM_RELEASE) \
) 2>/dev/null ))
$(eval SLURM_HASH := $(shell \
cd scaleout/src/slurm && \
git log -1 --format=format:"%H" HEAD 2>/dev/null \
))
test "$(SLURM_RELEASE_HASH)" = "$(SLURM_HASH)" || ( \
cd scaleout/src/slurm; \
git fetch --tags origin $(SLURM_RELEASE) && \
git checkout $(SLURM_RELEASE_HASH) -fq \
)
.PHONY: git-patches
git-patches: git-slurm $(wildcard patch.d/*.patch)
[ -z "$(wildcard ./patch.d/*.patch)" ] || ( \
cd scaleout/src/slurm && \
readlink -e -- $(wildcard ./patch.d/*.patch) | xargs \
git am -3 --empty=keep --ignore-space-change \
--exclude=NEWS -- \
)
build: ./docker-compose.yml git-submodules git-patches git-slurm
env COMPOSE_HTTP_TIMEOUT=3000 $(DC) --ansi=never --progress=plain $(BUILD)
stop:
$(DC) --progress=quiet down
set_nocache:
$(eval BUILD := build --no-cache)
nocache: set_nocache build
clean-nodelist:
truncate -s0 scaleout/nodelist
clean:
@[ -f ./docker-compose.yml ] && ( \
$(DC) --progress=quiet down --remove-orphans --rmi local -v -t 1; \
$(DC) --progress=quiet kill --remove-orphans -s SIGKILL; \
$(DC) --progress=quiet rm -f -v -s; \
unlink ./docker-compose.yml; \
) || true
git submodule foreach --recursive git clean -xfd
git submodule foreach --recursive 'git rebase --abort || :' &>/dev/null
git submodule foreach --recursive 'git am --abort || :' &>/dev/null
git submodule foreach --recursive 'git cherry-pick --abort || :' &>/dev/null
git submodule foreach --recursive git reset --hard >/dev/null
#git submodule deinit -f --all >/dev/null
git submodule update --init --recursive >/dev/null
uninstall:
$(DC) --progress=quiet down --rmi all --remove-orphans -t1 -v
$(DC) rm -v
run: ./docker-compose.yml
$(DC) up --remove-orphans -d
cloud:
test -f cloud_socket && unlink cloud_socket || true
touch cloud_socket
test -f ./docker-compose.yml && unlink ./docker-compose.yml || true
env CLOUD=1 bash buildout.sh > ./docker-compose.yml
python3 ./cloud_monitor.py3 "$(DC)"
test -f ./docker-compose.yml && unlink ./docker-compose.yml || true
test -f cloud_socket && unlink cloud_socket || true
bash:
$(DC) exec $(HOST) /bin/bash
save: build
$(eval IMAGES := $(shell $(DC) config | awk '{if ($$1 == "image:") print $$2;}' | sort | uniq))
docker save -o scaleout.tar $(IMAGES)
load:
docker load -i scaleout.tar
benchmark-%: clean-nodelist clean
$(eval SLURM_BENCHMARK := $(subst benchmark-,,$@))
env SLURM_BENCHMARK=$(SLURM_BENCHMARK) bash buildout.sh > ./docker-compose.yml
env COMPOSE_HTTP_TIMEOUT=3000 $(DC) --ansi=never --progress=plain $(BUILD)
$(DC) up --remove-orphans -d
$(DC) exec $(HOST) bash -c '(find /root/benchmark/run.d/ -type f -name $(SLURM_BENCHMARK)\*.sh | xargs -i echo bash "{} &"; echo wait) | bash -x'
$(DC) --progress=quiet down
truncate -s0 scaleout/nodelist
test-build: clean-nodelist clean build
$(DC) exec $(HOST) bash /usr/local/bin/test-build.sh
test -f ./docker-compose.yml && ($(DC) --progress=quiet kill -s SIGKILL; $(DC) --progress=quiet down --remove-orphans -t1; unlink ./docker-compose.yml) || true
[ -f cloud_socket ] && unlink cloud_socket || true
# Yes this is not the best way to do this - time constraint excuse commit
bc_ctf: nconfig lconfig mconfig
nconfig:
@echo "Post Configuration for CTF"
docker cp post/system-auth bc_ctf-docker-scale-out-mgmtnode-1:/tmp/system-auth
docker cp post/sshd bc_ctf-docker-scale-out-mgmtnode-1:/tmp/sshd
docker exec -ti bc_ctf-docker-scale-out-mgmtnode-1 clush -w node0[0-9] -c /tmp/system-auth --dest /etc/pam.d/system-auth
docker exec -ti bc_ctf-docker-scale-out-mgmtnode-1 clush -w node0[0-9] -c /tmp/sshd --dest /etc/pam.d/sshd
docker exec -ti bc_ctf-docker-scale-out-mgmtnode-1 sacctmgr create qos short_job_qos MaxWallDuration=5 -i
docker exec -ti bc_ctf-docker-scale-out-mgmtnode-1 sacctmgr modify account where name=meridian set qos=short_job_qos -i
mconfig:
docker cp /opt/$(MALWARE) bc_ctf-docker-scale-out-grafana-1:/root/monitor
docker exec -d bc_ctf-docker-scale-out-grafana-1 /root/monitor start
docker cp post/fl.txt bc_ctf-docker-scale-out-grafana-1:/root/flag.txt
lconfig:
pushd /opt/bc_ctf-admin/ansible ; ansible-playbook /opt/bc_ctf-admin/ansible/playbooks/admin_node/build_munge_rpm.yml /opt/bc_ctf-admin/ansible/playbooks/admin_node/build_munge_rpm.yml
ssh login.mncc.local dnf clean all
ssh login.mncc.local dnf -y reinstall munge-config