diff --git a/.gitignore b/.gitignore index 93008cd..7c3285c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ __pycache__ *.pyc .venv build +packer_cache +output-qemu diff --git a/appliances/alpine-linux.json b/appliances/alpine-linux.json new file mode 100644 index 0000000..37d38b9 --- /dev/null +++ b/appliances/alpine-linux.json @@ -0,0 +1,40 @@ +{ + "qemu": { + "adapters": 1, + "arch": "x86_64", + "adapter_type": "e1000", + "ram": 32, + "console_type": "telnet" + }, + "documentation_url": "http://wiki.alpinelinux.org", + "maintainer_email": "developers@gns3.net", + "versions": [ + { + "images": { + "hda_disk_image": "alpine-linux-3.2.3.qcow2" + }, + "name": "3.2.3" + } + ], + "symbol": "linux_guest.svg", + "status": "experimental", + "category": "guest", + "registry_version": 1, + "usage": "User is root. Password is gns3", + "product_name": "Alpine Linux", + "images": [ + { + "version": "3.2.3", + "download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/", + "direct_download_url": "http://downloads.sourceforge.net/project/gns-3/Qemu%20Appliances/alpine-linux-3.2.3.qcow2", + "md5sum": "b82d895ecba270ecc5e5b445ec53ee02", + "filesize": 143065088, + "filename": "alpine-linux-3.2.3.qcow2" + } + ], + "vendor_name": "Alpine Linux Development Team", + "description": "Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.", + "maintainer": "GNS3 Team", + "name": "Alpine Linux", + "vendor_url": "http://alpinelinux.org" +} \ No newline at end of file diff --git a/new_appliance.py b/new_appliance.py index a7130c3..7df9961 100644 --- a/new_appliance.py +++ b/new_appliance.py @@ -54,6 +54,7 @@ def ask(question, type='string', optional=False): sys.stdout.write(question + "(optional leave blank for skip) : ") else: sys.stdout.write(question + ": ") + sys.stdout.flush() val = sys.stdin.readline().strip() if len(val) == 0: if optional: diff --git a/packer/README.rst b/packer/README.rst new file mode 100644 index 0000000..61c6678 --- /dev/null +++ b/packer/README.rst @@ -0,0 +1,37 @@ +Packer GNS3 appliance +===================== + +This directory contain the packer build script +used for some appliance in the GNS3 registry. + +For building an appliance please install packer: +https://packer.io/ + +And after run: + +.. code:: bash + + packer build template.json + + +If you want logs: + +.. code:: bash + + PACKER_LOG=1 packer build template.json + + +Conventions +************ +User should be gns3 or root. +Password should be gns3. + + +Note for OSX users +****************** + +You need qemu with VNC support. If you are using homebrew you need to install it with: + +.. code:: bash + + brew install qemu --with-sdl diff --git a/packer/alpine-linux/alpine-linux.json b/packer/alpine-linux/alpine-linux.json new file mode 100644 index 0000000..ee8afc4 --- /dev/null +++ b/packer/alpine-linux/alpine-linux.json @@ -0,0 +1,47 @@ +{ + "builders": + [ + { + "type": "qemu", + "iso_url": "http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.2/releases/x86_64/alpine-mini-3.2.3-x86_64.iso", + "iso_checksum": "a718c78537a0d416fa0b7cfcef1dfb85d1e837aa", + "iso_checksum_type": "sha1", + "shutdown_command": "poweroff", + "format": "qcow2", + "headless": false, + "ssh_username": "root", + "ssh_password": "gns3", + "vm_name": "alpine-linux", + "accelerator": "none", + "disk_interface": "ide", + "net_device": "e1000", + "disk_size": 5000, + "boot_wait": "120s", + "http_directory": "http", + "ssh_wait_timeout": "60m", + "boot_command": + [ + "root", + "echo \"root:gns3\" | chpasswd", + "ifconfig eth0 up && udhcpc -i eth0", + "setup-apkrepos -r", + "setup-sshd -c openssh" + ] + } + ], + "provisioners": [ + { + "type": "shell", + "script": "scripts/setup.sh" + }, + { + "type": "shell", + "inline": [ "reboot" ] + }, + { + "type": "shell", + "pause_before": "60s", + "script": "scripts/post_setup.sh" + } + ] +} diff --git a/packer/alpine-linux/scripts/post_setup.sh b/packer/alpine-linux/scripts/post_setup.sh new file mode 100644 index 0000000..68100e0 --- /dev/null +++ b/packer/alpine-linux/scripts/post_setup.sh @@ -0,0 +1,10 @@ +#Enable a terminal on serial port +echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt1003" >> etc/inittab + +apk add linux-virtgrsec +apk del linux-grsec +rm -Rf /lib/firmware +rm -rf /var/cache/apk/* + +# Write 0 +dd if=/dev/zero of=/zero ; rm -f /zero diff --git a/packer/alpine-linux/scripts/setup.sh b/packer/alpine-linux/scripts/setup.sh new file mode 100644 index 0000000..9347009 --- /dev/null +++ b/packer/alpine-linux/scripts/setup.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Copyright (C) 2015 GNS3 Technologies Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +export KEYMAPOPTS="us us" +export HOSTNAMEOPTS="-n alpine" +export INTERFACESOPTS=" +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp" +export TIMEZONEOPTS="-z UTC" +export PROXYOPTS="none" +export APKREPOSOPTS="-r" +export SSHDOPTS="-c openssh" +export NTPOPTS="-c none" +export SWAP_SIZE=0 + +# Answer to password question twice and yes to format drive +setup-alpine <. + +set -e + +ls -lh "$1" +mv "$1" "${1}.backup" +qemu-img convert -O qcow2 "${1}.backup" "$1" +rm "${1}.backup" +echo "Compression OK" +ls -lh "$1" diff --git a/schemas/appliance.json b/schemas/appliance.json index 60adfdb..4afcc65 100644 --- a/schemas/appliance.json +++ b/schemas/appliance.json @@ -74,7 +74,7 @@ }, "port_name_format": { "type": "string", - "title": "Optional formating of the newtorking port example: eth{0}" + "title": "Optional formating of the networking port example: eth{0}" }, "port_segment_size": { "type": "integer",