Table of Contents
The project demonstrates two approaches to automatically creating and configuring a Linux environment based on QEMU/KVM virtual machines. You can choose one of them:
Approach 1 (Vagrant Provisioning): Utilizes Vagrant to launch machines and execute configuration scripts within them.
Approach 2 (Ansible): Utilizes Vagrant to launch machines, but Ansible is used to define the target state of the infrastructure and perform automatic configuration.
Tests: I have created SSH connectivity tests using Bash, Python, and the Pyinfra framework to ensure seamless server communication and validate firewall rules.
Fedora
-
Update the package first:
sudo dnf update
-
Install the required packages:
sudo -i dnf install @virtualization dnf install libvirt libvirt-devel qemu-kvm
-
Start and enable the libvirtd service:
sudo systemctl start libvirtd sudo systemctl enable libvirtd
Ubuntu
-
Update the package first:
sudo apt update
-
Install the required packages:
sudo apt install libvirt-bin qemu-kvm
-
Start and enable the libvirtd service:
sudo systemctl start libvirtd sudo systemctl enable libvirtd
Red Hat
-
Update the package first:
sudo yum update
-
Install the required packages:
sudo yum install libvirt libvirt-devel qemu-kvm
-
Start and enable the libvirtd service:
sudo systemctl start libvirtd sudo systemctl enable libvirtd
Fedora
-
Add the HashiCorp repository:
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
-
Install Vagrant:
sudo dnf install vagrant
Ubuntu
-
Download the Vagrant package:
curl -O https://releases.hashicorp.com/vagrant/2.3.4/vagrant_2.3.4_x86_64.deb
-
Install the package:
sudo apt install ./vagrant_2.3.4_x86_64.deb
Red Hat
-
Add the HashiCorp repository:
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
-
Install Vagrant:
sudo yum install vagrant
Fedora
Instalation:
sudo -i
dnf install -y git python3-pip curl sudo
pip3 install ansibleUbuntu
Instalation:
sudo -i
apt install python3
apt install python3-pip
apt install ansibleRed Hat
Instalation:
sudo -i
dnf install epel-release
dnf install python3
dnf install python3-pip
dnf install ansible-
Create/Choose catalog where you want to extract the repository, in example:
mkdir ~/Documents/ cd ~/Documents/
-
Cloning repository:
git clone https://github.com/kaszebenetes/examples.git
-
Run vagrant:
// Getting to relevant catalog cd linux-vm-provisioning-examples/vagrant_haproxy_tcp_nginx_shell/ // Starting up virtual machines using Vagrant vagrant up // Provisioning will be done by itself.
-
Create/Choose catalog where you want to extract the repository, in example:
mkdir ~/Documents/ cd ~/Documents/
-
Clone repository:
git clone https://github.com/kaszebenetes/examples.git
-
Run vagrant:
// Getting to relevant catalog cd linux-vm-provisioning-examples/vagrant_haproxy_tcp_nginx_ansible/ // Starting up virtual machines using Vagrant vagrant up -
Change user_name in ansible/inventories/inventory.yaml to your Fedora username and run Ansible:
// Edit and change user_name vim ~/Documents/linux-vm-provisioning-examples/vagrant_haproxy_tcp_nginx_ansible/ansible/inventories/inventory.yaml // run ansible cd ~/Documents/linux-vm-provisioning-examples/vagrant_haproxy_tcp_nginx_ansible/ansible/ ansible-playbook -i ./inventories/inventory.yaml playbook-vms.yaml
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the GNU GPLv3 License. See LICENSE for more information.
Project Link: https://github.com/kaszebenetes/linux-vm-provisioning-examples