vm-tool


Namevm-tool JSON
Version 1.0.26 PyPI version JSON
download
home_pagehttps://github.com/thesunnysinha/vm_tool
SummaryA Comprehensive Tool for Setting Up Virtual Machines.
upload_time2025-02-16 09:48:15
maintainerNone
docs_urlNone
authorSunny Sinha
requires_python>=3.6
licenseMIT
keywords virtual machine setup ansible automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **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:  

```bash
pip install vm-tool
```

---

## **Example Usage**  

### **Automated VM Setup**  
Use the following example to configure and run the VM setup:  

```python
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:  
1. Configure Git with GitHub token if provided.
2. Clone the specified GitHub repository to your local machine.  
3. Install **Docker** if it’s not already available on the target machine.  
4. Install **Docker Compose** for managing multi-container applications.  
5. Log in to Docker Hub if credentials are provided.
6. Create, enable, and start the Docker service.  
7. 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:

```python
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_identity_file='/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:  
1. Connect to the specified cloud VM using SSH.  
2. Configure Git with GitHub token if provided.
3. Clone the specified GitHub repository to the VM.  
4. Install **Docker** if it’s not already available on the VM.  
5. Install **Docker Compose** for managing multi-container applications.  
6. Log in to Docker Hub if credentials are provided.
7. Create, enable, and start the Docker service on the VM.  
8. 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**  

