Provisioning script template for ubuntu virtual environment using vagrant or multipass cloud init.
- Language - Java, NodeJS, PHP, Ruby(using rbenv)
- DB - MariaDB, MySQL, Postgres
- APP - Code Server, Docker, Drupal, Hugo, Ruby on Rails, Rclone, Seatable, Wordpress, mecab-ko
- clone the repo
- modify your environment variables to use this repo's template as VAGRANT_DEFAULT_TEMPLATE.
## ~/.bashrc # or your file of choice.
export VAGRANT_DEFAULT_TEMPLATE=/path/to/ubuntu-provision/vagrant/Vagrantfile.erb
$ source ~/.bashrc
- Create vagrant file with necessary application(s) you need as parameter(s) and boot virtual environment.
$ mkdir foo
$ cd foo
$ APP=hugo vagrant init
- Reference vagrant/Vagrantfile.erb for list of parameters to include as provision scripts.
- If declaring multiple langs, db, apps, delimit them with comma(s).
$ APP=hugo,rclone,mecab-ko vagrant init
- Further modify your Vagrantfile or .env file and then vagrant up.
$ cd path/to/vagrantfile
$ vagrant up
- clone the repo
- copy cloud-init.yml.example to create cloud-init.yml configuration file
- edit cloud-init.yml to include variables or scripts
- launch multipass
$ multipass launch -n project_name --cloud-init /path/to/cloud-init.yml
https://docs.j7k6.org/mount-qcow2-disk-image-linux/
$ sudo apt -y install qemu-utils
# $ IMG=/var/snap/multipass/common/data/multipassd/vault/instances/php7/ubuntu-20.04-server-cloudimg-amd64.img
$ IMG=/var/snap/multipass/common/data/multipassd/vault/instances/mariadb/ubuntu-20.04-server-cloudimg-amd64.img
$ sudo modprobe nbd max_part=8
$ sudo qemu-nbd --connect=/dev/nbd0 --read-only $IMG
$ sudo fdisk -l /dev/nbd0
$ sudo mount -o ro /dev/nbd0p1 /home/mozo/mnt
$ mkdir ~/php7
$ cd /home/mozo/mnt/home/ubuntu/projects/
$ cp -r ./* ~/php7/*
$ sudo umount /home/mozo/mnt
$ sudo qemu-nbd --disconnect /dev/nbd0