mcp-souschef 2.2.0__py3-none-any.whl → 2.8.0__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.2.0.dist-info → mcp_souschef-2.8.0.dist-info}/METADATA +226 -38
- mcp_souschef-2.8.0.dist-info/RECORD +42 -0
- mcp_souschef-2.8.0.dist-info/entry_points.txt +4 -0
- souschef/__init__.py +10 -2
- souschef/assessment.py +113 -30
- souschef/ci/__init__.py +11 -0
- souschef/ci/github_actions.py +379 -0
- souschef/ci/gitlab_ci.py +299 -0
- souschef/ci/jenkins_pipeline.py +343 -0
- souschef/cli.py +605 -5
- souschef/converters/__init__.py +2 -2
- souschef/converters/cookbook_specific.py +125 -0
- souschef/converters/cookbook_specific.py.backup +109 -0
- souschef/converters/playbook.py +853 -15
- souschef/converters/resource.py +103 -1
- souschef/core/constants.py +13 -0
- souschef/core/path_utils.py +12 -9
- souschef/core/validation.py +35 -2
- souschef/deployment.py +29 -27
- souschef/filesystem/operations.py +0 -7
- souschef/parsers/__init__.py +6 -1
- souschef/parsers/attributes.py +397 -32
- souschef/parsers/inspec.py +343 -18
- souschef/parsers/metadata.py +30 -0
- souschef/parsers/recipe.py +48 -10
- souschef/server.py +429 -178
- souschef/ui/__init__.py +8 -0
- souschef/ui/app.py +2998 -0
- souschef/ui/health_check.py +36 -0
- souschef/ui/pages/ai_settings.py +497 -0
- souschef/ui/pages/cookbook_analysis.py +1360 -0
- mcp_souschef-2.2.0.dist-info/RECORD +0 -31
- mcp_souschef-2.2.0.dist-info/entry_points.txt +0 -4
- {mcp_souschef-2.2.0.dist-info → mcp_souschef-2.8.0.dist-info}/WHEEL +0 -0
- {mcp_souschef-2.2.0.dist-info → mcp_souschef-2.8.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Cookbook-specific resource conversions for common infrastructure cookbooks."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
APT_MODULE = "ansible.builtin.apt"
|
|
6
|
+
|
|
7
|
+
# Cookbook-specific include_recipe mappings
|
|
8
|
+
# Maps cookbook names to their primary package installation parameters
|
|
9
|
+
COOKBOOK_PACKAGE_MAPPINGS: dict[str, dict[str, Any]] = {
|
|
10
|
+
"nodejs": {
|
|
11
|
+
"module": APT_MODULE,
|
|
12
|
+
"params": {"name": ["nodejs", "npm"], "state": "present", "update_cache": True},
|
|
13
|
+
},
|
|
14
|
+
"apache2": {
|
|
15
|
+
"module": APT_MODULE,
|
|
16
|
+
"params": {"name": "apache2", "state": "present", "update_cache": True},
|
|
17
|
+
},
|
|
18
|
+
"mysql": {
|
|
19
|
+
"module": APT_MODULE,
|
|
20
|
+
"params": {"name": "mysql-server", "state": "present", "update_cache": True},
|
|
21
|
+
},
|
|
22
|
+
"docker": {
|
|
23
|
+
"module": APT_MODULE,
|
|
24
|
+
"params": {
|
|
25
|
+
"name": ["docker-ce", "docker-ce-cli", "containerd.io"],
|
|
26
|
+
"state": "present",
|
|
27
|
+
"update_cache": True,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_cookbook_package_config(cookbook_name: str) -> dict[str, Any] | None:
|
|
34
|
+
"""
|
|
35
|
+
Get package installation configuration for a specific cookbook.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
cookbook_name: Name of the cookbook (e.g., 'nodejs', 'apache2').
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Dictionary with 'module' and 'params' keys, or None if not found.
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
return COOKBOOK_PACKAGE_MAPPINGS.get(cookbook_name)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Cookbook-specific resource type mappings
|
|
48
|
+
# Maps resource types that are specific to certain cookbooks
|
|
49
|
+
COOKBOOK_RESOURCE_MAPPINGS: dict[str, dict[str, Any]] = {
|
|
50
|
+
"nodejs_npm": {
|
|
51
|
+
"description": "Node.js npm package installation",
|
|
52
|
+
"params_builder": "_build_nodejs_npm_params",
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _normalize_template_value(value: Any) -> Any:
|
|
58
|
+
"""
|
|
59
|
+
Normalize a template value for use in generated parameters.
|
|
60
|
+
|
|
61
|
+
This local implementation avoids importing from souschef.converters.resource
|
|
62
|
+
to prevent an import cycle. It performs a minimal, safe normalization:
|
|
63
|
+
- For strings, trim surrounding whitespace.
|
|
64
|
+
- For all other types, return the value unchanged.
|
|
65
|
+
"""
|
|
66
|
+
if isinstance(value, str):
|
|
67
|
+
return value.strip()
|
|
68
|
+
return value
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _build_nodejs_npm_params(
|
|
72
|
+
resource_name: str, action: str, props: dict[str, Any]
|
|
73
|
+
) -> dict[str, Any]:
|
|
74
|
+
"""Build parameters for nodejs_npm resources."""
|
|
75
|
+
params = {"name": resource_name, "global": True}
|
|
76
|
+
if "version" in props:
|
|
77
|
+
params["version"] = _normalize_template_value(props["version"])
|
|
78
|
+
if action == "install":
|
|
79
|
+
params["state"] = "present"
|
|
80
|
+
elif action == "remove":
|
|
81
|
+
params["state"] = "absent"
|
|
82
|
+
else:
|
|
83
|
+
params["state"] = "present"
|
|
84
|
+
return params
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_cookbook_resource_config(resource_type: str) -> dict[str, Any] | None:
|
|
88
|
+
"""
|
|
89
|
+
Get configuration for cookbook-specific resource types.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
resource_type: The resource type (e.g., 'nodejs_npm').
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Dictionary with resource configuration, or None if not found.
|
|
96
|
+
|
|
97
|
+
"""
|
|
98
|
+
return COOKBOOK_RESOURCE_MAPPINGS.get(resource_type)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def build_cookbook_resource_params(
|
|
102
|
+
resource_type: str, resource_name: str, action: str, props: dict[str, Any]
|
|
103
|
+
) -> dict[str, Any] | None:
|
|
104
|
+
"""
|
|
105
|
+
Build parameters for cookbook-specific resource types.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
resource_type: The resource type.
|
|
109
|
+
resource_name: The resource name.
|
|
110
|
+
action: The Chef action.
|
|
111
|
+
props: Parsed properties dictionary.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Dictionary of Ansible module parameters, or None if not supported.
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
config = get_cookbook_resource_config(resource_type)
|
|
118
|
+
if not config:
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
builder_name = config.get("params_builder")
|
|
122
|
+
if builder_name == "_build_nodejs_npm_params":
|
|
123
|
+
return _build_nodejs_npm_params(resource_name, action, props)
|
|
124
|
+
|
|
125
|
+
return None
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Cookbook-specific resource conversions for common infrastructure cookbooks."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
# Cookbook-specific include_recipe mappings
|
|
6
|
+
# Maps cookbook names to their primary package installation parameters
|
|
7
|
+
COOKBOOK_PACKAGE_MAPPINGS: dict[str, dict[str, Any]] = {
|
|
8
|
+
"nodejs": {
|
|
9
|
+
"module": "ansible.builtin.apt",
|
|
10
|
+
"params": {"name": ["nodejs", "npm"], "state": "present", "update_cache": True}
|
|
11
|
+
},
|
|
12
|
+
"apache2": {
|
|
13
|
+
"module": "ansible.builtin.apt",
|
|
14
|
+
"params": {"name": "apache2", "state": "present", "update_cache": True}
|
|
15
|
+
},
|
|
16
|
+
"mysql": {
|
|
17
|
+
"module": "ansible.builtin.apt",
|
|
18
|
+
"params": {"name": "mysql-server", "state": "present", "update_cache": True}
|
|
19
|
+
},
|
|
20
|
+
"docker": {
|
|
21
|
+
"module": "ansible.builtin.apt",
|
|
22
|
+
"params": {
|
|
23
|
+
"name": ["docker-ce", "docker-ce-cli", "containerd.io"],
|
|
24
|
+
"state": "present",
|
|
25
|
+
"update_cache": True
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_cookbook_package_config(cookbook_name: str) -> dict[str, Any] | None:
|
|
32
|
+
"""
|
|
33
|
+
Get package installation configuration for a specific cookbook.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
cookbook_name: Name of the cookbook (e.g., 'nodejs', 'apache2').
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Dictionary with 'module' and 'params' keys, or None if not found.
|
|
40
|
+
"""
|
|
41
|
+
return COOKBOOK_PACKAGE_MAPPINGS.get(cookbook_name)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# Cookbook-specific resource type mappings
|
|
45
|
+
# Maps resource types that are specific to certain cookbooks
|
|
46
|
+
COOKBOOK_RESOURCE_MAPPINGS: dict[str, dict[str, Any]] = {
|
|
47
|
+
"nodejs_npm": {
|
|
48
|
+
"description": "Node.js npm package installation",
|
|
49
|
+
"params_builder": "_build_nodejs_npm_params",
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _build_nodejs_npm_params(
|
|
55
|
+
resource_name: str, action: str, props: dict[str, Any]
|
|
56
|
+
) -> dict[str, Any]:
|
|
57
|
+
"""Build parameters for nodejs_npm resources."""
|
|
58
|
+
from souschef.converters.resource import _normalize_template_value
|
|
59
|
+
|
|
60
|
+
params = {"name": resource_name, "global": True}
|
|
61
|
+
if "version" in props:
|
|
62
|
+
params["version"] = _normalize_template_value(props["version"])
|
|
63
|
+
if action == "install":
|
|
64
|
+
params["state"] = "present"
|
|
65
|
+
elif action == "remove":
|
|
66
|
+
params["state"] = "absent"
|
|
67
|
+
else:
|
|
68
|
+
params["state"] = "present"
|
|
69
|
+
return params
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def get_cookbook_resource_config(resource_type: str) -> dict[str, Any] | None:
|
|
73
|
+
"""
|
|
74
|
+
Get configuration for cookbook-specific resource types.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
resource_type: The resource type (e.g., 'nodejs_npm').
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Dictionary with resource configuration, or None if not found.
|
|
81
|
+
"""
|
|
82
|
+
return COOKBOOK_RESOURCE_MAPPINGS.get(resource_type)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def build_cookbook_resource_params(
|
|
86
|
+
resource_type: str, resource_name: str, action: str, props: dict[str, Any]
|
|
87
|
+
) -> dict[str, Any] | None:
|
|
88
|
+
"""
|
|
89
|
+
Build parameters for cookbook-specific resource types.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
resource_type: The resource type.
|
|
93
|
+
resource_name: The resource name.
|
|
94
|
+
action: The Chef action.
|
|
95
|
+
props: Parsed properties dictionary.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Dictionary of Ansible module parameters, or None if not supported.
|
|
99
|
+
"""
|
|
100
|
+
config = get_cookbook_resource_config(resource_type)
|
|
101
|
+
if not config:
|
|
102
|
+
return None
|
|
103
|
+
|
|
104
|
+
builder_name = config.get("params_builder")
|
|
105
|
+
if builder_name == "_build_nodejs_npm_params":
|
|
106
|
+
return _build_nodejs_npm_params(resource_name, action, props)
|
|
107
|
+
|
|
108
|
+
return None</content>
|
|
109
|
+
<parameter name="filePath">/workspaces/souschef/souschef/converters/cookbook_specific.py
|