Skip to content

Commit 154bcff

Browse files
author
Arvind Jangir
committed
add check to avoid deployment with invalid features
1 parent 48984fd commit 154bcff

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/filter_plugins/foremanctl.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def list_all_features(enabled_features, only_enabled=False):
7373

7474
return "\n".join(output)
7575

76+
def invalid_features(features):
77+
"""Return a list of unknown features not defined in features.yaml."""
78+
return [feature for feature in features if feature not in FEATURE_MAP]
79+
7680
def foreman_proxy_plugins(value):
7781
dependencies = list(get_dependencies(filter_features(value)))
7882
plugins = [FEATURE_MAP.get(feature, {}).get('foreman_proxy', {}).get('plugin_name') for feature in filter_features(value + dependencies)]
@@ -94,4 +98,5 @@ def filters(self):
9498
'features_to_foreman_proxy_plugins': foreman_proxy_plugins,
9599
'available_foreman_proxy_plugins': available_foreman_proxy_plugins,
96100
'list_all_features': list_all_features,
101+
'invalid_features': invalid_features,
97102
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: Validate requested features
3+
ansible.builtin.assert:
4+
that:
5+
- found_invalid_features | length == 0
6+
fail_msg: |
7+
ERROR: Unknown feature(s) requested: {{ found_invalid_features | join(', ') }}
8+
9+
To remove them, run:
10+
foremanctl deploy {% for feature in found_invalid_features %}--remove-feature={{ feature }} {% endfor %}
11+
12+
Run 'foremanctl features' to list all available features.
13+
vars:
14+
found_invalid_features: "{{ features | invalid_features }}"
15+
when: features | length > 0

src/roles/checks/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- name: Execute checks
33
ansible.builtin.include_tasks: execute_check.yml
44
loop:
5+
- check_features
56
- check_hostname
67
- check_database_connection
78
- check_system_requirements

0 commit comments

Comments
 (0)