runbooks 0.1.1__py3-none-any.whl
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.
- cloudops/__init__.py +10 -0
- cloudops/toolkit.py +147 -0
- runbooks-0.1.1.dist-info/METADATA +181 -0
- runbooks-0.1.1.dist-info/RECORD +6 -0
- runbooks-0.1.1.dist-info/WHEEL +5 -0
- runbooks-0.1.1.dist-info/top_level.txt +1 -0
cloudops/__init__.py
ADDED
cloudops/toolkit.py
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
from typing import Tuple, Union
|
2
|
+
|
3
|
+
from loguru import logger
|
4
|
+
|
5
|
+
## Define a type alias for supported numeric types
|
6
|
+
Number = Union[float, int]
|
7
|
+
|
8
|
+
|
9
|
+
def add(a: Number, b: Number) -> float:
|
10
|
+
"""Compute and return the sum of two numbers.
|
11
|
+
|
12
|
+
Examples:
|
13
|
+
>>> add(4.0, 2.0)
|
14
|
+
6.0
|
15
|
+
>>> add(4, 2)
|
16
|
+
6.0
|
17
|
+
|
18
|
+
Args:
|
19
|
+
a: The first number in the addition.
|
20
|
+
b: The second number in the addition.
|
21
|
+
|
22
|
+
Returns:
|
23
|
+
float: The arithmetic sum of `a` and `b`.
|
24
|
+
|
25
|
+
Raises:
|
26
|
+
TypeError: If inputs are not numbers.
|
27
|
+
"""
|
28
|
+
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
|
29
|
+
raise TypeError("Both inputs must be integers or floats.")
|
30
|
+
|
31
|
+
logger.debug(f"Adding {a} + {b}")
|
32
|
+
return float(a + b)
|
33
|
+
|
34
|
+
|
35
|
+
def subtract(a: Number, b: Number) -> float:
|
36
|
+
"""Compute and return the subtraction of two numbers.
|
37
|
+
|
38
|
+
Examples:
|
39
|
+
>>> subtract(4.0, 2.0)
|
40
|
+
2.0
|
41
|
+
>>> subtract(4, 2)
|
42
|
+
2.0
|
43
|
+
|
44
|
+
Args:
|
45
|
+
a: The first number in the subtraction.
|
46
|
+
b: The second number in the subtraction.
|
47
|
+
|
48
|
+
Returns:
|
49
|
+
float: The arithmetic subtraction of `a` and `b`.
|
50
|
+
|
51
|
+
Raises:
|
52
|
+
TypeError: If inputs are not numbers.
|
53
|
+
"""
|
54
|
+
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
|
55
|
+
raise TypeError("Both inputs must be integers or floats.")
|
56
|
+
|
57
|
+
logger.debug(f"Subtracting {a} - {b}")
|
58
|
+
return float(a - b)
|
59
|
+
|
60
|
+
|
61
|
+
def multiply(a: Number, b: Number) -> float:
|
62
|
+
"""Compute and return the multiplication of two numbers.
|
63
|
+
|
64
|
+
Examples:
|
65
|
+
>>> multiply(4.0, 2.0)
|
66
|
+
8.0
|
67
|
+
>>> multiply(4, 2)
|
68
|
+
8.0
|
69
|
+
|
70
|
+
Args:
|
71
|
+
a: The first number in the multiplication.
|
72
|
+
b: The second number in the multiplication.
|
73
|
+
|
74
|
+
Returns:
|
75
|
+
float: The arithmetic multiplication of `a` and `b`.
|
76
|
+
|
77
|
+
Raises:
|
78
|
+
TypeError: If inputs are not numbers.
|
79
|
+
"""
|
80
|
+
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
|
81
|
+
raise TypeError("Both inputs must be integers or floats.")
|
82
|
+
|
83
|
+
logger.debug(f"Multiplying {a} * {b}")
|
84
|
+
return float(a * b)
|
85
|
+
|
86
|
+
|
87
|
+
def divide(a: Number, b: Number) -> float:
|
88
|
+
"""Compute and return the division of two numbers.
|
89
|
+
|
90
|
+
Examples:
|
91
|
+
>>> divide(4.0, 2.0)
|
92
|
+
2.0
|
93
|
+
>>> divide(4, 2)
|
94
|
+
2.0
|
95
|
+
|
96
|
+
Args:
|
97
|
+
a: The numerator.
|
98
|
+
b: The denominator.
|
99
|
+
|
100
|
+
Returns:
|
101
|
+
float: The result of dividing `a` by `b`.
|
102
|
+
|
103
|
+
Raises:
|
104
|
+
TypeError: If inputs are not numbers.
|
105
|
+
ZeroDivisionError: If the denominator is zero.
|
106
|
+
"""
|
107
|
+
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
|
108
|
+
raise TypeError("Both inputs must be integers or floats.")
|
109
|
+
if b == 0:
|
110
|
+
logger.error("Attempted division by zero.")
|
111
|
+
raise ZeroDivisionError("division by zero")
|
112
|
+
|
113
|
+
logger.debug(f"Dividing {a} / {b}")
|
114
|
+
return float(a / b)
|
115
|
+
|
116
|
+
|
117
|
+
def divide(a: Number, b: Number) -> float:
|
118
|
+
"""Compute and return the division of two numbers.
|
119
|
+
|
120
|
+
Examples:
|
121
|
+
>>> divide(4.0, 2.0)
|
122
|
+
2.0
|
123
|
+
>>> divide(4, 2)
|
124
|
+
2.0
|
125
|
+
|
126
|
+
Args:
|
127
|
+
a: The numerator.
|
128
|
+
b: The denominator.
|
129
|
+
|
130
|
+
Returns:
|
131
|
+
float: The result of dividing `a` by `b`.
|
132
|
+
|
133
|
+
Raises:
|
134
|
+
TypeError: If inputs are not numbers.
|
135
|
+
ZeroDivisionError: If the denominator is zero.
|
136
|
+
"""
|
137
|
+
# Input validation
|
138
|
+
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
|
139
|
+
raise TypeError("Both inputs must be integers or floats.")
|
140
|
+
|
141
|
+
# Handle division by zero
|
142
|
+
if b == 0:
|
143
|
+
raise ZeroDivisionError("division by zero")
|
144
|
+
|
145
|
+
# Perform division
|
146
|
+
logger.debug(f"Dividing {a} / {b}")
|
147
|
+
return float(a / b)
|
@@ -0,0 +1,181 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: runbooks
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: CloudOps Automation for DevOps and SRE teams.
|
5
|
+
Author-email: runbooks maintainers <nnthanh101@gmail.com>
|
6
|
+
Classifier: Development Status :: 4 - Beta
|
7
|
+
Classifier: Environment :: Console
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
13
|
+
Classifier: Topic :: Documentation
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
+
Classifier: Topic :: Utilities
|
16
|
+
Requires-Python: >=3.11
|
17
|
+
Description-Content-Type: text/markdown
|
18
|
+
Requires-Dist: requests>=2.32.3
|
19
|
+
Requires-Dist: loguru>=0.7.3
|
20
|
+
Requires-Dist: typer>=0.15.1
|
21
|
+
Requires-Dist: tqdm>=4.67.1
|
22
|
+
Requires-Dist: boto3>=1.35.90
|
23
|
+
Requires-Dist: moto>=5.0.25
|
24
|
+
|
25
|
+
# ๐ฅ CloudOps Automation at Scale ๐ฆ
|
26
|
+
|
27
|
+
๐ You can use [CloudOps Automation Runbooks](https://cloudops.oceansoft.io), built on Jupyter Notebooks, to quickly create SRE RunBooks for Runbook Automation and Cloud Infrastructure Management! ๐
|
28
|
+
|
29
|
+
> [!IMPORTANT]
|
30
|
+
> **๐ Mission**: Our mission is to simplify CloudOps Automation for DevOps and SRE teams by providing an extensive, community-driven repository of actions and runbooks that streamline day-to-day operations.
|
31
|
+
|
32
|
+
> [!NOTE]
|
33
|
+
> **๐๏ธ Vision**: Our vision is to be the ๐ฅ One-Stop Multi-Cloud Platform Engineering & Best Practices Solution for all CloudOps Automation needs, allowing DevOps and SRE teams to automate their workflows with ease, improve efficiency, and minimize toil.
|
34
|
+
|
35
|
+
[](https://pypi.org/project/cloudops/)
|
36
|
+
|
37
|
+
<div align="left">
|
38
|
+
<a href="https://www.linkedin.com/in/nnthanh" target="blank"><img align="center" src="https://img.shields.io/badge/-nnthanh-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/nnthanh/" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
|
39
|
+
<a href="https://github.com/nnthanh101/" target="blank"><img align="center" src="https://img.shields.io/github/followers/nnthanh101?label=Follow&style=social&link=https://github.com/nnthanh101/" alt="Thanh Nguyen" height="25" width="100" /></a>
|
40
|
+
<a href="https://www.facebook.com/groups/platformengineering" target="blank"><img align="center" src="https://img.shields.io/badge/Facebook-blue?style=flat-square&logo=facebook&logoColor=white&link=[https://www.linkedin.com/in/nnthanh/](https://www.facebook.com/groups/platformengineering)" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
## ๐ ๏ธ Features
|
46
|
+
|
47
|
+
* ๐ฅ โ
**Lightning-Fast Toolchain**: Powered by ๐ฆ `uv` - Next-generation Python dependency and build management, ๐
`ruff` - Linting and formatting at blazing speed, and ๐งช pytest - Robust testing framework with coverage reports.
|
48
|
+
* ๐ฅ โ
**Effortless CI/CD Pipelines**: ๐ ๏ธ Taskfile Automation - Say goodbye to manual SDLC repetitive tasks, ๐ณ Containerized Workflows โ ๐ก๏ธ Security-first practices and Multi-stage Wolfi-based Docker builds for scalable production-ready environments, and โ๏ธ Auto-publish to `PyPI` and GitHub Container Registry (`GHCR`) with GitHub Actions.
|
49
|
+
* ๐ฅ โ๏ธ**CloudOps Automation and FinOps Toolkit** โ Pre-configured hybrid-cloud workflows and seamlessly integrations (jupyterlab, mkdocs, boto3, moto) for managing cloud infrastructure ๐.
|
50
|
+
|
51
|
+
| **Feature** | **Toolchain** | **Purpose** |
|
52
|
+
|--------------------------|-------------------------------------|----------------------------------------------------|
|
53
|
+
| ๐ ๏ธ Configuration | `pyproject.toml` | Centralized configuration for dependencies, testing, and linting. |
|
54
|
+
| ๐งน Task Automation | [`Taskfile`](https://taskfile.dev/) | Automates repetitive tasks like linting, testing, and publishing. |
|
55
|
+
| ๐ฆ Python Dependencies | [`uv`](https://docs.astral.sh/uv/) | Lightning-fast dependency resolution, caching, and builds. |
|
56
|
+
| ๐
Linting & Formatting | [`ruff`](https://docs.astral.sh/ruff/) | Enforces code quality standards, auto-formatting, and import sorting. |
|
57
|
+
| ๐งช Testing Framework | [`pytest`](https://docs.pytest.org/) | Comprehensive unit tests, integration tests with coverage reporting. |
|
58
|
+
| ๐ณ Docker Integration | Dockerfile + [`DevContainer`](https://containers.dev/) | Optimized wolfi-based multi-stage builds for CI/CD and local development environments. |
|
59
|
+
| ๐ฆพ CI/CD Pipelines | [`GitHub Actions`](https://github.com/features/actions) | Automated builds, tests, and deployments to PyPI and GHCR. |
|
60
|
+
| ๐ Security Compliance | [`chainguard/wolfi-base`](https://hub.docker.com/r/chainguard/wolfi-base) + SBOM + Attestations | Ensures compliance, vulnerability scanning, and security transparency. |
|
61
|
+
|
62
|
+
---
|
63
|
+
|
64
|
+
### WIP
|
65
|
+
|
66
|
+
- [ ] ๐ auto doc generation
|
67
|
+
- [ ] **CLI Tools** โ Typer simplifies automation for AWS resources.
|
68
|
+
- [ ] **Logging** โ Loguru ensures structured logs for debugging.
|
69
|
+
- [x] ๐ณ CI/CD Optimized Docker Image runs when a new *release* is created pushing to gh registry
|
70
|
+
- [x] ๐ฆพ GitHub actions:
|
71
|
+
- [x] auto publish to [`pypi`](https://pypi.org/) on push on `main`
|
72
|
+
- [ ] auto creating a new tag on push on `main`, sync versions
|
73
|
+
- [x] run `tests` and `lint` on `dev` and `main` when a PR is open
|
74
|
+
|
75
|
+
## ๐ Quick Start
|
76
|
+
|
77
|
+
### 1. Clone the Repository
|
78
|
+
|
79
|
+
```bash
|
80
|
+
git clone https://github.com/nnthanh101/CloudOps.git
|
81
|
+
cd CloudOps
|
82
|
+
```
|
83
|
+
|
84
|
+
### 2. Install Dependencies and Run CI/CD Pipelines
|
85
|
+
|
86
|
+
```bash
|
87
|
+
echo "Install Python dependencies using UV"
|
88
|
+
task install
|
89
|
+
|
90
|
+
echo "Run CI/CD pipeline tasks: clean, lint, format, test, and build"
|
91
|
+
task ci
|
92
|
+
|
93
|
+
echo "Publish the project package to PyPI"
|
94
|
+
task publish
|
95
|
+
```
|
96
|
+
|
97
|
+
### 3. Run in DevContainer ๐ณ
|
98
|
+
|
99
|
+
1. Open the project in **VSCode**.
|
100
|
+
2. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension.
|
101
|
+
3. **Reopen in Container**:
|
102
|
+
**Command Palette `Ctrl+Shift+P` โ Reopen in Container**.
|
103
|
+
|
104
|
+
---
|
105
|
+
|
106
|
+
## Project Structure
|
107
|
+
|
108
|
+
> ๐ End-to-end Production-grade project structure for successful ๐ CloudOps Automation and Visual Analytics FinOps projects ๐
|
109
|
+
|
110
|
+
```
|
111
|
+
cloudops-automation/
|
112
|
+
โโโ .devcontainer/ ## Dev Container configurations
|
113
|
+
โ โโโ Dockerfile ## Container image build file
|
114
|
+
โโโ .github/ ## CI/CD workflows
|
115
|
+
โ โโโ workflows/ ## GitHub Actions workflows
|
116
|
+
โ โโโ templates/ ## Workflow templates
|
117
|
+
โโโ .vscode/ ## IDE-specific configurations
|
118
|
+
โโโ config/ ## Configuration files (YAML, JSON)
|
119
|
+
โโโ data ๐ Where all your raw and processed data files are stored.
|
120
|
+
โ โโโ external <- Data from third-party sources.
|
121
|
+
โ โโโ interim <- Intermediate data that has been transformed.
|
122
|
+
โ โโโ processed <- The final, canonical data sets for modeling.
|
123
|
+
โ โโโ raw <- The original, unprocessed, immutable data dump.
|
124
|
+
โ
|
125
|
+
โโโ docs ๐ A default mkdocs project; see mkdocs.org for details
|
126
|
+
โ โโโ api/ ## API documentation
|
127
|
+
โ โโโ architecture/ ## Architecture diagrams
|
128
|
+
โ โโโ tutorials/ ## Tutorials and guides
|
129
|
+
โ โโโ getting-started.md ## Quickstart guide
|
130
|
+
โ โโโ index.md ## Overview documentation
|
131
|
+
โ
|
132
|
+
โโโ logs/ ## Log files for debugging
|
133
|
+
|
|
134
|
+
โโโ models ๐ง Store your trained and serialized models for easy access and versioning.
|
135
|
+
โ
|
136
|
+
โโโ notebooks ๐ป Jupyter notebooks for experiments and visualization.
|
137
|
+
โ โโโ data_exploration.ipynb
|
138
|
+
โ โโโ data_preprocessing.ipynb
|
139
|
+
โ โโโ model_training.ipynb
|
140
|
+
โ โโโ model_evaluation.ipynb
|
141
|
+
โ
|
142
|
+
โโโ pyproject.toml <- Project configuration file with package metadata for
|
143
|
+
โ cloudops and configuration for tools like black
|
144
|
+
โ
|
145
|
+
โโโ src/ ## ๐งฉ Source code for use in this project.
|
146
|
+
โ โโโ cloudops/ ## Main module for CloudOps automation
|
147
|
+
โ โ โโโ __init__.py ## Package initializer
|
148
|
+
โ โ โโโ s3.py ## S3 utility functions
|
149
|
+
โ โ โโโ ec2.py ## EC2 automation
|
150
|
+
โ โ โโโ rds.py ## RDS management
|
151
|
+
โ โ โโโ runbooks/ ## Automation runbooks
|
152
|
+
โ โ โ โโโ backup.py ## Automated backup runbook
|
153
|
+
โ โ โ โโโ scale-out.py ## Scale-out automation runbook
|
154
|
+
โ โ โ โโโ cleanup.py ## Cleanup automation runbook
|
155
|
+
โ โโโ utils/ ## Utility scripts (logging, configs)
|
156
|
+
โ โโโ cli/ ## Command-line interface
|
157
|
+
โ โ โโโ __init__.py ## CLI module initializer
|
158
|
+
โ โ โโโ main.py ## CLI entry point
|
159
|
+
โ โ โโโ commands.py ## CLI commands
|
160
|
+
โ โโโ tests/ ## Unit and integration tests
|
161
|
+
โ โโโ test_s3.py ## Test cases for S3 module
|
162
|
+
โ โโโ test_ec2.py ## Test cases for EC2 module
|
163
|
+
โ โโโ test_runbooks.py ## Test cases for runbooks
|
164
|
+
โโโ templates/ ## Terraform and CloudFormation templates
|
165
|
+
โโโ tools/ ## Developer tools and scripts
|
166
|
+
โโโ .dockerignore ## Docker ignore file
|
167
|
+
โโโ .env ## Environment variables
|
168
|
+
โโโ .gitignore ## Git ignore file
|
169
|
+
โโโ .python-version ## Python version management
|
170
|
+
โโโ .gitignore
|
171
|
+
โโโ mkdocs.yml # Documentation generator configuration
|
172
|
+
โโโ README.md ๐ค Explain your project and its structure for better collaboration.
|
173
|
+
โโโ references <- Data dictionaries, manuals, and all other explanatory materials.
|
174
|
+
โ
|
175
|
+
โโโ reports ๐ Generated analysis (reports, charts, and plots) as HTML, PDF, LaTeX.
|
176
|
+
โ โโโ figures <- Generated graphics and figures to be used in reporting
|
177
|
+
โ
|
178
|
+
โโโ requirements.txt ๐ The requirements file for reproducing the analysis environment, for easy environment setup.
|
179
|
+
โโโ Taskfile <- Taskfile with convenience commands like `task data` or `task train`
|
180
|
+
|
181
|
+
```
|
@@ -0,0 +1,6 @@
|
|
1
|
+
cloudops/__init__.py,sha256=FzKaMwt2VjEQSJ1A3_jDmHqGyxawsmmtfJtiDvcDmr4,230
|
2
|
+
cloudops/toolkit.py,sha256=4fICu62-eaxjaxfR8TzYpFcLSzK_m5Eoll-WayU9xrE,3650
|
3
|
+
runbooks-0.1.1.dist-info/METADATA,sha256=FDD8yt6vpj3uE0oxgBFPBIArFJAl-sAvdfBG68K2BDE,10665
|
4
|
+
runbooks-0.1.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
5
|
+
runbooks-0.1.1.dist-info/top_level.txt,sha256=DKYLN0RQdA42RbZhbFKw2kz4Id3KIqM0CeBFdof7RnQ,9
|
6
|
+
runbooks-0.1.1.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
cloudops
|