diff --git a/cloud-init/centos-cloud/README.md b/cloud-init/centos-cloud/README.md new file mode 100644 index 0000000..f331dd2 --- /dev/null +++ b/cloud-init/centos-cloud/README.md @@ -0,0 +1,9 @@ +# Centos-cloud cloud-init-data image for GNS3 virtual appliance + +Generated using the following commands: + +``` +printf "#cloud-config\n\npassword: centos\nchpasswd: { expire: False }\nssh_pwauth: True\n" > user-data +printf "instance-id: centos-cloud\nlocal-hostname: centos-cloud\n" > meta-data +mkisofs -output centos-cloud-init-data.iso -volid cidata -joliet -rock user-data meta-data +``` diff --git a/cloud-init/centos-cloud/centos-cloud-init-data.iso b/cloud-init/centos-cloud/centos-cloud-init-data.iso new file mode 100644 index 0000000..7306891 Binary files /dev/null and b/cloud-init/centos-cloud/centos-cloud-init-data.iso differ diff --git a/cloud-init/centos-cloud/meta-data b/cloud-init/centos-cloud/meta-data new file mode 100644 index 0000000..a04521c --- /dev/null +++ b/cloud-init/centos-cloud/meta-data @@ -0,0 +1,2 @@ +instance-id: centos-cloud +local-hostname: centos-cloud diff --git a/cloud-init/centos-cloud/user-data b/cloud-init/centos-cloud/user-data new file mode 100644 index 0000000..28ea93c --- /dev/null +++ b/cloud-init/centos-cloud/user-data @@ -0,0 +1,5 @@ +#cloud-config + +password: centos +chpasswd: { expire: False } +ssh_pwauth: True diff --git a/cloud-init/oracle-cloud/README.md b/cloud-init/oracle-cloud/README.md new file mode 100644 index 0000000..e21fb7d --- /dev/null +++ b/cloud-init/oracle-cloud/README.md @@ -0,0 +1,9 @@ +# Oracle-cloud cloud-init-data image for GNS3 virtual appliance + +Generated using the following commands: + +``` +printf "#cloud-config\n\npassword: oracle\nchpasswd: { expire: False }\nssh_pwauth: True\n" > user-data +printf "instance-id: oracle-cloud\nlocal-hostname: oracle-cloud\n" > meta-data +mkisofs -output oracle-cloud-init-data.iso -volid cidata -joliet -rock user-data meta-data +``` diff --git a/cloud-init/oracle-cloud/meta-data b/cloud-init/oracle-cloud/meta-data new file mode 100644 index 0000000..1b71690 --- /dev/null +++ b/cloud-init/oracle-cloud/meta-data @@ -0,0 +1,2 @@ +instance-id: oracle-cloud +local-hostname: oracle-cloud diff --git a/cloud-init/oracle-cloud/oracle-cloud-init-data.iso b/cloud-init/oracle-cloud/oracle-cloud-init-data.iso new file mode 100644 index 0000000..b50064d Binary files /dev/null and b/cloud-init/oracle-cloud/oracle-cloud-init-data.iso differ diff --git a/cloud-init/oracle-cloud/user-data b/cloud-init/oracle-cloud/user-data new file mode 100644 index 0000000..26d25a8 --- /dev/null +++ b/cloud-init/oracle-cloud/user-data @@ -0,0 +1,5 @@ +#cloud-config + +password: oracle +chpasswd: { expire: False } +ssh_pwauth: True diff --git a/packer/centos/centos-cloud-init-data.iso b/packer/centos/centos-cloud-init-data.iso new file mode 120000 index 0000000..154f415 --- /dev/null +++ b/packer/centos/centos-cloud-init-data.iso @@ -0,0 +1 @@ +../../cloud-init/centos-cloud/centos-cloud-init-data.iso \ No newline at end of file diff --git a/packer/centos/centos8.json b/packer/centos/centos8.json new file mode 100644 index 0000000..1d43530 --- /dev/null +++ b/packer/centos/centos8.json @@ -0,0 +1,51 @@ +{ + "builders": [ + { + "disk_compression": true, + "disk_image": true, + "disk_interface": "virtio-scsi", + "disk_size": "{{user `disk_size`}}", + "headless": true, + "iso_checksum": "sha256:{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", + "net_device": "virtio-net-pci", + "qemuargs": [ + [ + "-cdrom", + "centos-cloud-init-data.iso" + ] + ], + "shutdown_command": "sudo shutdown -P now", + "ssh_password": "centos", + "ssh_timeout": "3600s", + "ssh_username": "centos", + "type": "qemu", + "vm_name": "{{user `vm_name`}}" + } + ], + "provisioners": [ + { + "execute_command": "sudo env {{ .Vars }} {{ .Path }}", + "script": "scripts/upgrade-os.sh", + "type": "shell" + }, + { + "execute_command": "sudo env {{ .Vars }} {{ .Path }}", + "script": "scripts/centos-gns3-user.sh", + "type": "shell" + }, + { + "execute_command": "sudo env {{ .Vars }} {{ .Path }}", + "script": "scripts/post_setup.sh", + "type": "shell" + } + ], + "variables": { + "disk_size": "20G", + "iso_checksum": "8717251f8e4d2fe3e5032799caae89358c1ba68d65a16b5128a59ec6003aac1c", + "iso_url": "https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20220913.0.x86_64.qcow2", + "setup_script": "centos8.sh", + "vm_name": "centos8.qcow2" + } +} + diff --git a/packer/centos/scripts/centos-gns3-user.sh b/packer/centos/scripts/centos-gns3-user.sh new file mode 100644 index 0000000..669ffe1 --- /dev/null +++ b/packer/centos/scripts/centos-gns3-user.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +set -ex + +printf "gns3\ngns3\n" | useradd -c "gns3" -G wheel gns3 diff --git a/packer/centos/scripts/post_setup.sh b/packer/centos/scripts/post_setup.sh new file mode 100644 index 0000000..28fa782 --- /dev/null +++ b/packer/centos/scripts/post_setup.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -ex + +# clear repository +dnf clean all + +# clear unused space +echo 'Clearing unused space...' +dd if=/dev/zero bs=1M of=/zero >/dev/null 2>&1 || true; rm -f /zero +sync diff --git a/packer/centos/scripts/upgrade-os.sh b/packer/centos/scripts/upgrade-os.sh new file mode 100644 index 0000000..ed5f36d --- /dev/null +++ b/packer/centos/scripts/upgrade-os.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -ex + +# clear repository +dnf clean all + +dnf update -y diff --git a/packer/oracle/oracle-cloud-init-data.iso b/packer/oracle/oracle-cloud-init-data.iso new file mode 120000 index 0000000..bf2c166 --- /dev/null +++ b/packer/oracle/oracle-cloud-init-data.iso @@ -0,0 +1 @@ +../../cloud-init/oracle-cloud/oracle-cloud-init-data.iso \ No newline at end of file diff --git a/packer/oracle/oracle8.json b/packer/oracle/oracle8.json new file mode 100644 index 0000000..180110d --- /dev/null +++ b/packer/oracle/oracle8.json @@ -0,0 +1,51 @@ +{ + "builders": [ + { + "disk_compression": true, + "disk_image": true, + "disk_interface": "virtio-scsi", + "disk_size": "{{user `disk_size`}}", + "headless": true, + "iso_checksum": "sha256:{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", + "net_device": "virtio-net-pci", + "qemuargs": [ + [ + "-cdrom", + "oracle-cloud-init-data.iso" + ] + ], + "shutdown_command": "sudo shutdown -P now", + "ssh_password": "oracle", + "ssh_timeout": "240s", + "ssh_username": "cloud-user", + "type": "qemu", + "vm_name": "{{user `vm_name`}}" + } + ], + "provisioners": [ + { + "execute_command": "sudo env {{ .Vars }} {{ .Path }}", + "script": "scripts/upgrade-os.sh", + "type": "shell" + }, + { + "execute_command": "sudo env {{ .Vars }} {{ .Path }}", + "script": "scripts/oracle-gns3-user.sh", + "type": "shell" + }, + { + "execute_command": "sudo env {{ .Vars }} {{ .Path }}", + "script": "scripts/post_setup.sh", + "type": "shell" + } + ], + "variables": { + "disk_size": "40G", + "iso_checksum": "4a98e22908333dae1423e0bb4032c88aed60dbf1267addb73a6905778e9930df", + "iso_url": "https://yum.oracle.com/templates/OracleLinux/OL8/u7/x86_64/OL8U7_x86_64-kvm-b148.qcow", + "setup_script": "oracle8.sh", + "vm_name": "oracle8.qcow2" + } +} + diff --git a/packer/oracle/scripts/oracle-gns3-user.sh b/packer/oracle/scripts/oracle-gns3-user.sh new file mode 100644 index 0000000..669ffe1 --- /dev/null +++ b/packer/oracle/scripts/oracle-gns3-user.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +set -ex + +printf "gns3\ngns3\n" | useradd -c "gns3" -G wheel gns3 diff --git a/packer/oracle/scripts/post_setup.sh b/packer/oracle/scripts/post_setup.sh new file mode 100644 index 0000000..28fa782 --- /dev/null +++ b/packer/oracle/scripts/post_setup.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -ex + +# clear repository +dnf clean all + +# clear unused space +echo 'Clearing unused space...' +dd if=/dev/zero bs=1M of=/zero >/dev/null 2>&1 || true; rm -f /zero +sync diff --git a/packer/oracle/scripts/upgrade-os.sh b/packer/oracle/scripts/upgrade-os.sh new file mode 100644 index 0000000..ed5f36d --- /dev/null +++ b/packer/oracle/scripts/upgrade-os.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -ex + +# clear repository +dnf clean all + +dnf update -y