Skip to content
Snippets Groups Projects
Commit 157efc6e authored by Attila Farkas's avatar Attila Farkas
Browse files

Merge branch 'master' of gitlab.ics.muni.cz:cs4eu/sandbox-creator

parents e9556cb5 096cdd80
No related branches found
No related tags found
No related merge requests found
......@@ -2,23 +2,28 @@
name: big-broker
hosts:
- name: web
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 2048
- name: workstation
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 2048
- name: database
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 2048
- name: attacker
base_box: mu/kali-2019.4
base_box:
image: kali-2019.4
memory: 2048
- name: client
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 2048
routers:
......
kali-2019.4: muni-kypo/kali-2019.4
base_box: debian/stretch64
base_box:
image: debian/stretch64
memory: 256
cpus: 1
string:
base_mac: vm.base_mac
base_address: vm.base_address
base_box: vm.box
box_download_checksum: vm.box_download_checksum
box_download_checksum_type: vm.box_download_checksum_type
box_download_client_cert: vm.box_download_client_cert
......@@ -19,7 +18,6 @@ string:
ssh_remote_user: ssh.remote_user
ssh_shell: ssh.shell
ssh_sudo_command: ssh.sudo_command
ssh_username: ssh.username
winrm_username: winrm.username
winrm_password: winrm.password
winrm_host: winrm.host
......@@ -57,6 +55,8 @@ boolean:
winrm_ssl_peer_verification: winrm.ssl_peer_verification
winssh_forward_agent: winssh.forward_agent
winssh_keep_alive: winssh.keep_alive
special:
base_box: vm.box
other:
box_url: vm.box_url
guest: vm.guest
......
......@@ -4,6 +4,7 @@ from modules.file_manager import generate_file, open_yaml
VAGRANT_MAPPING = open_yaml("conf/vagrant_mapping.yml")
VIRTUALBOX_MAPPING = open_yaml("conf/virtualbox_mapping.yml")
BOX_MAPPING = open_yaml("conf/box_mapping.yml")
BASE_PLAYBOOK = "base_provisioning/device_configuration.yml"
USER_PLAYBOOK = "provisioning/playbook.yml"
......@@ -31,6 +32,28 @@ def _create_complex_attribute(key, value):
return attribute
def _create_special_commands(attribute, value):
"""Create special commands that cannot be mapped to a single command."""
special_attributes = []
if attribute == "base_box":
if "image" in value:
if value["image"] in BOX_MAPPING:
value["image"] = BOX_MAPPING[value["image"]]
box_name = dict()
box_name["type"] = "string"
box_name["command"] = "vm.box"
box_name["value"] = value["image"]
special_attributes.append(box_name)
if "man_user" in value:
user = dict()
user["type"] = "string"
user["command"] = "ssh.username"
user["value"] = value["man_user"]
special_attributes.append(user)
return special_attributes
def _create_commands(device_attributes):
"""Create basic vagrant definition commands for a device."""
commands = []
......@@ -53,6 +76,8 @@ def _create_commands(device_attributes):
vagrant_attribute = VAGRANT_MAPPING["other"][attribute]
commands.append(_create_complex_attribute(vagrant_attribute,
value))
elif attribute in VAGRANT_MAPPING["special"]:
commands.extend(_create_special_commands(attribute, value))
elif attribute in VIRTUALBOX_MAPPING["integer"]:
vagrant_attribute = VIRTUALBOX_MAPPING["integer"][attribute]
vb_commands.append(_create_simple_attribute(vagrant_attribute,
......
......@@ -2,7 +2,8 @@
name: 0-routers-1-networks-1-hosts
hosts:
- name: debian10
base_box: generic/debian10
base_box:
image: generic/debian10
flavor: csirtmu.tiny1x4
cpus: 2
......
......@@ -2,23 +2,28 @@
name: 1-network-various-boxes
hosts:
- name: debian10
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 512
- name: debian9
base_box: generic/debian9
base_box:
image: generic/debian9
memory: 512
- name: debian-stretch
base_box: debian/contrib-stretch64
base_box:
image: debian/contrib-stretch64
memory: 512
- name: ubuntu-xenial
base_box: ubuntu/xenial64
base_box:
image: ubuntu/xenial64
memory: 1024
- name: mu-kali
base_box: mu/kali-2019.4
base_box:
image: kali-2019.4
memory: 2048
networks:
......
......@@ -3,7 +3,8 @@
name: 1-router-1-host
hosts:
- name: debian10
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 512
routers:
......
......@@ -2,11 +2,13 @@
name: 2-networks
hosts:
- name: server
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 512
- name: home
base_box: generic/debian10
base_box:
image: generic/debian10
memory: 512
routers:
......
name: small-sandbox
hosts:
- name: server
base_box: ubuntu/xenial64
base_box:
image: ubuntu/xenial64
flavor: csirtmu.tiny1x4
cpus: 2
- name: home
base_box: ubuntu/xenial64
base_box:
image: ubuntu/xenial64
boot_timeout: 1000
box_check_update: false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment