Skip to content

Commit 0ca7ca3

Browse files
committed
Fixed the issue where there is no QA or support for a track (yet) which would forbid deploying the track. Fixed the issue where the monitoring would be on 'main-site' in the track.yaml template. Set a path dynamically instead of hardcoded dot-dot-slashes. Fixed an issue where the network zone would not get deleted when destroying the whole CTF.
1 parent ebbce11 commit 0ca7ca3

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

ctf/deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def run_ansible_playbook(remote: str, production: bool, track: str, path: str) -
230230
LOG.info(msg=f"Running common yaml with ansible for track {track}...")
231231
ansible_args = [
232232
"ansible-playbook",
233-
"../../../.deploy/common.yaml",
233+
os.path.join(CTF_ROOT_DIRECTORY, ".deploy", "common.yaml"),
234234
"-i",
235235
"inventory",
236236
] + extra_args

ctf/destroy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def destroy(
5757

5858
terraform_tracks = get_terraform_tracks_from_modules()
5959

60+
total_deployed_tracks = len(terraform_tracks)
61+
6062
r = (
6163
subprocess.run(
6264
args=["incus", "project", "get-current"],
@@ -110,7 +112,11 @@ def destroy(
110112
terraform_binary(),
111113
"destroy",
112114
"-auto-approve",
113-
*[f"-target=module.track-{track}" for track in terraform_tracks],
115+
*(
116+
[] # If every track needs to be destroyed, destroy everything including the network zone as well.
117+
if total_deployed_tracks == len(terraform_tracks)
118+
else [f"-target=module.track-{track}" for track in terraform_tracks]
119+
),
114120
],
115121
cwd=os.path.join(CTF_ROOT_DIRECTORY, ".deploy"),
116122
check=False,
@@ -194,6 +200,7 @@ def destroy(
194200
capture_output=True,
195201
env=ENV,
196202
)
203+
197204
remove_tracks_from_terraform_modules(
198205
tracks=terraform_tracks,
199206
remote=remote,

ctf/templates/main.tf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ resource "incus_project" "this" {
88
config = {
99
"features.images" = "false"
1010
"user.contacts.dev" = join(", ", local.track.contacts.dev)
11-
"user.contacts.qa" = join(", ", local.track.contacts.qa)
12-
"user.contacts.support" = join(", ", local.track.contacts.support)
11+
"user.contacts.qa" = length(local.track.contacts.qa) > 0 ? join(", ", local.track.contacts.qa) : null
12+
"user.contacts.support" = length(local.track.contacts.support) > 0 ? join(", ", local.track.contacts.support) : null
1313
}
1414
}
1515

ctf/templates/track.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
# Each service name must be unique for a given instance (container/VM).
4040
- name: {% if data.template == "python-service" %}HTTP-5000{% else %}HTTP{% endif %}
4141
# Name of the container or VM
42-
instance: main-site
42+
instance: {{ data.name }}
4343
# The IPv6 address was randomly generated from the MAC Address (hwaddr) and the subnets defined in main.tf.
4444
# If you need other machines, you can choose another MAC Address and get the IPv6 from the MAC AND the IPv6 subnet ({{ data.ipv6_subnet }}) at https://eui64-calc.princelle.org/
4545
address: '{{ data.full_ipv6_address }}'

0 commit comments

Comments
 (0)