```python
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:  
1. Generate an SSH key pair if none exists.  
2. Read the public SSH key or create a new one if necessary.  
3. Configure the VM by adding the public key to the VM's **authorized_keys** file.  
4. Update the local SSH configuration file with the VM's details.  
5. Establish an SSH connection to verify the setup.  
6. 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thesunnysinha/vm_tool",
    "name": "vm-tool",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "virtual machine setup ansible automation",
    "author": "Sunny Sinha",
    "author_email": "thesunnysinha@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b1/ae/256c1d067944e3567274c0b5ba501367ef7795160b9862c650aec54cf5df/vm_tool-1.0.26.tar.gz",
    "platform": null,
    "description": "# **VM Setup Tool**  \n### **A Comprehensive Solution for Streamlining Virtual Machine Configuration**\n\n## **Overview**  \nThe **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.\n\n---\n\n## **Pre-requisites**  \nThis tool supports projects utilizing **Docker Compose**.\n\n---\n\n## **Installation**  \nInstall the VM Setup Tool using **pip**, the Python package manager:  \n\n```bash\npip install vm-tool\n```\n\n---\n\n## **Example Usage**  \n\n### **Automated VM Setup**  \nUse the following example to configure and run the VM setup:  \n\n```python\nfrom vm_tool.runner import SetupRunner, SetupRunnerConfig\n\nconfig = SetupRunnerConfig(\n    github_username='your_github_username',  # Required if the repository is private, e.g., username\n    github_token='your_github_token',        # Required if the repository is private, e.g., token\n    github_project_url='your_github_project_url',  # e.g., https://github.com/username/repo\n    github_branch='your_branch_name',        # Optional, defaults to 'main'\n    docker_compose_file_path='path_to_your_docker_compose_file',  # Optional, defaults to 'docker-compose.yml'\n    dockerhub_username='your_dockerhub_username',  # Required if DockerHub login is needed, e.g., dockerhub_user\n    dockerhub_password='your_dockerhub_password'   # Required if DockerHub login is needed, e.g., dockerhub_password\n)\n\nrunner = SetupRunner(config)\n\nrunner.run_setup()\n```\n\n### **What Happens During Setup**  \nThe VM Setup Tool will:  \n1. Configure Git with GitHub token if provided.\n2. Clone the specified GitHub repository to your local machine.  \n3. Install **Docker** if it\u2019s not already available on the target machine.  \n4. Install **Docker Compose** for managing multi-container applications.  \n5. Log in to Docker Hub if credentials are provided.\n6. Create, enable, and start the Docker service.  \n7. Ensure the Docker container remains active, providing a robust environment for your applications.  \n\nBy automating these tasks, the tool minimizes errors and saves time, allowing you to focus on development and deployment.\n\n---\n\n## **Cloud Setup**  \nThe **VM Setup Tool** also supports cloud setup for VMs. Use the following example to configure and run the cloud setup:\n\n```python\nfrom vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig\n\nconfig = SetupRunnerConfig(\n    github_username='your_github_username',  # Required if the repository is private, e.g., username\n    github_token='your_github_token',        # Required if the repository is private, e.g., token\n    github_project_url='your_github_project_url',  # e.g., https://github.com/username/repo\n    github_branch='your_branch_name',        # Optional, defaults to 'main'\n    docker_compose_file_path='path_to_your_docker_compose_file',  # Optional, defaults to 'docker-compose.yml'\n    dockerhub_username='your_dockerhub_username',  # Required if DockerHub login is needed, e.g., dockerhub_user\n    dockerhub_password='your_dockerhub_password'   # Required if DockerHub login is needed, e.g., dockerhub_password\n)\n\nrunner = SetupRunner(config)\n\nssh_configs = [\n    SSHConfig(\n        ssh_username='your_ssh_username_1',           # e.g., ssh_user_1\n        ssh_password='your_ssh_password_1',           # Optional, only use if you don\u2019t want to use SSH key\n        ssh_hostname='your_ssh_hostname_1',           # e.g., ssh1.example.com\n        ssh_identity_file='/path/to/your/ssh_key_1'   # Optional, path to SSH Identity file\n    ),\n    SSHConfig(\n        ssh_username='your_ssh_username_2',           # e.g., ssh_user_2\n        ssh_password='your_ssh_password_2',           # Optional, only use if you don\u2019t want to use SSH key\n        ssh_hostname='your_ssh_hostname_2',           # e.g., ssh2.example.com\n        ssh_identity_file='/path/to/your/ssh_key_2'   # Optional, path to SSH Identity file\n    )\n    # Add more SSHConfig instances as needed\n]\n\nrunner.run_cloud_setup(ssh_configs)\n```\n\n### **What Happens During Cloud Setup**  \nWhen you run the cloud setup, the tool will:  \n1. Connect to the specified cloud VM using SSH.  \n2. Configure Git with GitHub token if provided.\n3. Clone the specified GitHub repository to the VM.  \n4. Install **Docker** if it\u2019s not already available on the VM.  \n5. Install **Docker Compose** for managing multi-container applications.  \n6. Log in to Docker Hub if credentials are provided.\n7. Create, enable, and start the Docker service on the VM.  \n8. Ensure the Docker container remains active, providing a robust environment for your applications.  \n\n---\n\n## **SSH Client Feature**  \nThe **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.\n\n### **Example Usage**  \n\n```python\nfrom vm_tool.ssh import SSHSetup\n\nssh_setup = SSHSetup(\n    hostname='your_vm_hostname',  # e.g., vm.example.com\n    username='your_vm_username',  # e.g., user\n    password='your_vm_password',  # e.g., password\n    email='your_email_for_ssh_key'  # e.g., user@example.com\n)\n\nssh_setup.setup()\n```\n\n### **What Happens During SSH Setup**  \nWhen you run the SSH setup, the tool will:  \n1. Generate an SSH key pair if none exists.  \n2. Read the public SSH key or create a new one if necessary.  \n3. Configure the VM by adding the public key to the VM's **authorized_keys** file.  \n4. Update the local SSH configuration file with the VM's details.  \n5. Establish an SSH connection to verify the setup.  \n6. Close the connection once setup is complete.  \n\n---\n\nWith 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.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Comprehensive Tool for Setting Up Virtual Machines.",
    "version": "1.0.26",
    "project_urls": {
        "Documentation": "https://github.com/thesunnysinha/vm_tool/README.md",
        "Homepage": "https://github.com/thesunnysinha/vm_tool",
        "Source": "https://github.com/thesunnysinha/vm_tool",
        "Tracker": "https://github.com/thesunnysinha/vm_tool/issues"
    },
    "split_keywords": [
        "virtual",
        "machine",
        "setup",
        "ansible",
        "automation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b1ae256c1d067944e3567274c0b5ba501367ef7795160b9862c650aec54cf5df",
                "md5": "0bbbcdc30606af2ec6772554e97d642c",
                "sha256": "eeada9031a39094e62729250cb94533deb26553fddbb19963be1c0b135b0a2a3"
            },
            "downloads": -1,
            "filename": "vm_tool-1.0.26.tar.gz",
            "has_sig": false,
            "md5_digest": "0bbbcdc30606af2ec6772554e97d642c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12537,
            "upload_time": "2025-02-16T09:48:15",
            "upload_time_iso_8601": "2025-02-16T09:48:15.827075Z",
            "url": "https://files.pythonhosted.org/packages/b1/ae/256c1d067944e3567274c0b5ba501367ef7795160b9862c650aec54cf5df/vm_tool-1.0.26.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-16 09:48:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thesunnysinha",
    "github_project": "vm_tool",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "vm-tool"
}
        
Elapsed time: 2.08569s