Development and Testing

There are two basic things you need to start run and test an Infrastructure Challenge:

  • A System to run Ansible
  • A Virtual Machine to deploy the infrastructure challenge onto

It is highly recommended to a Virtual Machine that supports memory snapshotting for deploying challenges during testing. Infrastructure challenges inherently change the system they are deployed to, and so we recommend restoring to a "clean snapshot" whenever testing a challenge. This ensures the challenge setup can fully configure a completely new system, with no artifacts remaining from previous testing. Using a "Memory snapshot", where the hypervisor can restore the system to a running state, increases development speed by eliminating the boot time of the VM.

Vagrant

NCAE Cyber Games provides a Vagrant script for quickly setting up local VMs for development and testing. Vagrant relies on VirtualBox or HyperV to handle creating the VMs and initial snapshots. More information is available at Getting Started With Vagrant.

NCAE Cyber Games Cloud Environment

NCAE Cyber Games is working to provide a pre-configured development environment within our cloud Infrastructure. Please don’t hesitate to contact opfor-content@c2games.org for more information.

Editors

A text editor or IDE that has good support for YAML and/or Ansible is recommended. Microsoft’s Free editor "Visual Studio Code", or VS Code, with additional extensions is a great option. We provide links below to set up VS Code, but any editor can be used.

Setting up Visual Studio Code

VS Code has a great extension community, with hundreds of open-source extensions available to extend the editor’s capabilities. Extensions can be installed by clicking the "Extensions" button on the left toolbar and searching for the Extension name. The following extensions are recommended if using VS Code to create C2Games Infrastructure Challenges.

Linters

Linters are a form of static analysis for source code. NCAE Cyber Games runs a YAML linter and an Ansible Linter on all challenge submissions. We recommend you run both YAML and Ansible lint on your challenge before submitting, because if an issue is found with the submission, we may ask you to fix it before we can accept it.

Our configuration files, .ansible-lint and .yamllint, are available in the infrastructure-examples repository.

The Vagrant Development environment has ansible-lint and yamllint already installed. To run the linters, ssh to the vagrant dev system using vagrant ssh dev and run the lint.sh script.

ansible-lint roles/<ROLE>/
yamllint roles/<ROLE>/

The commands between the headers should output nothing if they ran successfully. Below is an example of both commands finding issues.

lint-output

Ensure there are no errors – warnings are acceptable, although they should be fixed if possible.

ansible-lint is telling us that there is an error, "Git checkouts must contain explicit version", and that the error is contained in the file manatee_bank_web_app/tasks/main.yaml on line 46, within the Task "Clone Manatee Bank".

A successful run might look like this:

lint-output-success-with-warnings