A Comprehensive Tool for Setting Up Virtual Machines.
Project description
VM Setup Tool
A Comprehensive Solution for Streamlining Virtual Machine Configuration
Overview
The VM Setup Tool is an efficient, user-friendly solution designed to simplify the process of setting up and managing virtual machines (VMs) using Ansible. Ideal for automating VM deployment and configuration, this tool ensures consistency and enhances operational efficiency across your infrastructure.
Pre-requisites
This tool supports projects utilizing Docker Compose.
Installation
Install the VM Setup Tool using pip, the Python package manager:
pip install vm-tool
Example Usage
Automated VM Setup
Use the following example to configure and run the VM setup:
from vm_tool.runner import SetupRunner, SetupRunnerConfig
config = SetupRunnerConfig(
github_username='your_github_username', # Required if the repository is private, e.g., username
github_token='your_github_token', # Required if the repository is private, e.g., token
github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
github_branch='your_branch_name', # Optional, defaults to 'main'
docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
)
runner = SetupRunner(config)
runner.run_setup()
What Happens During Setup
The VM Setup Tool will:
- Configure Git with GitHub token if provided.
- Clone the specified GitHub repository to your local machine.
- Install Docker if it’s not already available on the target machine.
- Install Docker Compose for managing multi-container applications.
- Log in to Docker Hub if credentials are provided.
- Create, enable, and start the Docker service.
- Ensure the Docker container remains active, providing a robust environment for your applications.
By automating these tasks, the tool minimizes errors and saves time, allowing you to focus on development and deployment.
Cloud Setup
The VM Setup Tool also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:
from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
config = SetupRunnerConfig(
github_username='your_github_username', # Required if the repository is private, e.g., username
github_token='your_github_token', # Required if the repository is private, e.g., token
github_project_url='your_github_project_url', # e.g., https://github.com/username/repo
github_branch='your_branch_name', # Optional, defaults to 'main'
docker_compose_file_path='path_to_your_docker_compose_file', # Optional, defaults to 'docker-compose.yml'
dockerhub_username='your_dockerhub_username', # Required if DockerHub login is needed, e.g., dockerhub_user
dockerhub_password='your_dockerhub_password' # Required if DockerHub login is needed, e.g., dockerhub_password
)
runner = SetupRunner(config)
ssh_configs = [
SSHConfig(
ssh_username='your_ssh_username_1', # e.g., ssh_user_1
ssh_password='your_ssh_password_1', # Optional, only use if you don’t want to use SSH key
ssh_hostname='your_ssh_hostname_1', # e.g., ssh1.example.com
ssh_identity_file='/path/to/your/ssh_key_1' # Optional, path to SSH Identity file
),
SSHConfig(
ssh_username='your_ssh_username_2', # e.g., ssh_user_2
ssh_password='your_ssh_password_2', # Optional, only use if you don’t want to use SSH key
ssh_hostname='your_ssh_hostname_2', # e.g., ssh2.example.com
ssh_key='/path/to/your/ssh_key_2' # Optional, path to SSH Identity file
)
# Add more SSHConfig instances as needed
]
runner.run_cloud_setup(ssh_configs)
What Happens During Cloud Setup
When you run the cloud setup, the tool will:
- Connect to the specified cloud VM using SSH.
- Configure Git with GitHub token if provided.
- Clone the specified GitHub repository to the VM.
- Install Docker if it’s not already available on the VM.
- Install Docker Compose for managing multi-container applications.
- Log in to Docker Hub if credentials are provided.
- Create, enable, and start the Docker service on the VM.
- Ensure the Docker container remains active, providing a robust environment for your applications.
SSH Client Feature
The VM Setup Tool also includes a dedicated SSH client feature to simplify the configuration of SSH access for VMs, including automated SSH key generation and management.
Example Usage
from vm_tool.ssh import SSHSetup
ssh_setup = SSHSetup(
hostname='your_vm_hostname', # e.g., vm.example.com
username='your_vm_username', # e.g., user
password='your_vm_password', # e.g., password
email='your_email_for_ssh_key' # e.g., user@example.com
)
ssh_setup.setup()
What Happens During SSH Setup
When you run the SSH setup, the tool will:
- Generate an SSH key pair if none exists.
- Read the public SSH key or create a new one if necessary.
- Configure the VM by adding the public key to the VM's authorized_keys file.
- Update the local SSH configuration file with the VM's details.
- Establish an SSH connection to verify the setup.
- Close the connection once setup is complete.
With its comprehensive features, the VM Setup Tool eliminates the hassle of manual configurations and enables seamless integration of VMs into your workflows. Start using the tool today to automate and optimize your virtual machine setup process.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file vm_tool-1.0.25.tar.gz.
File metadata
- Download URL: vm_tool-1.0.25.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c3f3b3797f058d6c20e6e0e9d2b6be8a4fab71a78ed1496bb6abac069be69f4
|
|
| MD5 |
236ab1105814c2c9b0fc60f9e790eed5
|
|
| BLAKE2b-256 |
89935f258e4254868b32f9170428b69749e79885a6277f87f370036c9714b516
|