vm-tool 1.0.4__tar.gz → 1.0.40__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.40/.devcontainer/devcontainer.json +18 -0
- vm_tool-1.0.40/.github/dependabot.yml +19 -0
- vm_tool-1.0.40/.github/workflows/ci.yml +57 -0
- vm_tool-1.0.40/.github/workflows/deploy.yml +207 -0
- vm_tool-1.0.40/.github/workflows/publish.yml +37 -0
- vm_tool-1.0.40/.gitignore +35 -0
- vm_tool-1.0.40/.pre-commit-config.yaml +14 -0
- vm_tool-1.0.40/CONTRIBUTING +57 -0
- vm_tool-1.0.40/CONTRIBUTING.md +40 -0
- vm_tool-1.0.40/MANIFEST.in +1 -0
- vm_tool-1.0.40/Makefile +19 -0
- vm_tool-1.0.40/PKG-INFO +213 -0
- vm_tool-1.0.40/README.md +166 -0
- vm_tool-1.0.40/codePushToGithub.py +209 -0
- vm_tool-1.0.40/docs/MODULE_GUIDE.md +42 -0
- vm_tool-1.0.40/docs/deployment-approaches.md +117 -0
- vm_tool-1.0.40/docs/ec2-github-actions-guide.md +519 -0
- vm_tool-1.0.40/docs/features.md +104 -0
- vm_tool-1.0.40/docs/generator.md +283 -0
- vm_tool-1.0.40/docs/index.md +114 -0
- vm_tool-1.0.40/docs/pipeline-generator.md +234 -0
- vm_tool-1.0.40/docs/reference/runner.md +3 -0
- vm_tool-1.0.40/docs/reference/ssh.md +3 -0
- vm_tool-1.0.40/docs/ssh-key-setup.md +211 -0
- vm_tool-1.0.40/docs/usage.md +468 -0
- vm_tool-1.0.40/examples/README.md +5 -0
- vm_tool-1.0.40/examples/__init__.py +1 -0
- vm_tool-1.0.40/examples/cloud/README.md +3 -0
- vm_tool-1.0.40/examples/cloud/__init__.py +1 -0
- vm_tool-1.0.40/examples/cloud/ssh_identity_file.py +27 -0
- vm_tool-1.0.40/examples/cloud/ssh_password.py +27 -0
- vm_tool-1.0.40/examples/cloud/template_cloud_setup.py +36 -0
- vm_tool-1.0.40/examples/deploy_full_setup.py +44 -0
- vm_tool-1.0.40/examples/docker-compose.example.yml +47 -0
- vm_tool-1.0.40/examples/ec2-setup.sh +95 -0
- vm_tool-1.0.40/examples/github-actions-ec2.yml +245 -0
- vm_tool-1.0.40/examples/github-actions-full-setup.yml +58 -0
- vm_tool-1.0.40/examples/local/.keep +1 -0
- vm_tool-1.0.40/examples/local/README.md +3 -0
- vm_tool-1.0.40/examples/local/__init__.py +1 -0
- vm_tool-1.0.40/examples/local/template_local_setup.py +27 -0
- vm_tool-1.0.40/examples/production-deploy.sh +70 -0
- vm_tool-1.0.40/examples/rollback.sh +52 -0
- vm_tool-1.0.40/examples/setup.sh +52 -0
- vm_tool-1.0.40/examples/ssh_key_management.py +22 -0
- vm_tool-1.0.40/examples/version_check.sh +3 -0
- vm_tool-1.0.40/mkdocs.yml +26 -0
- vm_tool-1.0.40/molecule/default/converge.yml +7 -0
- vm_tool-1.0.40/molecule/default/molecule.yml +17 -0
- vm_tool-1.0.40/molecule/default/verify.yml +7 -0
- vm_tool-1.0.40/pyproject.toml +96 -0
- vm_tool-1.0.40/requirements-docs.txt +2 -0
- vm_tool-1.0.40/requirements.txt +88 -0
- vm_tool-1.0.40/runtime.txt +1 -0
- vm_tool-1.0.40/setup.py +66 -0
- vm_tool-1.0.40/tests/conftest.py +29 -0
- vm_tool-1.0.40/tests/integration/test_deployment.py +99 -0
- vm_tool-1.0.40/tests/test_config.py +119 -0
- vm_tool-1.0.40/tests/test_generator.py +85 -0
- vm_tool-1.0.40/tests/test_health.py +148 -0
- vm_tool-1.0.40/tests/test_history.py +187 -0
- vm_tool-1.0.40/tests/test_logging.py +72 -0
- vm_tool-1.0.40/tests/test_runner.py +51 -0
- vm_tool-1.0.40/tests/test_ssh.py +54 -0
- vm_tool-1.0.40/tests/test_state.py +143 -0
- vm_tool-1.0.40/vm_tool/alerting.py +274 -0
- vm_tool-1.0.40/vm_tool/audit.py +118 -0
- vm_tool-1.0.40/vm_tool/backup.py +125 -0
- vm_tool-1.0.40/vm_tool/benchmarking.py +200 -0
- vm_tool-1.0.40/vm_tool/cli.py +768 -0
- vm_tool-1.0.40/vm_tool/cloud.py +125 -0
- vm_tool-1.0.40/vm_tool/completion.py +200 -0
- vm_tool-1.0.40/vm_tool/compliance.py +104 -0
- vm_tool-1.0.40/vm_tool/config.py +92 -0
- vm_tool-1.0.40/vm_tool/drift.py +98 -0
- vm_tool-1.0.40/vm_tool/generator.py +462 -0
- vm_tool-1.0.40/vm_tool/health.py +197 -0
- vm_tool-1.0.40/vm_tool/history.py +131 -0
- vm_tool-1.0.40/vm_tool/kubernetes.py +89 -0
- vm_tool-1.0.40/vm_tool/metrics.py +183 -0
- vm_tool-1.0.40/vm_tool/notifications.py +152 -0
- vm_tool-1.0.40/vm_tool/plugins.py +119 -0
- vm_tool-1.0.40/vm_tool/policy.py +197 -0
- vm_tool-1.0.40/vm_tool/rbac.py +140 -0
- vm_tool-1.0.40/vm_tool/recovery.py +169 -0
- vm_tool-1.0.40/vm_tool/reporting.py +218 -0
- vm_tool-1.0.40/vm_tool/runner.py +450 -0
- vm_tool-1.0.40/vm_tool/secrets.py +285 -0
- vm_tool-1.0.40/vm_tool/ssh.py +150 -0
- vm_tool-1.0.40/vm_tool/state.py +122 -0
- vm_tool-1.0.40/vm_tool/strategies/__init__.py +16 -0
- vm_tool-1.0.40/vm_tool/strategies/ab_testing.py +258 -0
- vm_tool-1.0.40/vm_tool/strategies/blue_green.py +227 -0
- vm_tool-1.0.40/vm_tool/strategies/canary.py +277 -0
- vm_tool-1.0.40/vm_tool/validation.py +267 -0
- vm_tool-1.0.40/vm_tool/vm_setup/cleanup.yml +27 -0
- vm_tool-1.0.40/vm_tool/vm_setup/docker/create_docker_service.yml +63 -0
- vm_tool-1.0.40/vm_tool/vm_setup/docker/docker_setup.yml +7 -0
- vm_tool-1.0.40/vm_tool/vm_setup/docker/install_docker_and_compose.yml +92 -0
- vm_tool-1.0.40/vm_tool/vm_setup/docker/login_to_docker_hub.yml +6 -0
- vm_tool-1.0.40/vm_tool/vm_setup/github/git_configuration.yml +68 -0
- vm_tool-1.0.40/vm_tool/vm_setup/inventory.yml +1 -0
- vm_tool-1.0.40/vm_tool/vm_setup/k8s.yml +15 -0
- vm_tool-1.0.40/vm_tool/vm_setup/main.yml +27 -0
- vm_tool-1.0.40/vm_tool/vm_setup/monitoring.yml +42 -0
- vm_tool-1.0.40/vm_tool/vm_setup/project_service.yml +17 -0
- vm_tool-1.0.40/vm_tool/vm_setup/push_code.yml +5 -0
- vm_tool-1.0.40/vm_tool/vm_setup/push_code_tasks.yml +45 -0
- vm_tool-1.0.40/vm_tool/vm_setup/setup.yml +17 -0
- vm_tool-1.0.40/vm_tool/vm_setup/setup_project_env.yml +7 -0
- vm_tool-1.0.40/vm_tool/webhooks.py +83 -0
- vm_tool-1.0.40/vm_tool.egg-info/PKG-INFO +213 -0
- vm_tool-1.0.40/vm_tool.egg-info/SOURCES.txt +118 -0
- vm_tool-1.0.40/vm_tool.egg-info/requires.txt +18 -0
- vm_tool-1.0.40/vm_tool.egg-info/top_level.txt +2 -0
- vm_tool-1.0.4/PKG-INFO +0 -97
- vm_tool-1.0.4/setup.py +0 -26
- vm_tool-1.0.4/vm_tool/cli.py +0 -14
- vm_tool-1.0.4/vm_tool/runner.py +0 -46
- vm_tool-1.0.4/vm_tool/ssh.py +0 -53
- vm_tool-1.0.4/vm_tool.egg-info/PKG-INFO +0 -97
- vm_tool-1.0.4/vm_tool.egg-info/SOURCES.txt +0 -12
- vm_tool-1.0.4/vm_tool.egg-info/requires.txt +0 -3
- vm_tool-1.0.4/vm_tool.egg-info/top_level.txt +0 -1
- {vm_tool-1.0.4 → vm_tool-1.0.40}/LICENSE +0 -0
- {vm_tool-1.0.4 → vm_tool-1.0.40}/setup.cfg +0 -0
- {vm_tool-1.0.4 → vm_tool-1.0.40}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0.4 → vm_tool-1.0.40}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0.4 → vm_tool-1.0.40}/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`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include vm_tool/vm_setup *
|
vm_tool-1.0.40/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
|