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 ADDED
@@ -0,0 +1,10 @@
1
+ """
2
+ CloudOps: CloudOps Toolkit
3
+
4
+ Provides utility functions for math operations, AWS S3 interactions, and data management.
5
+ """
6
+
7
+ __version__ = "0.1.1"
8
+
9
+ from .toolkit import add, divide, multiply, subtract
10
+ # from .s3 import S3Client
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
+ [![๐Ÿ CloudOps PyPI version](https://img.shields.io/pypi/v/cloudops)](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,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ cloudops