Skip to content

Commit 2cbc2aa

Browse files
committed
Migrate dev environment plugins to unified feature system
Replace the hardcoded plugin registry and --foreman-development-enabled-plugin parameter with the shared feature system from src/. Development-specific metadata (git repos, settings templates) lives in development/features.yaml and is deep-merged with src/features.yaml at runtime via a new filter plugin.
1 parent 2aa04c7 commit 2cbc2aa

12 files changed

Lines changed: 349 additions & 180 deletions

File tree

development/ansible.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ host_key_checking = False
33
stdout_callback=debug
44
stderr_callback=debug
55
roles_path = ./roles:../src/roles
6+
filter_plugins = ./filter_plugins:../src/filter_plugins
67
display_skipped_hosts = no

development/features.yaml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
katello:
3+
development:
4+
foreman:
5+
github_repo: Katello/katello
6+
settings_template: katello.yaml.j2
7+
extra_gemfiles:
8+
- gemfile.d/test.rb
9+
hammer:
10+
gem: hammer_cli_katello
11+
github_repo: Katello/hammer-cli-katello
12+
module_config: katello.yml
13+
14+
dynflow:
15+
development:
16+
foreman_proxy:
17+
github_repo: theforeman/smart_proxy_dynflow
18+
module_config: dynflow.yml
19+
20+
remote-execution:
21+
development:
22+
foreman:
23+
github_repo: theforeman/foreman_remote_execution
24+
hammer:
25+
github_repo: theforeman/hammer_cli_foreman_remote_execution
26+
module_config: foreman_remote_execution.yml
27+
foreman_proxy:
28+
github_repo: theforeman/smart_proxy_remote_execution_ssh
29+
module_config: remote_execution_ssh.yml
30+
31+
ansible:
32+
development:
33+
foreman:
34+
github_repo: theforeman/foreman_ansible
35+
settings_template: foreman_ansible.yaml.j2
36+
hammer:
37+
gem: hammer_cli_foreman_ansible
38+
github_repo: theforeman/hammer-cli-foreman-ansible
39+
module_config: foreman_ansible.yml
40+
foreman_proxy:
41+
github_repo: theforeman/smart_proxy_ansible
42+
module_config: ansible.yml
43+
44+
rh-cloud:
45+
development:
46+
foreman:
47+
github_repo: theforeman/foreman_rh_cloud
48+
hammer:
49+
gem: hammer_cli_foreman_rh_cloud
50+
github_repo: theforeman/hammer-cli-foreman-rh-cloud
51+
module_config: foreman_rh_cloud.yml
52+
53+
# Features not yet in src/features.yaml — full definitions below.
54+
55+
foreman-tasks:
56+
description: Foreman Tasks plugin
57+
foreman:
58+
plugin_name: foreman_tasks
59+
hammer: foreman_tasks
60+
dependencies:
61+
- dynflow
62+
development:
63+
foreman:
64+
github_repo: theforeman/foreman-tasks
65+
hammer:
66+
gem: hammer_cli_foreman_tasks
67+
github_repo: theforeman/hammer-cli-foreman-tasks
68+
module_config: foreman_tasks.yml
69+
70+
discovery:
71+
description: Discovery plugin for Foreman
72+
foreman:
73+
plugin_name: foreman_discovery
74+
hammer: foreman_discovery
75+
development:
76+
foreman:
77+
github_repo: theforeman/foreman_discovery
78+
hammer:
79+
gem: hammer_cli_foreman_discovery
80+
github_repo: theforeman/hammer-cli-foreman-discovery
81+
module_config: foreman_discovery.yml
82+
foreman_proxy:
83+
github_repo: theforeman/smart_proxy_discovery
84+
module_config: discovery.yml
85+
86+
openscap:
87+
description: OpenSCAP plugin for Foreman
88+
foreman:
89+
plugin_name: foreman_openscap
90+
hammer: foreman_openscap
91+
development:
92+
foreman:
93+
github_repo: theforeman/foreman_openscap
94+
hammer:
95+
github_repo: theforeman/hammer_cli_foreman_openscap
96+
module_config: foreman_openscap.yml
97+
foreman_proxy:
98+
github_repo: theforeman/smart_proxy_openscap
99+
module_config: openscap.yml
100+
101+
bootdisk:
102+
description: Bootdisk plugin for Foreman
103+
foreman:
104+
plugin_name: foreman_bootdisk
105+
hammer: foreman_bootdisk
106+
development:
107+
foreman:
108+
github_repo: theforeman/foreman_bootdisk
109+
hammer:
110+
github_repo: theforeman/hammer_cli_foreman_bootdisk
111+
module_config: foreman_bootdisk.yml
112+
113+
theme-satellite:
114+
description: Red Hat Satellite theme for Foreman
115+
foreman:
116+
plugin_name: foreman_theme_satellite
117+
development:
118+
foreman:
119+
github_repo: redhatsatellite/foreman_theme_satellite
120+
121+
webhooks:
122+
description: Webhooks plugin for Foreman
123+
foreman:
124+
plugin_name: foreman_webhooks
125+
hammer: foreman_webhooks
126+
development:
127+
foreman:
128+
github_repo: theforeman/foreman_webhooks
129+
hammer:
130+
gem: hammer_cli_foreman_webhooks
131+
github_repo: theforeman/hammer-cli-foreman-webhooks
132+
module_config: foreman_webhooks.yml
133+
foreman_proxy:
134+
github_repo: theforeman/smart_proxy_shellhooks
135+
module_config: shellhooks.yml
136+
137+
templates:
138+
description: Templates plugin for Foreman
139+
foreman:
140+
plugin_name: foreman_templates
141+
hammer: foreman_templates
142+
development:
143+
foreman:
144+
github_repo: theforeman/foreman_templates
145+
hammer:
146+
gem: hammer_cli_foreman_templates
147+
github_repo: theforeman/hammer-cli-foreman-templates
148+
module_config: foreman_templates.yml
149+
150+
leapp:
151+
description: Leapp plugin for Foreman
152+
foreman:
153+
plugin_name: foreman_leapp
154+
hammer: foreman_leapp
155+
development:
156+
foreman:
157+
github_repo: theforeman/foreman_leapp
158+
hammer:
159+
gem: hammer_cli_foreman_leapp
160+
github_repo: theforeman/hammer-cli-foreman-leapp
161+
module_config: foreman_leapp.yml
162+
163+
puppet:
164+
description: Puppet plugin for Foreman
165+
foreman:
166+
plugin_name: foreman_puppet
167+
hammer: foreman_puppet
168+
development:
169+
foreman:
170+
github_repo: theforeman/foreman_puppet
171+
hammer:
172+
gem: hammer_cli_foreman_puppet
173+
github_repo: theforeman/hammer-cli-foreman-puppet
174+
module_config: foreman_puppet.yml
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from __future__ import (absolute_import, division, print_function)
2+
__metaclass__ = type
3+
4+
import pathlib
5+
import sys
6+
import yaml
7+
8+
# Make src filter_plugins importable to reuse dependency resolution logic
9+
# and the shared FEATURE_MAP, avoiding duplication.
10+
_src_filter_plugins = str(pathlib.Path(__file__).parent.parent.parent / 'src' / 'filter_plugins')
11+
if _src_filter_plugins not in sys.path:
12+
sys.path.insert(0, _src_filter_plugins)
13+
14+
from foremanctl import FEATURE_MAP, filter_features, get_dependencies_for_feature # noqa: E402
15+
16+
_dev_features_yaml = pathlib.Path(__file__).parent.parent / 'features.yaml'
17+
18+
19+
def _deep_merge(base, override):
20+
"""Recursively merge override into base, returning the merged dict."""
21+
merged = base.copy()
22+
for key, value in override.items():
23+
if key in merged and isinstance(merged[key], dict) and isinstance(value, dict):
24+
merged[key] = _deep_merge(merged[key], value)
25+
else:
26+
merged[key] = value
27+
return merged
28+
29+
30+
# Deep-merge development-specific feature extensions into the shared FEATURE_MAP.
31+
# This adds development: blocks to existing src/ features and introduces
32+
# dev-only features with full definitions.
33+
with _dev_features_yaml.open() as _f:
34+
for _feature, _data in yaml.safe_load(_f).items():
35+
if _feature in FEATURE_MAP:
36+
FEATURE_MAP[_feature] = _deep_merge(FEATURE_MAP[_feature], _data)
37+
else:
38+
FEATURE_MAP[_feature] = _data
39+
40+
41+
def _resolve_features(value):
42+
"""Resolve feature list including transitive dependencies, preserving order."""
43+
all_features = list(filter_features(value))
44+
deps = set()
45+
for f in all_features:
46+
deps.update(get_dependencies_for_feature(f))
47+
seen = set()
48+
result = []
49+
for f in list(filter_features(list(value) + list(deps))):
50+
if f not in seen:
51+
seen.add(f)
52+
result.append(f)
53+
return result
54+
55+
56+
def dev_plugins(value):
57+
"""Return list of development plugin configs for enabled features and their dependencies.
58+
59+
Each entry is the development: block from features.yaml for features that have
60+
any development data (foreman, hammer, or foreman_proxy). The calling tasks use
61+
conditional guards to skip entries that lack a specific component.
62+
"""
63+
plugins = []
64+
for feature in _resolve_features(value):
65+
dev_data = FEATURE_MAP.get(feature, {}).get('development', {})
66+
if dev_data:
67+
plugins.append(dev_data)
68+
return plugins
69+
70+
71+
class FilterModule(object):
72+
'''foremanctl development filters'''
73+
74+
def filters(self):
75+
return {
76+
'features_to_dev_plugins': dev_plugins,
77+
}

development/playbooks/_flavor_features/metadata.obsah.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
variables:
33
features:
44
parameter: --add-feature
5-
help: Additional features to enable in this deployment.
5+
help: Additional features to enable in production form.
6+
action: append_unique
7+
dev_features:
8+
parameter: --add-dev-feature
9+
help: Additional features to enable in development form (git checkout).
610
action: append_unique

development/playbooks/deploy-dev/metadata.obsah.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,6 @@ help: |
33
Deploy and manage Foreman development environment with git-based Foreman and containerized backend services.
44
55
variables:
6-
foreman_development_enabled_plugins:
7-
help: Plugin to enable (can be used multiple times)
8-
action: append
9-
parameter: --foreman-development-enabled-plugin
10-
choices:
11-
- foreman_remote_execution
12-
- foreman_ansible
13-
- foreman_rh_cloud
14-
- foreman_discovery
15-
- foreman_openscap
16-
- foreman_bootdisk
17-
- foreman_theme_satellite
18-
- foreman_tasks
19-
- foreman_webhooks
20-
- foreman_templates
21-
- foreman_leapp
22-
- foreman_puppet
236
target_host:
247
help: Target hostname or IP address for deployment
258
action: store

0 commit comments

Comments
 (0)