https://github.com/mweisel/fortigate-vagrant-libvirt
A Packer template for creating a Fortinet FortiGate Vagrant box for the libvirt provider.
https://github.com/mweisel/fortigate-vagrant-libvirt
fortigate libvirt-provider packer-template vagrant-box
Last synced: about 1 year ago
JSON representation
A Packer template for creating a Fortinet FortiGate Vagrant box for the libvirt provider.
- Host: GitHub
- URL: https://github.com/mweisel/fortigate-vagrant-libvirt
- Owner: mweisel
- License: mit
- Created: 2021-03-19T22:14:32.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-20T00:36:28.000Z (almost 4 years ago)
- Last Synced: 2024-03-22T23:46:50.410Z (about 2 years ago)
- Topics: fortigate, libvirt-provider, packer-template, vagrant-box
- Language: HCL
- Homepage:
- Size: 6.84 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Fortinet FortiGate Vagrant box
A Packer template for creating a Fortinet FortiGate Vagrant box for the [libvirt](https://libvirt.org) provider.
## Prerequisites
* [Fortinet](https://support.fortinet.com) account
* [Git](https://git-scm.com)
* [Packer](https://packer.io) >= 1.70
* [libvirt](https://libvirt.org)
* [QEMU](https://www.qemu.org)
* [Vagrant](https://www.vagrantup.com) >= 2.2.10, != 2.2.16
* [vagrant-libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt)
## Steps
0\. Verify the prerequisite tools are installed.
$ which git unzip packer libvirtd qemu-system-x86_64 vagrant
$ vagrant plugin list
vagrant-libvirt (0.9.0, global)
1\. Log in and download the _FortiGate for KVM platform_ package from [Fortinet](https://docs.fortinet.com/document/fortigate-private-cloud/7.2.0/kvm-administration-guide/706376/about-fortigate-vm-on-kvm). Save the file to your `Downloads` directory.
2\. Extract the disk image file to the `/var/lib/libvirt/images` directory.
$ cd $HOME/Downloads
$ sudo unzip -d /var/lib/libvirt/images FGT_VM64_KVM-v7.2.0.F-build1157-FORTINET.out.kvm.zip
3\. Modify the file ownership and permissions. Note the owner may differ between Linux distributions.
> Ubuntu 18.04
$ sudo chown libvirt-qemu:kvm /var/lib/libvirt/images/fortios.qcow2
$ sudo chmod u+x /var/lib/libvirt/images/fortios.qcow2
> Arch Linux
$ sudo chown libvirt-qemu:libvirt-qemu /var/lib/libvirt/images/fortios.qcow2
$ sudo chmod u+x /var/lib/libvirt/images/fortios.qcow2
4\. Create the `boxes` directory.
$ mkdir -p $HOME/boxes
5\. Clone this GitHub repo and _cd_ into the directory.
$ git clone https://github.com/mweisel/fortigate-vagrant-libvirt
$ cd fortigate-vagrant-libvirt
6\. Packer _build_ to create the Vagrant box artifact. Supply the FortiOS version number for the `version` variable value.
$ packer build -var 'version=7.2.0' fortigate.pkr.hcl
7\. Copy the Vagrant box artifact to the `boxes` directory.
$ cp ./builds/fortinet-fortigate-7.2.0.box $HOME/boxes/
8\. Copy the box metadata file to the `boxes` directory.
$ cp ./src/fortigate.json $HOME/boxes/
9\. Change the current working directory to `boxes`.
$ cd $HOME/boxes
10\. Substitute the `HOME` placeholder string in the box metadata file.
$ awk '/url/{gsub(/^ */,"");print}' fortigate.json
"url": "file://HOME/boxes/fortinet-fortigate-VER.box"
$ sed -i "s|HOME|${HOME}|" fortigate.json
$ awk '/url/{gsub(/^ */,"");print}' fortigate.json
"url": "file:///home/marc/boxes/fortinet-fortigate-VER.box"
11\. Also, substitute the `VER` placeholder string with the FortiOS version you're using.
$ awk '/VER/{gsub(/^ */,"");print}' fortigate.json
"version": "VER",
"url": "file:///home/marc/boxes/fortinet-fortigate-VER.box"
$ sed -i 's/VER/7.2.0/g' fortigate.json
$ awk '/\<version\>|url/{gsub(/^ */,"");print}' fortigate.json
"version": "7.2.0",
"url": "file:///home/marc/boxes/fortinet-fortigate-7.2.0.box"
12\. Add the Vagrant box to the local inventory.
$ vagrant box add --box-version 7.2.0 fortigate.json
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details