{"id":13876073,"url":"https://github.com/kayrus/deploy-vm","last_synced_at":"2025-04-30T16:26:33.601Z","repository":{"id":76014653,"uuid":"46121437","full_name":"kayrus/deploy-vm","owner":"kayrus","description":"Libvirt wrapper to spawn VMs using cloud images","archived":false,"fork":false,"pushed_at":"2021-02-26T21:05:48.000Z","size":128,"stargazers_count":59,"open_issues_count":8,"forks_count":18,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-19T06:57:04.855Z","etag":null,"topics":["centos","cloud-image","cloud-init","coreos","freebsd","kvm","libvirt","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kayrus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-11-13T12:44:30.000Z","updated_at":"2024-05-04T10:14:07.000Z","dependencies_parsed_at":"2023-02-26T03:30:17.059Z","dependency_job_id":null,"html_url":"https://github.com/kayrus/deploy-vm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayrus%2Fdeploy-vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayrus%2Fdeploy-vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayrus%2Fdeploy-vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayrus%2Fdeploy-vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kayrus","download_url":"https://codeload.github.com/kayrus/deploy-vm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251741298,"owners_count":21636223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["centos","cloud-image","cloud-init","coreos","freebsd","kvm","libvirt","ubuntu"],"created_at":"2024-08-06T06:00:59.763Z","updated_at":"2025-04-30T16:26:33.581Z","avatar_url":"https://github.com/kayrus.png","language":"Shell","readme":"## Install libvirt on Ubuntu\n\n```sh\nsudo apt-get install -y libvirt-bin virtinst qemu-kvm virt-manager git wget genisoimage\nsudo service libvirt-bin start\n```\n\nFor the Windows VM support install `bsdtar` (this tool allows to extract zip archive from stdin):\n\n```sh\nsudo apt-get install bsdtar\n```\n\n## Install on Fedora/CentOS\n\n```sh\nsudo yum install -y libvirt virt-install qemu-kvm virt-manager git wget genisoimage NetworkManager\nsudo service libvirtd start\n```\n\nFor the Windows VM support install `bsdtar` (this tool allows to extract zip archive from stdin):\n\n```sh\nsudo yum install bsdtar\n```\n\nThis string inside your `~/.profile` will allow you to use `virsh`:\n\n```sh\nexport LIBVIRT_DEFAULT_URI=qemu:///system\n```\n\n## Configure local resolver to use libvirt's dnsmasq\n\n* Ubuntu 18.04 (`systemd-resolved` [(c)](https://wiki.ubuntu.com/SecurityTeam/TestingEnvironment#Tell_systemd-resolved_to_use_libvirt.27s_dnsmasq_for_VMs_only_.2817.04.2B-.29))\n\nThe setting below is not preserved on reboot:\n\n```sh\nsystemd-resolve --set-dns=192.168.122.1 --set-domain=vm --interface=virbr0\n```\n\nVerify:\n\n```sh\nsystemd-resolve --status virbr0\n```\n\nAdd the following section into libvirt default network (`sudo virsh net-edit default`):\n\n```xml\n  \u003cdomain name='vm' localOnly='yes'/\u003e\n```\n\nAnd restart the network:\n\n```sh\nsudo virsh net-destroy default\nsudo virsh net-start default\n```\n\n* Ubuntu/Debian\n\n```sh\nvirsh net-dumpxml default | sed -r \":a;N;\\$!ba;s#.*address='([0-9.]+)'.*#nameserver \\1#\" | sudo tee -a /etc/resolvconf/resolv.conf.d/head \u0026\u0026 sudo resolvconf -u\n```\n\n* Fedora/CentOS\n\n```sh\nsudo systemctl enable NetworkManager\necho -e \"[main]\\ndns=dnsmasq\" | sudo tee -a /etc/NetworkManager/NetworkManager.conf\nvirsh net-dumpxml default | sed -r \":a;N;\\$!ba;s#.*address='([0-9.]+)'.*#server=\\1\\nall-servers#\" | sudo tee /etc/NetworkManager/dnsmasq.d/libvirt_dnsmasq.conf\nsudo systemctl restart NetworkManager\n```\n\n## Add current user into `libvirt` group (will allow you to run scripts without `sudo`)\n\n```sh\nsudo usermod -aG libvirtd $USER # for Debian/Ubuntu14.04/Ubuntu16.04\nsudo usermod -aG libvirt $USER # for CentOS/Fedora/Ubuntu18.04\n```\n\n**NOTE**: You have to relogin into your UI environment to apply these changes.\n\n## Allow libvirt to read VMs images in your home directory\n\n### ACL solution\n\n#### Add permissions\n\n```sh\nsetfacl -m \"u:libvirt-qemu:--x\" $HOME # for Debian/Ubuntu\nsetfacl -m \"u:qemu:--x\" $HOME # for CentOS/Fedora\n```\n\n#### Remove permissions\n\n##### Remove ACL entries only for libvirt\n\n```sh\nsetfacl -m \"u:libvirt-qemu:---\" $HOME # for Debian/Ubuntu\nsetfacl -m \"u:qemu:---\" $HOME # for CentOS/Fedora\n```\n\n##### Remove all custom ACL entries\n\n```sh\nsetfacl -b $HOME\ngetfacl $HOME\n```\n\n### Groups solution\n\n#### Add permissions\n\n```sh\nsudo usermod -aG $USER libvirt-qemu # for Debian/Ubuntu\nsudo usermod -aG $USER qemu # for CentOS/Fedora\nchmod g+x $HOME\n```\n\n#### Remove permissions\n\n```sh\nsudo usermod -G \"\" libvirt-qemu # for Debian/Ubuntu\nsudo usermod -G \"kvm\" qemu # for CentOS/Fedora\nchmod g-x $HOME\n```\n\n## Configure virsh environment\n\n```sh\necho \"export LIBVIRT_DEFAULT_URI=qemu:///system\" \u003e\u003e ~/.bashrc\n```\n\n## Configure ~/.ssh/config\n\n```sh\ncat dot_ssh_config \u003e\u003e ~/.ssh/config\nchmod 600 ~/.ssh/config\n```\n\n## Run Flatcar VMs cluster of 3 nodes\n\n```sh\n./deploy_flatcar_cluster.sh -s 3\n```\n\n`user_data` file works only for Flatcar and contains a template for Flatcar configuration and it configures `etcd2` and `fleet`.\n\n## Try out Tectonic\n\nCreate Tectonoic credentials files:\n\n* `tectonic.lic` # raw base64 encoded licence\n* `docker.cfg` # raw base64 encoded dockercfg\n\nDeploy cluster:\n\n```sh\n./deploy_k8s_cluster.sh --tectonic\n```\n\nEnter your Kubernetes master node:\n\n```sh\nssh core@k8s-master # [-i ~/.ssh/id_rsa]\n```\n\nGet Tectonic `admin@example.com` password:\n\n```sh\nkubectl --namespace=tectonic-system get secret tectonic-identity-admin-password -o template --template=\"{{.data.password}}\" | base64 -d \u0026\u0026 echo\n```\n\nLogin Tectonic:\n\n[https://k8s-master:32000](https://k8s-master:32000)\n\nUsername: `admin@example.com`\nPassword: see above\n\n## Run other VMs\n\n### Linux\n\nRun three CentOS VMs\n\n```sh\n./deploy_vms_cluster.sh -o centos -s 3\n```\n\n### Windows\n\nRun one Windows IE11.Win7 VM\n\n```sh\n./deploy_vms_cluster.sh -o windows -r IE11.Win7 -m 1024 -u 2\n```\n\n### FreeBSD guest (experimental)\n\nDownload and run FreeBSD:\n\n```sh\n./deploy_vms_cluster.sh -o freebsd # for 10.3 RELEASE\n./deploy_vms_cluster.sh -o freebsd -c 11.0 -r RC1 # for 11.0 RC1\n```\n\nFreeBSD QEMU images don't support `cloud-init`, so you have to configure network and ssh manually through the console:\n\n```sh\ndhclient vtnet0\necho 'sshd_enable=YES' \u003e\u003e /etc/rc.conf\necho 'ifconfig_DEFAULT=DHCP' \u003e\u003e /etc/rc.conf\necho 'PermitRootLogin yes' \u003e\u003e /etc/ssh/sshd_config\nservice sshd start\npasswd\n```\n\n## FreeBSD host (experimental)\n\n```sh\npkg install bash wget bzip2 gnupg cdrtools libvirt qemu virt-manager\nkldload vmm\nlibvirtd -d\nifconfig tap create\nifconfig bridge create\nifconfig bridge0 addm tap0 up\n```\n\nvirt-install version \u003e 1.4 should use following parameters:\n\n```sh\n--nographic \\\n--console nmdm,source.master=/dev/nmdm0A,source.slave=/dev/nmdm0B \\\n--network bridge=bridge0 \\\n```\n\nand without `--vnc` flag. VNC flag produces following XML:\n\n```xml\n\u003cgraphics type=\"vnc\" port=\"-1\" keymap=\"en-us\"/\u003e\n```\n\nwhich causes `internal error: cannot determine default video type` error message.\n\n## Completely destroy and remove all related VMs cluster data\n\n```sh\n./remove_cluster.sh flatcar\n```\n","funding_links":[],"categories":["Shell","ubuntu"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayrus%2Fdeploy-vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkayrus%2Fdeploy-vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayrus%2Fdeploy-vm/lists"}