Skip to content

kaszebenetes/linux-vm-provisioning-examples

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

linux-vm-provisioning-examples

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

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.

Built With

  • Vagrant
  • Ansible
  • Shell Script
  • Python

Getting Started

Installing libvirt

Fedora

  1. Update the package first:

    sudo dnf update
  2. Install the required packages:

    sudo -i
    dnf install @virtualization
    dnf install libvirt libvirt-devel qemu-kvm
    
  3. Start and enable the libvirtd service:

    sudo systemctl start libvirtd
    sudo systemctl enable libvirtd

Ubuntu

  1. Update the package first:

    sudo apt update
  2. Install the required packages:

    sudo apt install libvirt-bin qemu-kvm
  3. Start and enable the libvirtd service:

    sudo systemctl start libvirtd
    sudo systemctl enable libvirtd

Red Hat

  1. Update the package first:

    sudo yum update
  2. Install the required packages:

    sudo yum install libvirt libvirt-devel qemu-kvm
    
  3. Start and enable the libvirtd service:

    sudo systemctl start libvirtd
    sudo systemctl enable libvirtd

Installing Vagrant

Fedora

  1. Add the HashiCorp repository:

    sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
  2. Install Vagrant:

    sudo dnf install vagrant

Ubuntu

  1. Download the Vagrant package:

    curl -O https://releases.hashicorp.com/vagrant/2.3.4/vagrant_2.3.4_x86_64.deb
  2. Install the package:

    sudo apt install ./vagrant_2.3.4_x86_64.deb

Red Hat

  1. Add the HashiCorp repository:

    sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
  2. Install Vagrant:

    sudo yum install vagrant

Installing Ansible, Python

Fedora

Instalation:

sudo -i
dnf install -y git python3-pip curl sudo
pip3 install ansible

Ubuntu

Instalation:

sudo -i
apt install python3
apt install python3-pip
apt install ansible

Red Hat

Instalation:

sudo -i
dnf install epel-release
dnf install python3
dnf install python3-pip
dnf install ansible

Usage

Vagrant provisioning(shell):

  1. Create/Choose catalog where you want to extract the repository, in example:

    mkdir ~/Documents/
    cd ~/Documents/
  2. Cloning repository:

    git clone https://github.com/kaszebenetes/examples.git
  3. 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.

Ansible:

  1. Create/Choose catalog where you want to extract the repository, in example:

    mkdir ~/Documents/
    cd ~/Documents/
  2. Clone repository:

    git clone https://github.com/kaszebenetes/examples.git
  3. Run vagrant:

    // Getting to relevant catalog
    cd linux-vm-provisioning-examples/vagrant_haproxy_tcp_nginx_ansible/ 
    // Starting up virtual machines using Vagrant
    vagrant up
  4. 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

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GNU GPLv3 License. See LICENSE for more information.

Contact

Project Link: https://github.com/kaszebenetes/linux-vm-provisioning-examples

Acknowledgements

About

The project demonstrates two approaches to automatically creating and configuring a Linux environment based on QEMU/KVM virtual machines.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors