Skip to content

Fixed multiple issues #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:

- name: Copy CTF files
run: |
mkdir -p test-ctf/challenges
cp -r ./challenges test-ctf/
ls -al test-ctf/
ls -al test-ctf/challenges
mkdir -p test-ctf/challenges
cp -r ./challenges test-ctf/
ls -al test-ctf/
ls -al test-ctf/challenges

- name: ctf version
working-directory: test-ctf
Expand Down Expand Up @@ -196,10 +196,3 @@ jobs:
ctf redeploy --production --tracks mock-track-python-service
[ "$(incus list --all-projects -cn -fcsv | wc -l)" -eq 2 ] || exit 1
ctf destroy --force

- name: Check deployment results
run: |
incus project list
incus network zone record list ctf
incus network list --all-projects
incus list --all-projects
2 changes: 1 addition & 1 deletion ctf/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def run_ansible_playbook(remote: str, production: bool, track: str, path: str) -
LOG.info(msg=f"Running common yaml with ansible for track {track}...")
ansible_args = [
"ansible-playbook",
"../../../.deploy/common.yaml",
os.path.join(CTF_ROOT_DIRECTORY, ".deploy", "common.yaml"),
"-i",
"inventory",
] + extra_args
Expand Down
9 changes: 8 additions & 1 deletion ctf/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def destroy(

terraform_tracks = get_terraform_tracks_from_modules()

total_deployed_tracks = len(terraform_tracks)

r = (
subprocess.run(
args=["incus", "project", "get-current"],
Expand Down Expand Up @@ -110,7 +112,11 @@ def destroy(
terraform_binary(),
"destroy",
"-auto-approve",
*[f"-target=module.track-{track}" for track in terraform_tracks],
*(
[] # If every track needs to be destroyed, destroy everything including the network zone as well.
if total_deployed_tracks == len(terraform_tracks)
else [f"-target=module.track-{track}" for track in terraform_tracks]
),
],
cwd=os.path.join(CTF_ROOT_DIRECTORY, ".deploy"),
check=False,
Expand Down Expand Up @@ -194,6 +200,7 @@ def destroy(
capture_output=True,
env=ENV,
)

remove_tracks_from_terraform_modules(
tracks=terraform_tracks,
remote=remote,
Expand Down
4 changes: 2 additions & 2 deletions ctf/templates/main.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ resource "incus_project" "this" {
config = {
"features.images" = "false"
"user.contacts.dev" = join(", ", local.track.contacts.dev)
"user.contacts.qa" = join(", ", local.track.contacts.qa)
"user.contacts.support" = join(", ", local.track.contacts.support)
"user.contacts.qa" = length(local.track.contacts.qa) > 0 ? join(", ", local.track.contacts.qa) : null
"user.contacts.support" = length(local.track.contacts.support) > 0 ? join(", ", local.track.contacts.support) : null
}
}

Expand Down
2 changes: 1 addition & 1 deletion ctf/templates/track.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
# Each service name must be unique for a given instance (container/VM).
- name: {% if data.template == "python-service" %}HTTP-5000{% else %}HTTP{% endif %}
# Name of the container or VM
instance: main-site
instance: {{ data.name }}
# The IPv6 address was randomly generated from the MAC Address (hwaddr) and the subnets defined in main.tf.
# 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/
address: '{{ data.full_ipv6_address }}'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies = [
"setuptools",
"typer==0.16.0",
]
version = "2.1.0"
version = "3.0.0"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
Expand Down