vm-tool 1.0.29__tar.gz → 1.0.32__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vm_tool-1.0.32/.devcontainer/devcontainer.json +18 -0
- vm_tool-1.0.32/.github/dependabot.yml +19 -0
- vm_tool-1.0.32/.github/workflows/ci.yml +57 -0
- vm_tool-1.0.32/.github/workflows/deploy.yml +207 -0
- vm_tool-1.0.32/.github/workflows/publish.yml +37 -0
- vm_tool-1.0.32/.gitignore +35 -0
- vm_tool-1.0.32/.pre-commit-config.yaml +14 -0
- vm_tool-1.0.32/CONTRIBUTING +57 -0
- vm_tool-1.0.32/CONTRIBUTING.md +40 -0
- vm_tool-1.0.32/Makefile +19 -0
- {vm_tool-1.0.29/vm_tool.egg-info → vm_tool-1.0.32}/PKG-INFO +65 -21
- {vm_tool-1.0.29 → vm_tool-1.0.32}/README.md +51 -4
- vm_tool-1.0.32/codePushToGithub.sh +47 -0
- vm_tool-1.0.32/docs/MODULE_GUIDE.md +42 -0
- vm_tool-1.0.32/docs/deployment-approaches.md +117 -0
- vm_tool-1.0.32/docs/ec2-github-actions-guide.md +519 -0
- vm_tool-1.0.32/docs/features.md +104 -0
- vm_tool-1.0.32/docs/generator.md +283 -0
- vm_tool-1.0.32/docs/index.md +114 -0
- vm_tool-1.0.32/docs/pipeline-generator.md +234 -0
- vm_tool-1.0.32/docs/reference/runner.md +3 -0
- vm_tool-1.0.32/docs/reference/ssh.md +3 -0
- vm_tool-1.0.32/docs/ssh-key-setup.md +211 -0
- vm_tool-1.0.32/docs/usage.md +468 -0
- vm_tool-1.0.32/examples/README.md +5 -0
- vm_tool-1.0.32/examples/__init__.py +1 -0
- vm_tool-1.0.32/examples/cloud/README.md +3 -0
- vm_tool-1.0.32/examples/cloud/__init__.py +1 -0
- vm_tool-1.0.32/examples/cloud/ssh_identity_file.py +27 -0
- vm_tool-1.0.32/examples/cloud/ssh_password.py +27 -0
- vm_tool-1.0.32/examples/cloud/template_cloud_setup.py +36 -0
- vm_tool-1.0.32/examples/deploy_full_setup.py +44 -0
- vm_tool-1.0.32/examples/docker-compose.example.yml +47 -0
- vm_tool-1.0.32/examples/ec2-setup.sh +95 -0
- vm_tool-1.0.32/examples/github-actions-ec2.yml +245 -0
- vm_tool-1.0.32/examples/github-actions-full-setup.yml +58 -0
- vm_tool-1.0.32/examples/local/.keep +1 -0
- vm_tool-1.0.32/examples/local/README.md +3 -0
- vm_tool-1.0.32/examples/local/__init__.py +1 -0
- vm_tool-1.0.32/examples/local/template_local_setup.py +27 -0
- vm_tool-1.0.32/examples/production-deploy.sh +70 -0
- vm_tool-1.0.32/examples/rollback.sh +52 -0
- vm_tool-1.0.32/examples/setup.sh +52 -0
- vm_tool-1.0.32/examples/ssh_key_management.py +22 -0
- vm_tool-1.0.32/examples/version_check.sh +3 -0
- vm_tool-1.0.32/mkdocs.yml +26 -0
- vm_tool-1.0.32/molecule/default/converge.yml +7 -0
- vm_tool-1.0.32/molecule/default/molecule.yml +17 -0
- vm_tool-1.0.32/molecule/default/verify.yml +7 -0
- vm_tool-1.0.32/pyproject.toml +95 -0
- vm_tool-1.0.32/requirements-docs.txt +2 -0
- vm_tool-1.0.32/requirements.txt +88 -0
- vm_tool-1.0.32/setup.py +66 -0
- vm_tool-1.0.32/tests/conftest.py +29 -0
- vm_tool-1.0.32/tests/integration/test_deployment.py +99 -0
- vm_tool-1.0.32/tests/test_config.py +119 -0
- vm_tool-1.0.32/tests/test_generator.py +85 -0
- vm_tool-1.0.32/tests/test_health.py +148 -0
- vm_tool-1.0.32/tests/test_history.py +187 -0
- vm_tool-1.0.32/tests/test_logging.py +72 -0
- vm_tool-1.0.32/tests/test_runner.py +51 -0
- vm_tool-1.0.32/tests/test_ssh.py +54 -0
- vm_tool-1.0.32/tests/test_state.py +143 -0
- vm_tool-1.0.32/vm_tool/alerting.py +274 -0
- vm_tool-1.0.32/vm_tool/audit.py +118 -0
- vm_tool-1.0.32/vm_tool/backup.py +125 -0
- vm_tool-1.0.32/vm_tool/benchmarking.py +200 -0
- vm_tool-1.0.32/vm_tool/cli.py +761 -0
- vm_tool-1.0.32/vm_tool/cloud.py +125 -0
- vm_tool-1.0.32/vm_tool/completion.py +200 -0
- vm_tool-1.0.32/vm_tool/compliance.py +104 -0
- vm_tool-1.0.32/vm_tool/config.py +92 -0
- vm_tool-1.0.32/vm_tool/drift.py +98 -0
- vm_tool-1.0.32/vm_tool/generator.py +462 -0
- vm_tool-1.0.32/vm_tool/health.py +197 -0
- vm_tool-1.0.32/vm_tool/history.py +131 -0
- vm_tool-1.0.32/vm_tool/kubernetes.py +89 -0
- vm_tool-1.0.32/vm_tool/metrics.py +183 -0
- vm_tool-1.0.32/vm_tool/notifications.py +152 -0
- vm_tool-1.0.32/vm_tool/plugins.py +119 -0
- vm_tool-1.0.32/vm_tool/policy.py +197 -0
- vm_tool-1.0.32/vm_tool/rbac.py +140 -0
- vm_tool-1.0.32/vm_tool/recovery.py +169 -0
- vm_tool-1.0.32/vm_tool/reporting.py +218 -0
- vm_tool-1.0.32/vm_tool/runner.py +445 -0
- vm_tool-1.0.32/vm_tool/secrets.py +285 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/ssh.py +50 -17
- vm_tool-1.0.32/vm_tool/state.py +122 -0
- vm_tool-1.0.32/vm_tool/strategies/__init__.py +16 -0
- vm_tool-1.0.32/vm_tool/strategies/ab_testing.py +258 -0
- vm_tool-1.0.32/vm_tool/strategies/blue_green.py +227 -0
- vm_tool-1.0.32/vm_tool/strategies/canary.py +277 -0
- vm_tool-1.0.32/vm_tool/validation.py +267 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/docker/create_docker_service.yml +1 -1
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/github/git_configuration.yml +0 -5
- vm_tool-1.0.32/vm_tool/vm_setup/k8s.yml +15 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/main.yml +8 -0
- vm_tool-1.0.32/vm_tool/vm_setup/monitoring.yml +42 -0
- vm_tool-1.0.32/vm_tool/vm_setup/push_code.yml +40 -0
- vm_tool-1.0.32/vm_tool/vm_setup/setup.yml +17 -0
- vm_tool-1.0.32/vm_tool/vm_setup/setup_project_env.yml +7 -0
- vm_tool-1.0.32/vm_tool/webhooks.py +83 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32/vm_tool.egg-info}/PKG-INFO +65 -21
- vm_tool-1.0.32/vm_tool.egg-info/SOURCES.txt +116 -0
- vm_tool-1.0.32/vm_tool.egg-info/requires.txt +18 -0
- vm_tool-1.0.32/vm_tool.egg-info/top_level.txt +2 -0
- vm_tool-1.0.29/setup.py +0 -63
- vm_tool-1.0.29/vm_tool/cli.py +0 -9
- vm_tool-1.0.29/vm_tool/runner.py +0 -208
- vm_tool-1.0.29/vm_tool/vm_setup/dynamic_inventory.yml +0 -8
- vm_tool-1.0.29/vm_tool/vm_setup/setup.yml +0 -11
- vm_tool-1.0.29/vm_tool.egg-info/SOURCES.txt +0 -25
- vm_tool-1.0.29/vm_tool.egg-info/requires.txt +0 -10
- vm_tool-1.0.29/vm_tool.egg-info/top_level.txt +0 -1
- {vm_tool-1.0.29 → vm_tool-1.0.32}/LICENSE +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/MANIFEST.in +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/setup.cfg +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/cleanup.yml +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/docker/docker_setup.yml +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/docker/login_to_docker_hub.yml +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/inventory.yml +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool/vm_setup/project_service.yml +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0.29 → vm_tool-1.0.32}/vm_tool.egg-info/entry_points.txt +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "VM Tool Dev",
|
|
3
|
+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
|
|
4
|
+
"features": {
|
|
5
|
+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
|
|
6
|
+
},
|
|
7
|
+
"customizations": {
|
|
8
|
+
"vscode": {
|
|
9
|
+
"extensions": [
|
|
10
|
+
"ms-python.python",
|
|
11
|
+
"ms-python.flake8",
|
|
12
|
+
"charliermarsh.ruff",
|
|
13
|
+
"redhat.ansible"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"postCreateCommand": "pip install -e .[dev] && pip install pre-commit && pre-commit install"
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "pip"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
groups:
|
|
8
|
+
dependencies:
|
|
9
|
+
patterns:
|
|
10
|
+
- "*"
|
|
11
|
+
|
|
12
|
+
- package-ecosystem: "github-actions"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
16
|
+
groups:
|
|
17
|
+
dependencies:
|
|
18
|
+
patterns:
|
|
19
|
+
- "*"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install flake8 pytest
|
|
28
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
29
|
+
pip install -e .[dev]
|
|
30
|
+
|
|
31
|
+
- name: Lint with flake8
|
|
32
|
+
run: |
|
|
33
|
+
# stop the build if there are Python syntax errors or undefined names
|
|
34
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
35
|
+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
36
|
+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
37
|
+
|
|
38
|
+
- name: Test with pytest
|
|
39
|
+
run: |
|
|
40
|
+
pytest
|
|
41
|
+
|
|
42
|
+
security:
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v6
|
|
46
|
+
|
|
47
|
+
- name: Set up Python
|
|
48
|
+
uses: actions/setup-python@v6
|
|
49
|
+
with:
|
|
50
|
+
python-version: "3.12"
|
|
51
|
+
|
|
52
|
+
- name: Install Bandit
|
|
53
|
+
run: pip install bandit
|
|
54
|
+
|
|
55
|
+
- name: Run Bandit Scan
|
|
56
|
+
# -r: recursive, -ll: log level (only high/medium), -ii: confidence level
|
|
57
|
+
run: bandit -r vm_tool -ll -ii
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
name: Deploy to EC2 with vm_tool
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ develop ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
env:
|
|
11
|
+
EC2_HOST: ${{ secrets.EC2_HOST }}
|
|
12
|
+
EC2_USER: ${{ secrets.EC2_USER }}
|
|
13
|
+
APP_PORT: 8000
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
deploy:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Validate Required Secrets
|
|
24
|
+
run: |
|
|
25
|
+
echo "🔐 Validating GitHub Secrets..."
|
|
26
|
+
MISSING_SECRETS=()
|
|
27
|
+
|
|
28
|
+
if [ -z "${{ secrets.EC2_HOST }}" ]; then
|
|
29
|
+
MISSING_SECRETS+=("EC2_HOST")
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
if [ -z "${{ secrets.EC2_USER }}" ]; then
|
|
33
|
+
MISSING_SECRETS+=("EC2_USER")
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
if [ -z "${{ secrets.EC2_SSH_KEY }}" ]; then
|
|
37
|
+
MISSING_SECRETS+=("EC2_SSH_KEY")
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
if [ ${#MISSING_SECRETS[@]} -ne 0 ]; then
|
|
41
|
+
echo ""
|
|
42
|
+
echo "❌ ERROR: Missing required GitHub Secrets!"
|
|
43
|
+
echo ""
|
|
44
|
+
echo "Missing: ${MISSING_SECRETS[*]}"
|
|
45
|
+
echo ""
|
|
46
|
+
echo "📝 How to add secrets:"
|
|
47
|
+
echo "1. Go to: Repository → Settings → Secrets → Actions"
|
|
48
|
+
echo "2. Add each secret:"
|
|
49
|
+
echo ""
|
|
50
|
+
|
|
51
|
+
if [[ " ${MISSING_SECRETS[*]} " =~ " EC2_HOST " ]]; then
|
|
52
|
+
echo " EC2_HOST: Your EC2 IP (e.g., 54.123.45.67)"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
if [[ " ${MISSING_SECRETS[*]} " =~ " EC2_USER " ]]; then
|
|
56
|
+
echo " EC2_USER: SSH username (e.g., ubuntu)"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
if [[ " ${MISSING_SECRETS[*]} " =~ " EC2_SSH_KEY " ]]; then
|
|
60
|
+
echo " EC2_SSH_KEY: Run 'cat ~/.ssh/id_rsa' and copy output"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
echo ""
|
|
64
|
+
echo "📚 See: docs/ssh-key-setup.md"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
echo "✅ All secrets configured"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
- name: Set up Python
|
|
72
|
+
uses: actions/setup-python@v4
|
|
73
|
+
with:
|
|
74
|
+
python-version: '{self.python_version}'
|
|
75
|
+
|
|
76
|
+
- name: Install vm_tool
|
|
77
|
+
run: pip install vm-tool
|
|
78
|
+
|
|
79
|
+
- name: Lint with flake8
|
|
80
|
+
run: |
|
|
81
|
+
pip install flake8
|
|
82
|
+
# stop the build if there are Python syntax errors or undefined names
|
|
83
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
84
|
+
# exit-zero treats all errors as warnings.
|
|
85
|
+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
86
|
+
|
|
87
|
+
- name: Test with pytest
|
|
88
|
+
run: |
|
|
89
|
+
pip install pytest
|
|
90
|
+
pytest
|
|
91
|
+
|
|
92
|
+
- name: Set up SSH
|
|
93
|
+
run: |
|
|
94
|
+
mkdir -p ~/.ssh
|
|
95
|
+
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/deploy_key
|
|
96
|
+
chmod 600 ~/.ssh/deploy_key
|
|
97
|
+
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
|
|
98
|
+
|
|
99
|
+
- name: Validate SSH Connection
|
|
100
|
+
run: |
|
|
101
|
+
echo "✅ Testing SSH connection..."
|
|
102
|
+
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \
|
|
103
|
+
${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "echo 'Connected'" || {
|
|
104
|
+
echo "❌ SSH failed! Check docs/ssh-key-setup.md"
|
|
105
|
+
exit 1
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- name: Copy docker-compose to EC2
|
|
109
|
+
run: |
|
|
110
|
+
ssh -i ~/.ssh/deploy_key ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} \
|
|
111
|
+
'mkdir -p ~/app'
|
|
112
|
+
|
|
113
|
+
scp -i ~/.ssh/deploy_key docker-compose.yml \
|
|
114
|
+
${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:~/app/
|
|
115
|
+
|
|
116
|
+
# Copy any .env files if they exist
|
|
117
|
+
if [ -f .env.production ]; then
|
|
118
|
+
scp -i ~/.ssh/deploy_key .env.production \
|
|
119
|
+
${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:~/app/.env
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
- name: Create backup
|
|
123
|
+
run: |
|
|
124
|
+
ssh -i ~/.ssh/deploy_key ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
|
|
125
|
+
mkdir -p ~/backups
|
|
126
|
+
if [ -d ~/app ]; then
|
|
127
|
+
tar -czf ~/backups/backup-$(date +%Y%m%d-%H%M%S).tar.gz -C ~/app . 2>/dev/null || true
|
|
128
|
+
echo "✅ Backup created"
|
|
129
|
+
fi
|
|
130
|
+
EOF
|
|
131
|
+
|
|
132
|
+
- name: Dry-run
|
|
133
|
+
run: |
|
|
134
|
+
echo "🔍 DRY-RUN: Previewing deployment"
|
|
135
|
+
ssh -i ~/.ssh/deploy_key ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
|
|
136
|
+
cd ~/app && docker-compose config
|
|
137
|
+
EOF
|
|
138
|
+
|
|
139
|
+
- name: Deploy with vm_tool (Ansible-based)
|
|
140
|
+
run: |
|
|
141
|
+
# Create inventory file for Ansible
|
|
142
|
+
cat > inventory.yml << EOF
|
|
143
|
+
all:
|
|
144
|
+
hosts:
|
|
145
|
+
production:
|
|
146
|
+
ansible_host: ${{ secrets.EC2_HOST }}
|
|
147
|
+
ansible_user: ${{ secrets.EC2_USER }}
|
|
148
|
+
ansible_ssh_private_key_file: ~/.ssh/deploy_key
|
|
149
|
+
EOF
|
|
150
|
+
|
|
151
|
+
# Deploy using vm_tool (uses Ansible under the hood)
|
|
152
|
+
vm_tool deploy-docker \
|
|
153
|
+
--host ${{ secrets.EC2_HOST }} \
|
|
154
|
+
--user ${{ secrets.EC2_USER }} \
|
|
155
|
+
--compose-file ~/app/docker-compose.yml \
|
|
156
|
+
--inventory inventory.yml \
|
|
157
|
+
--force
|
|
158
|
+
|
|
159
|
+
- name: Health check
|
|
160
|
+
run: |
|
|
161
|
+
for i in {{1..30}}; do
|
|
162
|
+
if curl -f http://${{ secrets.EC2_HOST }}:8000/health 2>/dev/null; then
|
|
163
|
+
echo "✅ Health check passed"
|
|
164
|
+
exit 0
|
|
165
|
+
fi
|
|
166
|
+
sleep 2
|
|
167
|
+
done
|
|
168
|
+
echo "❌ Health check failed"
|
|
169
|
+
exit 1
|
|
170
|
+
|
|
171
|
+
- name: Verify
|
|
172
|
+
run: |
|
|
173
|
+
ssh -i ~/.ssh/deploy_key ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
|
|
174
|
+
cd ~/app
|
|
175
|
+
docker-compose ps
|
|
176
|
+
docker-compose logs --tail=20
|
|
177
|
+
EOF
|
|
178
|
+
|
|
179
|
+
- name: Rollback on failure
|
|
180
|
+
if: failure()
|
|
181
|
+
run: |
|
|
182
|
+
echo "⚠️ Rolling back..."
|
|
183
|
+
ssh -i ~/.ssh/deploy_key ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
|
|
184
|
+
BACKUP=$(ls -t ~/backups/*.tar.gz 2>/dev/null | head -1)
|
|
185
|
+
if [ -n "$BACKUP" ]; then
|
|
186
|
+
cd ~/app && tar -xzf $BACKUP
|
|
187
|
+
docker-compose up -d
|
|
188
|
+
echo "✅ Rolled back"
|
|
189
|
+
fi
|
|
190
|
+
EOF
|
|
191
|
+
|
|
192
|
+
- name: Cleanup
|
|
193
|
+
if: success()
|
|
194
|
+
run: |
|
|
195
|
+
ssh -i ~/.ssh/deploy_key ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
|
|
196
|
+
cd ~/backups 2>/dev/null || exit 0
|
|
197
|
+
ls -t *.tar.gz 2>/dev/null | tail -n +6 | xargs rm -f || true
|
|
198
|
+
EOF
|
|
199
|
+
|
|
200
|
+
- name: Notify
|
|
201
|
+
if: always()
|
|
202
|
+
run: |
|
|
203
|
+
if [ "${{ job.status }}" == "success" ]; then
|
|
204
|
+
echo "✅ Deployed to ${{ secrets.EC2_HOST }}:${{ env.APP_PORT }}"
|
|
205
|
+
else
|
|
206
|
+
echo "❌ Deployment failed"
|
|
207
|
+
fi
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
push:
|
|
7
|
+
tags:
|
|
8
|
+
- "v*"
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build-n-publish:
|
|
12
|
+
name: Build and publish to PyPI
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment:
|
|
15
|
+
name: pypi
|
|
16
|
+
url: https://pypi.org/p/vm-tool
|
|
17
|
+
permissions:
|
|
18
|
+
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v6
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@v6
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.x"
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: |
|
|
30
|
+
python -m pip install --upgrade pip
|
|
31
|
+
pip install build
|
|
32
|
+
|
|
33
|
+
- name: Build package
|
|
34
|
+
run: python -m build
|
|
35
|
+
|
|
36
|
+
- name: Publish to PyPI
|
|
37
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Project-specific files
|
|
2
|
+
project/
|
|
3
|
+
|
|
4
|
+
# Virtual environments
|
|
5
|
+
venv/
|
|
6
|
+
.env/
|
|
7
|
+
|
|
8
|
+
# Distribution / packaging
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
*.egg-info/
|
|
12
|
+
|
|
13
|
+
# Python-specific files
|
|
14
|
+
__pycache__/
|
|
15
|
+
*.py[cod]
|
|
16
|
+
*.pyo
|
|
17
|
+
*.pyd
|
|
18
|
+
|
|
19
|
+
# Jupyter Notebook checkpoints
|
|
20
|
+
.ipynb_checkpoints/
|
|
21
|
+
|
|
22
|
+
# Logs
|
|
23
|
+
*.log
|
|
24
|
+
|
|
25
|
+
# OS-specific files
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
|
|
29
|
+
# IDE-specific files
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
*.sublime-project
|
|
33
|
+
*.sublime-workspace
|
|
34
|
+
|
|
35
|
+
dynamic_inventory.yml
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v4.5.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-added-large-files
|
|
9
|
+
|
|
10
|
+
- repo: https://github.com/pycqa/flake8
|
|
11
|
+
rev: 7.0.0
|
|
12
|
+
hooks:
|
|
13
|
+
- id: flake8
|
|
14
|
+
args: [--max-line-length=127]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
## Initial Setup of the Application
|
|
2
|
+
|
|
3
|
+
1. **Connect to the deployment machine using VSCode.**
|
|
4
|
+
- Open VSCode.
|
|
5
|
+
- Use the SSH extension to connect to your deployment machine.
|
|
6
|
+
|
|
7
|
+
2. **Install the package and its dependencies:**
|
|
8
|
+
```bash
|
|
9
|
+
pip install .
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
3. **Raise a Pull Request (PR):**
|
|
13
|
+
- Ensure the issue you are addressing is resolved.
|
|
14
|
+
- Write a clear and concise description of the changes made in the PR.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Contributing Guidelines
|
|
19
|
+
|
|
20
|
+
We welcome contributions to improve this tool! Here are the steps to contribute:
|
|
21
|
+
|
|
22
|
+
1. **Fork the repository:**
|
|
23
|
+
- Navigate to the repository and click the "Fork" button.
|
|
24
|
+
|
|
25
|
+
2. **Clone your fork:**
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/thesunnysinha/vm_tool.git
|
|
28
|
+
cd vm-tool
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
3. **Create a new branch:**
|
|
32
|
+
```bash
|
|
33
|
+
git checkout -b feature/your-feature-name
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
4. **Make changes:**
|
|
37
|
+
- Ensure your code follows best practices.
|
|
38
|
+
- Test your changes locally before committing.
|
|
39
|
+
|
|
40
|
+
5. **Commit and push your changes:**
|
|
41
|
+
```bash
|
|
42
|
+
git add .
|
|
43
|
+
git commit -m "Add description of changes"
|
|
44
|
+
git push origin feature/your-feature-name
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
6. **Submit a PR:**
|
|
48
|
+
- Go to the original repository and click "New Pull Request."
|
|
49
|
+
- Provide a detailed description of your changes, including the issue it resolves.
|
|
50
|
+
|
|
51
|
+
7. **Review process:**
|
|
52
|
+
- Wait for maintainers to review your PR.
|
|
53
|
+
- Address any feedback promptly.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
Thank you for contributing to the VM Setup Tool!
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing to VM Tool
|
|
2
|
+
|
|
3
|
+
## Code Organization
|
|
4
|
+
|
|
5
|
+
VM Tool follows a modular architecture with clear separation of concerns:
|
|
6
|
+
|
|
7
|
+
- `vm_tool/core/` - Core infrastructure (config, state, history)
|
|
8
|
+
- `vm_tool/strategies/` - Deployment strategies (blue-green, canary, A/B)
|
|
9
|
+
- `vm_tool/operations/` - Operations (metrics, alerting, reporting)
|
|
10
|
+
- `vm_tool/enterprise/` - Enterprise features (RBAC, audit, policy)
|
|
11
|
+
- `vm_tool/integrations/` - External integrations (webhooks, notifications)
|
|
12
|
+
|
|
13
|
+
## Adding Features
|
|
14
|
+
|
|
15
|
+
1. Determine the appropriate module directory
|
|
16
|
+
2. Create module with clear, focused responsibility
|
|
17
|
+
3. Add comprehensive tests
|
|
18
|
+
4. Update documentation
|
|
19
|
+
5. Submit pull request
|
|
20
|
+
|
|
21
|
+
See `docs/code_organization.md` for detailed guidelines.
|
|
22
|
+
|
|
23
|
+
## Testing
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Run all tests
|
|
27
|
+
pytest -v
|
|
28
|
+
|
|
29
|
+
# Run specific module tests
|
|
30
|
+
pytest tests/unit/test_<module>.py -v
|
|
31
|
+
|
|
32
|
+
# Run integration tests
|
|
33
|
+
pytest tests/integration/ -v
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
- Update API docs in `docs/api/`
|
|
39
|
+
- Add usage examples in `docs/guides/`
|
|
40
|
+
- Update `CHANGELOG.md`
|
vm_tool-1.0.32/Makefile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.PHONY: clean build upload install version-control
|
|
2
|
+
|
|
3
|
+
# Clean up previous builds
|
|
4
|
+
clean:
|
|
5
|
+
rm -rf dist
|
|
6
|
+
|
|
7
|
+
# Build the source distribution
|
|
8
|
+
build: clean
|
|
9
|
+
mkdir -p dist
|
|
10
|
+
python setup.py sdist
|
|
11
|
+
|
|
12
|
+
# Upload the distribution to PyPI
|
|
13
|
+
upload: build
|
|
14
|
+
pip install --upgrade twine
|
|
15
|
+
twine upload dist/* --verbose
|
|
16
|
+
|
|
17
|
+
# Install dependencies
|
|
18
|
+
install:
|
|
19
|
+
pip install -r requirements.txt
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vm_tool
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.32
|
|
4
4
|
Summary: A Comprehensive Tool for Setting Up Virtual Machines.
|
|
5
5
|
Home-page: https://github.com/thesunnysinha/vm_tool
|
|
6
6
|
Author: Sunny Sinha
|
|
7
|
-
Author-email: thesunnysinha@gmail.com
|
|
7
|
+
Author-email: Sunny Sinha <thesunnysinha@gmail.com>
|
|
8
8
|
License: MIT
|
|
9
|
-
Project-URL: Documentation, https://
|
|
9
|
+
Project-URL: Documentation, https://vm-tool.sunnysinha.online/
|
|
10
10
|
Project-URL: Source, https://github.com/thesunnysinha/vm_tool
|
|
11
11
|
Project-URL: Tracker, https://github.com/thesunnysinha/vm_tool/issues
|
|
12
|
-
Keywords: virtual machine setup ansible automation
|
|
13
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
14
13
|
Classifier: Intended Audience :: Developers
|
|
15
14
|
Classifier: Intended Audience :: System Administrators
|
|
@@ -21,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
22
21
|
Classifier: Topic :: Software Development :: Build Tools
|
|
23
22
|
Classifier: Topic :: System :: Systems Administration
|
|
24
|
-
Requires-Python: >=3.
|
|
23
|
+
Requires-Python: >=3.9
|
|
25
24
|
Description-Content-Type: text/markdown
|
|
26
25
|
License-File: LICENSE
|
|
27
26
|
Requires-Dist: ansible
|
|
@@ -30,37 +29,40 @@ Requires-Dist: paramiko
|
|
|
30
29
|
Requires-Dist: pydantic
|
|
31
30
|
Requires-Dist: pyyaml
|
|
32
31
|
Provides-Extra: dev
|
|
33
|
-
Requires-Dist: pytest; extra == "dev"
|
|
34
|
-
Requires-Dist:
|
|
35
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: check-manifest; extra == "dev"
|
|
34
|
+
Requires-Dist: twine; extra == "dev"
|
|
35
|
+
Requires-Dist: wheel; extra == "dev"
|
|
36
|
+
Requires-Dist: bump-my-version; extra == "dev"
|
|
37
|
+
Requires-Dist: bandit; extra == "dev"
|
|
38
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
39
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
40
|
+
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
41
|
+
Requires-Dist: black; extra == "dev"
|
|
42
|
+
Requires-Dist: isort; extra == "dev"
|
|
36
43
|
Dynamic: author
|
|
37
|
-
Dynamic: author-email
|
|
38
|
-
Dynamic: classifier
|
|
39
|
-
Dynamic: description
|
|
40
|
-
Dynamic: description-content-type
|
|
41
44
|
Dynamic: home-page
|
|
42
|
-
Dynamic: keywords
|
|
43
|
-
Dynamic: license
|
|
44
45
|
Dynamic: license-file
|
|
45
|
-
Dynamic: project-url
|
|
46
|
-
Dynamic: provides-extra
|
|
47
|
-
Dynamic: requires-dist
|
|
48
46
|
Dynamic: requires-python
|
|
49
|
-
Dynamic: summary
|
|
50
47
|
|
|
51
48
|
# 🚀 VM Setup Tool
|
|
52
49
|
|
|
53
50
|
[](https://pypi.org/project/vm-tool/) [](https://pypi.org/project/vm-tool/)
|
|
54
51
|
|
|
55
|
-
[**PyPI**](https://pypi.org/project/vm-tool/) • [**GitHub**](https://github.com/thesunnysinha/vm_tool) • [**Contributing**](CONTRIBUTING) • [**License**](LICENSE)
|
|
52
|
+
[**Documentation**](https://vm-tool.sunnysinha.online/) • [**PyPI**](https://pypi.org/project/vm-tool/) • [**GitHub**](https://github.com/thesunnysinha/vm_tool) • [**Contributing**](CONTRIBUTING) • [**License**](LICENSE)
|
|
56
53
|
|
|
57
54
|
A modern, user-friendly solution for automating and managing virtual machine (VM) setup and configuration using Ansible.
|
|
58
55
|
|
|
59
56
|
---
|
|
60
57
|
|
|
61
58
|
## ✨ Features
|
|
59
|
+
|
|
62
60
|
- Automated VM setup with Docker & Docker Compose
|
|
63
61
|
- Cloud VM provisioning via SSH
|
|
62
|
+
- **Infrastructure Provisioning**: Terraform integration for cloud providers (AWS, etc.)
|
|
63
|
+
- **Kubernetes Ready**: One-click K3s cluster setup
|
|
64
|
+
- **Observability**: Instant Prometheus & Grafana deployment
|
|
65
|
+
- **CI/CD Pipelines**: Auto-generate GitHub Actions workflows
|
|
64
66
|
- SSH key management and configuration
|
|
65
67
|
- Simple Python API for integration
|
|
66
68
|
- One-command version check: `vm_tool --version`
|
|
@@ -68,6 +70,7 @@ A modern, user-friendly solution for automating and managing virtual machine (VM
|
|
|
68
70
|
---
|
|
69
71
|
|
|
70
72
|
## ⚡️ Installation
|
|
73
|
+
|
|
71
74
|
Install the latest version from PyPI:
|
|
72
75
|
|
|
73
76
|
```bash
|
|
@@ -78,7 +81,44 @@ pip install vm-tool
|
|
|
78
81
|
|
|
79
82
|
## 🛠️ Usage Examples
|
|
80
83
|
|
|
81
|
-
###
|
|
84
|
+
### 🚀 Universal Deployment (CLI)
|
|
85
|
+
|
|
86
|
+
#### 1. Generate CI/CD Pipeline
|
|
87
|
+
|
|
88
|
+
Bootstrap your project with a complete GitHub Actions workflow:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
vm_tool generate-pipeline
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### 2. Provision Infrastructure
|
|
95
|
+
|
|
96
|
+
Provision cloud resources using Terraform (requires Terraform installed):
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
vm_tool provision --provider aws --action apply --vars region=us-east-1
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 3. Setup Kubernetes (K3s)
|
|
103
|
+
|
|
104
|
+
Deploy a lightweight Kubernetes cluster to your servers:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
vm_tool setup-k8s --inventory inventory.yml
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### 4. Setup Observability
|
|
111
|
+
|
|
112
|
+
Deploy Prometheus and Grafana for instant monitoring:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
vm_tool setup-monitoring --inventory inventory.yml
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 🐍 Python API Usage
|
|
119
|
+
|
|
120
|
+
#### Automated Local VM Setup
|
|
121
|
+
|
|
82
122
|
```python
|
|
83
123
|
from vm_tool.runner import SetupRunner, SetupRunnerConfig
|
|
84
124
|
|
|
@@ -97,6 +137,7 @@ runner.run_setup()
|
|
|
97
137
|
```
|
|
98
138
|
|
|
99
139
|
### Cloud VM Setup (via SSH)
|
|
140
|
+
|
|
100
141
|
```python
|
|
101
142
|
from vm_tool.runner import SetupRunner, SetupRunnerConfig, SSHConfig
|
|
102
143
|
|
|
@@ -125,6 +166,7 @@ runner.run_cloud_setup(ssh_configs)
|
|
|
125
166
|
```
|
|
126
167
|
|
|
127
168
|
### SSH Key Management
|
|
169
|
+
|
|
128
170
|
```python
|
|
129
171
|
from vm_tool.ssh import SSHSetup
|
|
130
172
|
|
|
@@ -151,6 +193,7 @@ vm_tool --version
|
|
|
151
193
|
---
|
|
152
194
|
|
|
153
195
|
## ⚙️ Configuration Options
|
|
196
|
+
|
|
154
197
|
- `github_username`: GitHub username (for private repos)
|
|
155
198
|
- `github_token`: GitHub token (for private repos)
|
|
156
199
|
- `github_project_url`: GitHub repository URL
|
|
@@ -162,7 +205,8 @@ vm_tool --version
|
|
|
162
205
|
---
|
|
163
206
|
|
|
164
207
|
## 📚 Learn More
|
|
165
|
-
|
|
208
|
+
|
|
209
|
+
See the [Official Documentation](https://vm-tool.sunnysinha.online/) for complete guides. Visit the [PyPI page](https://pypi.org/project/vm-tool/) for generic details, or the [GitHub repository](https://github.com/thesunnysinha/vm_tool) for code and issues.
|
|
166
210
|
|
|
167
211
|
---
|
|
168
212
|
|