mcp-souschef 2.0.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.
- mcp_souschef-2.0.1.dist-info/METADATA +849 -0
- mcp_souschef-2.0.1.dist-info/RECORD +8 -0
- mcp_souschef-2.0.1.dist-info/WHEEL +4 -0
- mcp_souschef-2.0.1.dist-info/entry_points.txt +4 -0
- mcp_souschef-2.0.1.dist-info/licenses/LICENSE +21 -0
- souschef/__init__.py +0 -0
- souschef/cli.py +435 -0
- souschef/server.py +8199 -0
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-souschef
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: AI-powered MCP server for Chef to Ansible conversion
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: SousChef Contributors
|
|
8
|
+
Requires-Python: >=3.14,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Requires-Dist: anthropic (>=0.75.0)
|
|
13
|
+
Requires-Dist: click (>=8.1.0)
|
|
14
|
+
Requires-Dist: mcp (>=1.25.0)
|
|
15
|
+
Requires-Dist: python-dotenv (>=1.2.1)
|
|
16
|
+
Requires-Dist: zod (>=0.8.0)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# Chef to Ansible migration - SousChef MCP 🍳
|
|
20
|
+
|
|
21
|
+
An AI-powered MCP (Model Context Protocol) server that provides comprehensive Chef-to-Ansible migration capabilities for enterprise infrastructure transformation.
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/project/mcp-souschef/)
|
|
24
|
+
[](https://www.python.org/downloads/)
|
|
25
|
+
[](https://opensource.org/licenses/MIT)
|
|
26
|
+
[](htmlcov/index.html)
|
|
27
|
+
[](https://github.com/astral-sh/ruff)
|
|
28
|
+
[](http://mypy-lang.org/)
|
|
29
|
+
[](https://sonarcloud.io/summary/new_code?id=kpeacocke_souschef)
|
|
30
|
+
[](https://sonarcloud.io/summary/new_code?id=kpeacocke_souschef)
|
|
31
|
+
[](https://sonarcloud.io/summary/new_code?id=kpeacocke_souschef)
|
|
32
|
+
|
|
33
|
+
## Overview - Chef to Ansible features
|
|
34
|
+
|
|
35
|
+
SousChef is a complete enterprise-grade migration platform with 34 MCP tools organized across 8 major capability areas to facilitate Chef-to-Ansible AWX/AAP migrations. From cookbook analysis to deployment pattern conversion, SousChef provides everything needed for a successful infrastructure automation migration.
|
|
36
|
+
|
|
37
|
+
## 📦 Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# PyPI Installation
|
|
41
|
+
pip install mcp-souschef
|
|
42
|
+
|
|
43
|
+
# Development Installation
|
|
44
|
+
git clone https://github.com/kpeacocke/souschef.git
|
|
45
|
+
cd souschef
|
|
46
|
+
poetry install
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> **📖 For detailed installation instructions, MCP setup, and configuration, see [Installation & Setup](#installation--setup)**
|
|
50
|
+
|
|
51
|
+
## 🚀 Core Capabilities
|
|
52
|
+
|
|
53
|
+
### 1. Chef Cookbook Analysis & Parsing
|
|
54
|
+
Complete cookbook introspection and analysis tools:
|
|
55
|
+
|
|
56
|
+
- **parse_template** - Parse ERB templates with Jinja2 conversion and variable extraction
|
|
57
|
+
- **parse_custom_resource** - Extract properties, attributes, and actions from custom resources and LWRPs
|
|
58
|
+
- **list_directory** - Navigate and explore cookbook directory structures
|
|
59
|
+
- **read_file** - Read cookbook files with error handling
|
|
60
|
+
- **read_cookbook_metadata** - Parse metadata.rb files for dependencies and cookbook information
|
|
61
|
+
- **parse_recipe** - Analyze Chef recipes and extract resources, actions, and properties
|
|
62
|
+
- **parse_attributes** - Parse attribute files (default, override, normal) with precedence analysis
|
|
63
|
+
- **list_cookbook_structure** - Display complete cookbook directory hierarchy
|
|
64
|
+
|
|
65
|
+
### 2. Chef-to-Ansible Conversion Engine
|
|
66
|
+
Advanced resource-to-task conversion with intelligent module selection:
|
|
67
|
+
|
|
68
|
+
- **convert_resource_to_task** - Transform individual Chef resources to Ansible tasks
|
|
69
|
+
- **generate_playbook_from_recipe** - Generate complete Ansible playbooks from Chef recipes
|
|
70
|
+
|
|
71
|
+
### 3. Chef Search & Inventory Integration
|
|
72
|
+
Convert Chef search patterns to dynamic Ansible inventory:
|
|
73
|
+
|
|
74
|
+
- **convert_chef_search_to_inventory** - Transform Chef search queries to Ansible inventory groups
|
|
75
|
+
- **generate_dynamic_inventory_script** - Create dynamic inventory scripts from Chef server queries
|
|
76
|
+
- **analyze_chef_search_patterns** - Discover and analyze search usage in cookbooks
|
|
77
|
+
|
|
78
|
+
### 4. InSpec Integration & Validation
|
|
79
|
+
Complete InSpec-to-Ansible testing pipeline:
|
|
80
|
+
|
|
81
|
+
- **parse_inspec_profile** - Parse InSpec profiles and extract controls
|
|
82
|
+
- **convert_inspec_to_test** - Convert InSpec controls to Testinfra or Ansible assert tasks
|
|
83
|
+
- **generate_inspec_from_recipe** - Auto-generate InSpec validation from Chef recipes
|
|
84
|
+
|
|
85
|
+
### 5. Data Bags & Secrets Management
|
|
86
|
+
Chef data bags to Ansible vars/vault conversion:
|
|
87
|
+
|
|
88
|
+
- **convert_chef_databag_to_vars** - Transform data bags to Ansible variable files
|
|
89
|
+
- **generate_ansible_vault_from_databags** - Convert encrypted data bags to Ansible Vault
|
|
90
|
+
- **analyze_chef_databag_usage** - Analyze data bag usage patterns in cookbooks
|
|
91
|
+
|
|
92
|
+
### 6. Environment & Configuration Management
|
|
93
|
+
Chef environments to Ansible inventory groups:
|
|
94
|
+
|
|
95
|
+
- **convert_chef_environment_to_inventory_group** - Transform Chef environments to inventory
|
|
96
|
+
- **generate_inventory_from_chef_environments** - Generate complete inventory from environments
|
|
97
|
+
- **analyze_chef_environment_usage** - Analyze environment usage in cookbooks
|
|
98
|
+
|
|
99
|
+
### 7. AWX/Ansible Automation Platform Integration
|
|
100
|
+
Enterprise AWX/AAP configuration generation:
|
|
101
|
+
|
|
102
|
+
- **generate_awx_job_template_from_cookbook** - Create AWX job templates from cookbooks
|
|
103
|
+
- **generate_awx_workflow_from_chef_runlist** - Transform Chef run-lists to AWX workflows
|
|
104
|
+
- **generate_awx_project_from_cookbooks** - Generate AWX projects from cookbook collections
|
|
105
|
+
- **generate_awx_inventory_source_from_chef** - Create dynamic inventory sources from Chef server
|
|
106
|
+
|
|
107
|
+
### 8. Advanced Deployment Patterns & Migration Assessment
|
|
108
|
+
Modern deployment strategies and migration planning:
|
|
109
|
+
|
|
110
|
+
- **convert_chef_deployment_to_ansible_strategy** - Convert deployment recipes to Ansible strategies
|
|
111
|
+
- **generate_blue_green_deployment_playbook** - Create blue/green deployment playbooks
|
|
112
|
+
- **generate_canary_deployment_strategy** - Generate canary deployment configurations
|
|
113
|
+
- **analyze_chef_application_patterns** - Identify application deployment patterns
|
|
114
|
+
- **assess_chef_migration_complexity** - Comprehensive migration complexity assessment
|
|
115
|
+
- **generate_migration_plan** - Create detailed migration execution plans
|
|
116
|
+
- **analyze_cookbook_dependencies** - Analyze dependencies and migration order
|
|
117
|
+
- **generate_migration_report** - Generate executive and technical migration reports
|
|
118
|
+
|
|
119
|
+
## 🎯 Migration Workflow
|
|
120
|
+
|
|
121
|
+
### Phase 1: Discovery & Assessment
|
|
122
|
+
```bash
|
|
123
|
+
# Assess migration complexity
|
|
124
|
+
assess_chef_migration_complexity /path/to/cookbooks
|
|
125
|
+
|
|
126
|
+
# Analyze cookbook dependencies
|
|
127
|
+
analyze_cookbook_dependencies /path/to/cookbook
|
|
128
|
+
|
|
129
|
+
# Generate migration plan
|
|
130
|
+
generate_migration_plan '{\"cookbooks\": [\"/path/to/cookbook1\", \"/path/to/cookbook2\"]}'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Phase 2: Content Conversion
|
|
134
|
+
```bash
|
|
135
|
+
# Convert recipes to playbooks
|
|
136
|
+
generate_playbook_from_recipe /path/to/recipe.rb
|
|
137
|
+
|
|
138
|
+
# Convert data bags to Ansible Vault
|
|
139
|
+
generate_ansible_vault_from_databags /path/to/databags
|
|
140
|
+
|
|
141
|
+
# Convert environments to inventory
|
|
142
|
+
generate_inventory_from_chef_environments /path/to/environments
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Phase 3: AWX/AAP Integration
|
|
146
|
+
```bash
|
|
147
|
+
# Generate AWX job templates
|
|
148
|
+
generate_awx_job_template_from_cookbook /path/to/cookbook cookbook_name
|
|
149
|
+
|
|
150
|
+
# Create AWX workflows from run-lists
|
|
151
|
+
generate_awx_workflow_from_chef_runlist \"recipe[app::deploy]\" workflow_name
|
|
152
|
+
|
|
153
|
+
# Setup dynamic inventory from Chef server
|
|
154
|
+
generate_awx_inventory_source_from_chef https://chef.example.com production web_servers
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Phase 4: Validation & Testing
|
|
158
|
+
```bash
|
|
159
|
+
# Generate InSpec validation
|
|
160
|
+
generate_inspec_from_recipe /path/to/recipe.rb
|
|
161
|
+
|
|
162
|
+
# Convert existing InSpec to Ansible tests
|
|
163
|
+
convert_inspec_to_test /path/to/inspec_profile testinfra
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## 📊 Enterprise Features
|
|
167
|
+
|
|
168
|
+
### Migration Assessment & Reporting
|
|
169
|
+
- **Complexity Analysis**: Automated assessment of migration effort and risk factors
|
|
170
|
+
- **Dependency Mapping**: Complete cookbook dependency analysis with migration ordering
|
|
171
|
+
- **Impact Analysis**: Resource usage patterns and conversion recommendations
|
|
172
|
+
- **Executive Reports**: Stakeholder-ready migration reports with timelines and costs
|
|
173
|
+
|
|
174
|
+
### Modern Deployment Patterns
|
|
175
|
+
- **Blue/Green Deployments**: Zero-downtime deployment strategies
|
|
176
|
+
- **Canary Releases**: Gradual rollout configurations
|
|
177
|
+
- **Application Patterns**: Modern containerized and cloud-native deployment patterns
|
|
178
|
+
- **Rollback Strategies**: Automated failure recovery procedures
|
|
179
|
+
|
|
180
|
+
### Enterprise Integration
|
|
181
|
+
- **AWX/AAP Ready**: Native Ansible Automation Platform integration
|
|
182
|
+
- **Dynamic Inventory**: Chef server integration for hybrid environments
|
|
183
|
+
- **Secrets Management**: Secure data bag to Vault conversion
|
|
184
|
+
- **Multi-Environment**: Production-ready inventory and variable management
|
|
185
|
+
|
|
186
|
+
## 🛠️ Installation & Setup
|
|
187
|
+
|
|
188
|
+
### Prerequisites
|
|
189
|
+
- Python 3.14+
|
|
190
|
+
- [Poetry](https://python-poetry.org/) for dependency management
|
|
191
|
+
- MCP-compatible client (Claude Desktop, VS Code with MCP extension, etc.)
|
|
192
|
+
|
|
193
|
+
### Quick Start
|
|
194
|
+
|
|
195
|
+
1. **Install SousChef**:
|
|
196
|
+
```bash
|
|
197
|
+
pip install mcp-souschef
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
2. **Configure MCP Client**:
|
|
201
|
+
|
|
202
|
+
**🎯 Quick Setup - Use Pre-configured Files:**
|
|
203
|
+
```bash
|
|
204
|
+
# Claude Desktop (macOS)
|
|
205
|
+
cp config/claude-desktop.json ~/Library/Application\ Support/Claude/claude_desktop_config.json
|
|
206
|
+
|
|
207
|
+
# VS Code Copilot (macOS/Linux)
|
|
208
|
+
mkdir -p ~/.config/Code/User/globalStorage/github.copilot-chat
|
|
209
|
+
cp config/vscode-copilot.json ~/.config/Code/User/globalStorage/github.copilot-chat/mcp.json
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
See [config/README.md](config/README.md) for detailed setup instructions, development configs, and troubleshooting.
|
|
213
|
+
|
|
214
|
+
3. **Start using SousChef**:
|
|
215
|
+
- **Claude Desktop**: Restart Claude, then ask: "What tools does souschef provide?"
|
|
216
|
+
- **VS Code Copilot**: Reload window, then use: `@souschef analyze this cookbook`
|
|
217
|
+
|
|
218
|
+
### Command Line Interface (CLI)
|
|
219
|
+
|
|
220
|
+
SousChef includes a standalone CLI for direct cookbook parsing and conversion:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Basic usage examples
|
|
224
|
+
souschef-cli --help
|
|
225
|
+
souschef-cli recipe /path/to/recipe.rb
|
|
226
|
+
souschef-cli template /path/to/template.erb
|
|
227
|
+
souschef-cli convert package nginx --action install
|
|
228
|
+
souschef-cli cookbook /path/to/cookbook
|
|
229
|
+
|
|
230
|
+
# Parse and convert with output formats
|
|
231
|
+
souschef-cli recipe recipe.rb --format json
|
|
232
|
+
souschef-cli inspec-generate recipe.rb > validation.rb
|
|
233
|
+
souschef-cli inspec-convert controls.rb --format testinfra
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Available Commands:**
|
|
237
|
+
- `recipe` - Parse Chef recipe files and extract resources
|
|
238
|
+
- `template` - Convert ERB templates to Jinja2 with variable extraction
|
|
239
|
+
- `resource` - Parse custom resources and LWRPs
|
|
240
|
+
- `attributes` - Extract Chef attribute definitions
|
|
241
|
+
- `metadata` - Parse cookbook metadata.rb files
|
|
242
|
+
- `structure` - Display cookbook directory structure
|
|
243
|
+
- `convert` - Convert Chef resources to Ansible tasks
|
|
244
|
+
- `cookbook` - Comprehensive cookbook analysis
|
|
245
|
+
- `inspec-parse` - Parse InSpec profiles and controls
|
|
246
|
+
- `inspec-convert` - Convert InSpec to Testinfra/Ansible tests
|
|
247
|
+
- `inspec-generate` - Generate InSpec validation from recipes
|
|
248
|
+
- `ls` / `cat` - File system operations
|
|
249
|
+
|
|
250
|
+
### Development Setup
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Install dependencies
|
|
254
|
+
poetry install
|
|
255
|
+
|
|
256
|
+
# Install pre-commit hooks (one-time - auto-handles poetry.lock)
|
|
257
|
+
poetry run pre-commit install
|
|
258
|
+
|
|
259
|
+
# Run tests
|
|
260
|
+
poetry run pytest
|
|
261
|
+
|
|
262
|
+
# Run with coverage
|
|
263
|
+
poetry run pytest --cov=souschef --cov-report=html
|
|
264
|
+
|
|
265
|
+
# Lint and format
|
|
266
|
+
poetry run ruff check .
|
|
267
|
+
poetry run ruff format .
|
|
268
|
+
|
|
269
|
+
# Type check
|
|
270
|
+
poetry run mypy souschef
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### **Dependency Management**
|
|
274
|
+
|
|
275
|
+
Poetry manages dependencies with **automatic lock file synchronization**:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Add dependencies
|
|
279
|
+
poetry add package-name # Production
|
|
280
|
+
poetry add --group dev package-name # Development
|
|
281
|
+
|
|
282
|
+
# Update lock file after manual pyproject.toml edits
|
|
283
|
+
poetry lock # Poetry 2.x preserves versions automatically
|
|
284
|
+
|
|
285
|
+
# Update dependencies
|
|
286
|
+
poetry update package-name # Specific package
|
|
287
|
+
poetry update # All packages
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Automated Systems:**
|
|
291
|
+
- ✅ Pre-commit hooks auto-update `poetry.lock` when `pyproject.toml` changes
|
|
292
|
+
- ✅ CI validates lock file on every PR
|
|
293
|
+
- ✅ Dependabot sends weekly dependency updates
|
|
294
|
+
|
|
295
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md#-managing-dependencies) for detailed dependency management guide.
|
|
296
|
+
|
|
297
|
+
## 🏗️ Architecture & Design
|
|
298
|
+
|
|
299
|
+
### MCP Protocol Integration
|
|
300
|
+
SousChef leverages the Model Context Protocol (MCP) to provide seamless integration with AI assistants and development environments:
|
|
301
|
+
|
|
302
|
+
- **34 Specialized Tools**: Each migration capability exposed as dedicated MCP tool
|
|
303
|
+
- **Type-Safe Interfaces**: Full Python type hints for reliable AI interactions
|
|
304
|
+
- **Comprehensive Error Handling**: Graceful degradation and helpful error messages
|
|
305
|
+
- **Streaming Support**: Efficient handling of large cookbook conversions
|
|
306
|
+
|
|
307
|
+
### Testing Strategy
|
|
308
|
+
Following enterprise-grade testing standards:
|
|
309
|
+
|
|
310
|
+
- **Unit Tests**: Mock-based testing for individual functions (tests/test_server.py)
|
|
311
|
+
- **Integration Tests**: Real cookbook testing with fixtures (tests/test_integration.py)
|
|
312
|
+
- **Property-Based Tests**: Hypothesis fuzz testing for edge cases (tests/test_property_based.py)
|
|
313
|
+
- **92% Coverage**: Comprehensive test coverage exceeding the 90% target for production readiness
|
|
314
|
+
|
|
315
|
+
### Quality Assurance
|
|
316
|
+
- **Zero Warnings Policy**: All code passes linting without disabling checks
|
|
317
|
+
- **Type Safety**: Complete type annotations throughout the codebase
|
|
318
|
+
- **Automated Testing**: CI/CD pipeline with comprehensive test suites
|
|
319
|
+
- **Documentation**: Detailed docstrings and usage examples
|
|
320
|
+
|
|
321
|
+
## 📚 Documentation
|
|
322
|
+
|
|
323
|
+
### Tool Reference
|
|
324
|
+
Each MCP tool includes comprehensive documentation:
|
|
325
|
+
- Purpose and use cases
|
|
326
|
+
- Parameter descriptions and types
|
|
327
|
+
- Return value specifications
|
|
328
|
+
- Usage examples and patterns
|
|
329
|
+
- Error handling behaviors
|
|
330
|
+
|
|
331
|
+
### Migration Guides
|
|
332
|
+
- **[Enterprise Migration Guide](docs/enterprise-migration.md)** - Complete methodology for large-scale migrations
|
|
333
|
+
- **[AWX Integration Guide](docs/awx-integration.md)** - Step-by-step AWX/AAP setup and configuration
|
|
334
|
+
- **[Testing Strategy Guide](docs/testing-strategy.md)** - Validation and testing approaches
|
|
335
|
+
- **[Best Practices](docs/best-practices.md)** - Recommended patterns and approaches
|
|
336
|
+
|
|
337
|
+
## 🤝 Contributing
|
|
338
|
+
|
|
339
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for:
|
|
340
|
+
- Development setup and workflow
|
|
341
|
+
- Code style and testing requirements
|
|
342
|
+
- Pull request process
|
|
343
|
+
- Issue reporting guidelines
|
|
344
|
+
|
|
345
|
+
## 📄 License
|
|
346
|
+
|
|
347
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
348
|
+
|
|
349
|
+
## 🚀 Roadmap
|
|
350
|
+
|
|
351
|
+
### Completed ✅
|
|
352
|
+
- ✅ Complete Chef cookbook parsing (recipes, attributes, metadata, templates)
|
|
353
|
+
- ✅ InSpec profile parsing and conversion to Testinfra/Ansible tests
|
|
354
|
+
- ✅ Chef resource to Ansible task conversion with module mapping
|
|
355
|
+
- ✅ Data bags to Ansible Vault conversion
|
|
356
|
+
- ✅ Chef environments to Ansible inventory conversion
|
|
357
|
+
- ✅ Chef search patterns to dynamic inventory conversion
|
|
358
|
+
- ✅ AWX/AAP job templates, workflows, and project generation
|
|
359
|
+
- ✅ Blue/green and canary deployment pattern generation
|
|
360
|
+
- ✅ Migration complexity assessment and planning tools
|
|
361
|
+
- ✅ Comprehensive testing suite (unit, integration, property-based)
|
|
362
|
+
- ✅ Command-line interface (CLI) for standalone usage
|
|
363
|
+
|
|
364
|
+
### In Progress 🔄
|
|
365
|
+
- 🔄 Enhanced error handling and user experience improvements
|
|
366
|
+
- 🔄 Documentation website and interactive examples
|
|
367
|
+
- 🔄 Performance optimizations for large-scale enterprise migrations
|
|
368
|
+
- 🔄 Technical debt reduction (15 functions tracked in [GitHub Issues](https://github.com/kpeacocke/souschef/issues?q=is%3Aissue+is%3Aopen+label%3Atechnical-debt))
|
|
369
|
+
|
|
370
|
+
### Planned 📅
|
|
371
|
+
- 📅 Chef Habitat to containerized deployment conversion
|
|
372
|
+
- 📅 Integration with additional test frameworks (ServerSpec, Goss)
|
|
373
|
+
- 📅 Visual migration planning and dependency mapping interface
|
|
374
|
+
- 📅 Terraform provider for infrastructure state management
|
|
375
|
+
- 📅 Jenkins/GitLab CI pipeline generation
|
|
376
|
+
- 📅 Advanced Chef guard handling (only_if, not_if conditions)
|
|
377
|
+
- 📅 Complex attribute precedence and merging logic
|
|
378
|
+
- 📅 Conversion validation and testing framework
|
|
379
|
+
|
|
380
|
+
## 🙋♀️ Support & Community
|
|
381
|
+
|
|
382
|
+
- **Issues**: [GitHub Issues](https://github.com/kpeacocke/souschef/issues)
|
|
383
|
+
- **Discussions**: [GitHub Discussions](https://github.com/kpeacocke/souschef/discussions)
|
|
384
|
+
- **Documentation**: [Wiki](https://github.com/kpeacocke/souschef/wiki)
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
**SousChef** - *Transforming infrastructure automation, one recipe at a time.* 🍳✨
|
|
389
|
+
desc 'Ensure package nginx is properly configured'
|
|
390
|
+
impact 1.0
|
|
391
|
+
|
|
392
|
+
describe package('nginx') do
|
|
393
|
+
it { should be_installed }
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
control 'service-nginx' do
|
|
398
|
+
title 'Verify service nginx'
|
|
399
|
+
desc 'Ensure service nginx is properly configured'
|
|
400
|
+
impact 1.0
|
|
401
|
+
|
|
402
|
+
describe service('nginx') do
|
|
403
|
+
it { should be_running }
|
|
404
|
+
it { should be_enabled }
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
control 'template--etc-nginx-nginx.conf' do
|
|
409
|
+
title 'Verify template /etc/nginx/nginx.conf'
|
|
410
|
+
desc 'Ensure template /etc/nginx/nginx.conf is properly configured'
|
|
411
|
+
impact 1.0
|
|
412
|
+
|
|
413
|
+
describe file('/etc/nginx/nginx.conf') do
|
|
414
|
+
it { should exist }
|
|
415
|
+
its('mode') { should cmp '0644' }
|
|
416
|
+
its('owner') { should eq 'root' }
|
|
417
|
+
its('group') { should eq 'root' }
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### Testinfra Integration
|
|
423
|
+
|
|
424
|
+
Convert to Python tests for CI/CD pipelines:
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
souschef-cli inspec-convert validation-controls.rb --format testinfra
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
```python
|
|
431
|
+
import pytest
|
|
432
|
+
|
|
433
|
+
def test_package_nginx(host):
|
|
434
|
+
"""Ensure package nginx is properly configured"""
|
|
435
|
+
pkg = host.package("nginx")
|
|
436
|
+
assert pkg.is_installed
|
|
437
|
+
|
|
438
|
+
def test_service_nginx(host):
|
|
439
|
+
"""Ensure service nginx is properly configured"""
|
|
440
|
+
svc = host.service("nginx")
|
|
441
|
+
assert svc.is_running
|
|
442
|
+
assert svc.is_enabled
|
|
443
|
+
|
|
444
|
+
def test_template_etc_nginx_nginx_conf(host):
|
|
445
|
+
"""Ensure template /etc/nginx/nginx.conf is properly configured"""
|
|
446
|
+
f = host.file("/etc/nginx/nginx.conf")
|
|
447
|
+
assert f.exists
|
|
448
|
+
assert oct(f.mode) == "0644"
|
|
449
|
+
assert f.user == "root"
|
|
450
|
+
assert f.group == "root"
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
#### Ansible Assert Integration
|
|
454
|
+
|
|
455
|
+
For Ansible playbook validation:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
souschef-cli inspec-convert validation-controls.rb --format ansible_assert
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
```yaml
|
|
462
|
+
---
|
|
463
|
+
# Validation tasks converted from InSpec
|
|
464
|
+
|
|
465
|
+
- name: Verify package nginx
|
|
466
|
+
ansible.builtin.assert:
|
|
467
|
+
that:
|
|
468
|
+
- ansible_facts.packages['nginx'] is defined
|
|
469
|
+
fail_msg: "Ensure package nginx is properly configured validation failed"
|
|
470
|
+
|
|
471
|
+
- name: Verify service nginx
|
|
472
|
+
ansible.builtin.assert:
|
|
473
|
+
that:
|
|
474
|
+
- services['nginx'].state == 'running'
|
|
475
|
+
- services['nginx'].status == 'enabled'
|
|
476
|
+
fail_msg: "Ensure service nginx is properly configured validation failed"
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
#### Benefits
|
|
480
|
+
|
|
481
|
+
- **Consistency Validation** - Ensure Chef and Ansible produce identical infrastructure state
|
|
482
|
+
- **AI Context Enhancement** - InSpec profiles help AI understand infrastructure intent
|
|
483
|
+
- **Automated Testing** - Generate tests automatically from Chef recipes
|
|
484
|
+
- **Multiple Test Formats** - Support for InSpec, Testinfra, and Ansible assert
|
|
485
|
+
- **CI/CD Integration** - Easy integration with existing test pipelines
|
|
486
|
+
|
|
487
|
+
### As an MCP Server
|
|
488
|
+
|
|
489
|
+
SousChef is designed to be used as an MCP server with AI assistants that support the Model Context Protocol.
|
|
490
|
+
|
|
491
|
+
#### Configure with Claude Desktop
|
|
492
|
+
|
|
493
|
+
Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
494
|
+
|
|
495
|
+
```json
|
|
496
|
+
{
|
|
497
|
+
"mcpServers": {
|
|
498
|
+
"souschef": {
|
|
499
|
+
"command": "poetry",
|
|
500
|
+
"args": [
|
|
501
|
+
"-C",
|
|
502
|
+
"/path/to/souschef",
|
|
503
|
+
"run",
|
|
504
|
+
"souschef"
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Available Tools
|
|
512
|
+
|
|
513
|
+
#### `list_directory(path: str)`
|
|
514
|
+
List the contents of a directory.
|
|
515
|
+
|
|
516
|
+
**Example:**
|
|
517
|
+
```python
|
|
518
|
+
list_directory("/path/to/cookbooks")
|
|
519
|
+
# Returns: ['nginx', 'apache2', 'mysql']
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
#### `read_file(path: str)`
|
|
523
|
+
Read the contents of a file.
|
|
524
|
+
|
|
525
|
+
**Example:**
|
|
526
|
+
```python
|
|
527
|
+
read_file("/path/to/cookbook/recipes/default.rb")
|
|
528
|
+
# Returns: file contents as string
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
#### `read_cookbook_metadata(path: str)`
|
|
532
|
+
Parse Chef cookbook metadata.rb file.
|
|
533
|
+
|
|
534
|
+
**Example:**
|
|
535
|
+
```python
|
|
536
|
+
read_cookbook_metadata("/path/to/cookbook/metadata.rb")
|
|
537
|
+
# Returns:
|
|
538
|
+
# name: nginx
|
|
539
|
+
# maintainer: Chef Software, Inc.
|
|
540
|
+
# version: 8.0.0
|
|
541
|
+
# depends: logrotate, iptables
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
#### `parse_recipe(path: str)`
|
|
545
|
+
Parse a Chef recipe file and extract resources.
|
|
546
|
+
|
|
547
|
+
**Example:**
|
|
548
|
+
```python
|
|
549
|
+
parse_recipe("/path/to/cookbook/recipes/default.rb")
|
|
550
|
+
# Returns:
|
|
551
|
+
# Resource 1:
|
|
552
|
+
# Type: package
|
|
553
|
+
# Name: nginx
|
|
554
|
+
# Action: install
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
#### `parse_attributes(path: str)`
|
|
558
|
+
Parse a Chef attributes file and extract attribute definitions.
|
|
559
|
+
|
|
560
|
+
**Example:**
|
|
561
|
+
```python
|
|
562
|
+
parse_attributes("/path/to/cookbook/attributes/default.rb")
|
|
563
|
+
# Returns:
|
|
564
|
+
# default[nginx.port] = 80
|
|
565
|
+
# default[nginx.ssl_port] = 443
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
#### `list_cookbook_structure(path: str)`
|
|
569
|
+
List the structure of a Chef cookbook directory.
|
|
570
|
+
|
|
571
|
+
**Example:**
|
|
572
|
+
```python
|
|
573
|
+
list_cookbook_structure("/path/to/cookbook")
|
|
574
|
+
# Returns:
|
|
575
|
+
# recipes/
|
|
576
|
+
# default.rb
|
|
577
|
+
# install.rb
|
|
578
|
+
# attributes/
|
|
579
|
+
# default.rb
|
|
580
|
+
# metadata/
|
|
581
|
+
# metadata.rb
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
#### `parse_template(path: str)`
|
|
585
|
+
Parse a Chef ERB template file and convert it to Jinja2 format.
|
|
586
|
+
|
|
587
|
+
**Example:**
|
|
588
|
+
```python
|
|
589
|
+
parse_template("/path/to/cookbook/templates/default/nginx.conf.erb")
|
|
590
|
+
# Returns JSON with:
|
|
591
|
+
# {
|
|
592
|
+
# "original_file": "/path/to/cookbook/templates/default/nginx.conf.erb",
|
|
593
|
+
# "variables": [
|
|
594
|
+
# "nginx']['port",
|
|
595
|
+
# "nginx']['server_name",
|
|
596
|
+
# "nginx']['ssl_enabled"
|
|
597
|
+
# ],
|
|
598
|
+
# "jinja2_template": "server {\n listen {{ nginx']['port }};\n {% if nginx']['ssl_enabled %}\n ssl on;\n {% endif %}\n}"
|
|
599
|
+
# }
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**ERB to Jinja2 Conversion:**
|
|
603
|
+
- Variable output: `<%= var %>` → `{{ var }}`
|
|
604
|
+
- Instance variables: `<%= @var %>` → `{{ var }}`
|
|
605
|
+
- Node attributes: `<%= node['attr'] %>` → `{{ attr }}`
|
|
606
|
+
- Conditionals: `<% if cond %>` → `{% if cond %}`
|
|
607
|
+
- Unless: `<% unless cond %>` → `{% if not cond %}`
|
|
608
|
+
- Elsif: `<% elsif cond %>` → `{% elif cond %}`
|
|
609
|
+
- Else: `<% else %>` → `{% else %}`
|
|
610
|
+
- Loops: `<% arr.each do |item| %>` → `{% for item in arr %}`
|
|
611
|
+
- End blocks: `<% end %>` → `{% endif %}` or `{% endfor %}`
|
|
612
|
+
|
|
613
|
+
#### `parse_custom_resource(path: str)`
|
|
614
|
+
Parse a Chef custom resource or LWRP file and extract properties, attributes, and actions.
|
|
615
|
+
|
|
616
|
+
**Example:**
|
|
617
|
+
```python
|
|
618
|
+
parse_custom_resource("/path/to/cookbook/resources/app_config.rb")
|
|
619
|
+
# Returns JSON with:
|
|
620
|
+
# {
|
|
621
|
+
# "resource_file": "/path/to/cookbook/resources/app_config.rb",
|
|
622
|
+
# "resource_name": "app_config",
|
|
623
|
+
# "resource_type": "custom_resource", # or "lwrp"
|
|
624
|
+
# "properties": [
|
|
625
|
+
# {
|
|
626
|
+
# "name": "config_name",
|
|
627
|
+
# "type": "String",
|
|
628
|
+
# "name_property": true
|
|
629
|
+
# },
|
|
630
|
+
# {
|
|
631
|
+
# "name": "port",
|
|
632
|
+
# "type": "Integer",
|
|
633
|
+
# "default": "8080"
|
|
634
|
+
# },
|
|
635
|
+
# {
|
|
636
|
+
# "name": "ssl_enabled",
|
|
637
|
+
# "type": "[true, false]",
|
|
638
|
+
# "default": "false"
|
|
639
|
+
# }
|
|
640
|
+
# ],
|
|
641
|
+
# "actions": ["create", "delete"],
|
|
642
|
+
# "default_action": "create"
|
|
643
|
+
# }
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
**Detected Resource Types:**
|
|
647
|
+
- **Custom Resource** (modern) - Uses `property` keyword
|
|
648
|
+
- **LWRP** (legacy) - Uses `attribute` keyword with `kind_of:`
|
|
649
|
+
|
|
650
|
+
**Property/Attribute Fields:**
|
|
651
|
+
- `name` - Property/attribute name
|
|
652
|
+
- `type` - Type constraint (String, Integer, Boolean, Array, Hash, etc.)
|
|
653
|
+
- `name_property` - Whether this is the resource's name property (true/false)
|
|
654
|
+
- `default` - Default value if specified
|
|
655
|
+
- `required` - Whether the property is required (true/false)
|
|
656
|
+
|
|
657
|
+
**Action Extraction:**
|
|
658
|
+
- Modern format: `action :name do ... end`
|
|
659
|
+
- LWRP format: `actions :create, :delete, :update`
|
|
660
|
+
- Supports both formats and mixed declarations
|
|
661
|
+
|
|
662
|
+
#### `convert_resource_to_task(resource_type: str, resource_name: str, action: str = "create", properties: str = "")`
|
|
663
|
+
Convert a Chef resource to an Ansible task.
|
|
664
|
+
|
|
665
|
+
**Example:**
|
|
666
|
+
```python
|
|
667
|
+
convert_resource_to_task("package", "nginx", "install")
|
|
668
|
+
# Returns:
|
|
669
|
+
# - name: Install package nginx
|
|
670
|
+
# ansible.builtin.package:
|
|
671
|
+
# name: "nginx"
|
|
672
|
+
# state: "present"
|
|
673
|
+
|
|
674
|
+
convert_resource_to_task("service", "nginx", "start")
|
|
675
|
+
# Returns:
|
|
676
|
+
# - name: Start service nginx
|
|
677
|
+
# ansible.builtin.service:
|
|
678
|
+
# name: "nginx"
|
|
679
|
+
# enabled: true
|
|
680
|
+
# state: "started"
|
|
681
|
+
|
|
682
|
+
convert_resource_to_task("template", "/etc/nginx/nginx.conf.erb", "create")
|
|
683
|
+
# Returns:
|
|
684
|
+
# - name: Create template /etc/nginx/nginx.conf.erb
|
|
685
|
+
# ansible.builtin.template:
|
|
686
|
+
# src: "/etc/nginx/nginx.conf.erb"
|
|
687
|
+
# dest: "/etc/nginx/nginx.conf"
|
|
688
|
+
# mode: "0644"
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
**Supported Resource Types:**
|
|
692
|
+
- `package` → `ansible.builtin.package`
|
|
693
|
+
- `service` → `ansible.builtin.service`
|
|
694
|
+
- `template` → `ansible.builtin.template`
|
|
695
|
+
- `file` → `ansible.builtin.file`
|
|
696
|
+
- `directory` → `ansible.builtin.file` (with state: directory)
|
|
697
|
+
- `execute` → `ansible.builtin.command`
|
|
698
|
+
- `bash` → `ansible.builtin.shell`
|
|
699
|
+
- `user` → `ansible.builtin.user`
|
|
700
|
+
- `group` → `ansible.builtin.group`
|
|
701
|
+
- And more...
|
|
702
|
+
|
|
703
|
+
## Development
|
|
704
|
+
|
|
705
|
+
### Project Structure
|
|
706
|
+
|
|
707
|
+
```
|
|
708
|
+
souschef/
|
|
709
|
+
├── souschef/
|
|
710
|
+
│ ├── __init__.py
|
|
711
|
+
│ └── server.py # MCP server implementation
|
|
712
|
+
├── tests/
|
|
713
|
+
│ ├── __init__.py
|
|
714
|
+
│ └── test_server.py # Comprehensive test suite
|
|
715
|
+
├── .devcontainer/ # VS Code dev container config
|
|
716
|
+
├── .github/
|
|
717
|
+
│ └── copilot-instructions.md # Copilot development guidelines
|
|
718
|
+
├── pyproject.toml # Project configuration
|
|
719
|
+
└── README.md
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
### Development Standards
|
|
723
|
+
|
|
724
|
+
SousChef uses a modern Python toolchain for code quality:
|
|
725
|
+
|
|
726
|
+
- **Ruff**: Primary linter and formatter (replaces Black, isort, flake8)
|
|
727
|
+
```bash
|
|
728
|
+
poetry run ruff check . # Lint code
|
|
729
|
+
poetry run ruff format . # Format code
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
- **mypy**: Static type checking for CI/CD
|
|
733
|
+
```bash
|
|
734
|
+
poetry run mypy souschef # Type check source code
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
- **Pylance**: Real-time VS Code type checking and intellisense
|
|
738
|
+
- Configured in `.vscode/settings.json`
|
|
739
|
+
- Provides immediate feedback during development
|
|
740
|
+
|
|
741
|
+
- **pytest**: Testing framework with coverage reporting
|
|
742
|
+
```bash
|
|
743
|
+
poetry run pytest --cov=souschef --cov-report=term-missing
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
**Quality Requirements:**
|
|
747
|
+
- Zero warnings from all tools (Ruff, mypy, Pylance)
|
|
748
|
+
- Type hints required for all functions
|
|
749
|
+
- Google-style docstrings
|
|
750
|
+
- 92% test coverage (exceeds 90% target)
|
|
751
|
+
|
|
752
|
+
See [.github/copilot-instructions.md](.github/copilot-instructions.md) for detailed development guidelines.
|
|
753
|
+
|
|
754
|
+
### Running Tests
|
|
755
|
+
|
|
756
|
+
```bash
|
|
757
|
+
# Run all tests
|
|
758
|
+
poetry run pytest
|
|
759
|
+
|
|
760
|
+
# Run with coverage report
|
|
761
|
+
poetry run pytest --cov=souschef --cov-report=term-missing --cov-report=html
|
|
762
|
+
|
|
763
|
+
# Run only unit tests (mocked)
|
|
764
|
+
poetry run pytest tests/test_server.py
|
|
765
|
+
|
|
766
|
+
# Run only integration tests (real files)
|
|
767
|
+
poetry run pytest tests/test_integration.py
|
|
768
|
+
|
|
769
|
+
# Run property-based tests
|
|
770
|
+
poetry run pytest tests/test_property_based.py
|
|
771
|
+
|
|
772
|
+
# Run with benchmarks
|
|
773
|
+
poetry run pytest --benchmark-only
|
|
774
|
+
|
|
775
|
+
# Check code quality
|
|
776
|
+
poetry run ruff check . # Linting
|
|
777
|
+
poetry run ruff format . # Formatting
|
|
778
|
+
poetry run mypy souschef # Type checking
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
### Test Types
|
|
782
|
+
|
|
783
|
+
The project includes multiple types of tests:
|
|
784
|
+
|
|
785
|
+
1. **Unit Tests** (`test_server.py`)
|
|
786
|
+
- Mock-based tests for individual functions
|
|
787
|
+
- Test error handling and edge cases
|
|
788
|
+
- Fast execution, isolated from filesystem
|
|
789
|
+
|
|
790
|
+
2. **Integration Tests** (`test_integration.py`)
|
|
791
|
+
- Real file operations with test fixtures
|
|
792
|
+
- Validate parsing with actual Chef cookbook files
|
|
793
|
+
- Parameterized tests for various scenarios
|
|
794
|
+
- Performance benchmarks with pytest-benchmark
|
|
795
|
+
|
|
796
|
+
3. **Property-Based Tests** (`test_property_based.py`)
|
|
797
|
+
- Uses Hypothesis for fuzz testing
|
|
798
|
+
- Generates random inputs to find edge cases
|
|
799
|
+
- Ensures functions handle any input gracefully
|
|
800
|
+
|
|
801
|
+
4. **Test Fixtures**
|
|
802
|
+
- Sample Chef cookbook in `tests/fixtures/sample_cookbook/`
|
|
803
|
+
- Real-world metadata, recipes, and attributes
|
|
804
|
+
- Used for integration testing
|
|
805
|
+
|
|
806
|
+
### Test Coverage
|
|
807
|
+
|
|
808
|
+
The project maintains 92% test coverage, exceeding the 90% target. Run coverage with HTML report:
|
|
809
|
+
|
|
810
|
+
```bash
|
|
811
|
+
poetry run pytest --cov=souschef --cov-report=html
|
|
812
|
+
open htmlcov/index.html # View detailed coverage report
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
### Mutation Testing
|
|
816
|
+
|
|
817
|
+
To verify test quality with mutation testing:
|
|
818
|
+
|
|
819
|
+
```bash
|
|
820
|
+
poetry run mutmut run
|
|
821
|
+
poetry run mutmut results
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
### VS Code Tasks
|
|
825
|
+
|
|
826
|
+
The project includes several VS Code tasks:
|
|
827
|
+
- **Run Tests** - Execute test suite
|
|
828
|
+
- **Run Tests with Coverage** - Generate coverage reports
|
|
829
|
+
- **Lint (Ruff)** - Check code quality
|
|
830
|
+
- **Format (Ruff)** - Auto-format code
|
|
831
|
+
- **Lint & Test** - Run both linting and tests
|
|
832
|
+
|
|
833
|
+
## Contributing
|
|
834
|
+
|
|
835
|
+
Contributions are welcome! Please ensure:
|
|
836
|
+
1. All tests pass
|
|
837
|
+
2. Code coverage maintained at 90%+
|
|
838
|
+
3. Code passes ruff linting
|
|
839
|
+
4. All functions have type hints and docstrings
|
|
840
|
+
5. Follow the development standards in `.github/copilot-instructions.md`
|
|
841
|
+
|
|
842
|
+
## License
|
|
843
|
+
|
|
844
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
845
|
+
|
|
846
|
+
---
|
|
847
|
+
|
|
848
|
+
**SousChef** - *Ansible automation, one recipe at a time.* 🍳✨
|
|
849
|
+
|