Skip to content

List enabled and available features#404

Open
arvind4501 wants to merge 1 commit intotheforeman:masterfrom
arvind4501:features
Open

List enabled and available features#404
arvind4501 wants to merge 1 commit intotheforeman:masterfrom
arvind4501:features

Conversation

@arvind4501
Copy link
Contributor

This implemets listing of available and enabled features, with old foreman-installer there was no good way to list all availabe features then doing foreman-installer --full-help which comes up with lot of puppet module args listed.

Here we have features.yml as source of truth for features listing. I did not like how ansible playbook outputs directly for listing features(it creates a lot of noise), i want it to be like systemctl so i have created a PR in obsah which allows bypassing ansible playbook execution and runs scripts directly(a hack to get nice output, maybe can be better).

This is how it will show the result

./foremanctl features

FEATURE                   STATE        BASE                 DESCRIPTION
katello                   enabled      foreman              Katello content management
remote_execution          enabled      foreman,proxy        Foreman Remote Execution support
azure_rm                  available    foreman              Azure Resource Manager integration
google                    available    foreman              Google Compute Engine integration

This PR lays out my initial thought of solving features listing.

It requires: PR

@arvind4501
Copy link
Contributor Author

Currently This Does not list the BASE features which are hammer, foreman-proxy, foreman

@arvind4501 arvind4501 requested a review from evgeni March 10, 2026 10:50
@ehelms
Copy link
Member

ehelms commented Mar 10, 2026

Is there any to make use of callback_result_format just for this command to format the results the way you'd want to the user? Just a curious question, I can see how this might be useful for some additional things in the future.

In the results, what does the BASE column represent?

@ehelms
Copy link
Member

ehelms commented Mar 10, 2026

Colors can sometimes be a pain, this would enforce colors even if Ansible is configured with no colors. I think we either should skip colors or be consistent with Ansible's configuration.

@arvind4501
Copy link
Contributor Author

Is there any to make use of callback_result_format just for this command to format the results the way you'd want to the user? Just a curious question, I can see how this might be useful for some additional things in the future.

I was not much aware about available callback plugins, but now that you mentioned it, i see that there are builtin plugins which i tried and they does not give our expected output format(if i did not missed anything), we might need to create a custom plugin for that but not sure if we should?

My thought here was that what if i need a custom script to run at some point from foremanctl and i did not find a way to do so, and that made me do theforeman/obsah#105,

In the results, what does the BASE column represent?

This was taken from https://github.com/theforeman/foremanctl/blob/master/src/filter_plugins/foremanctl.py#L7 , where we define BASE_FEATURES(which can have plugins on top of that). So here BASE represent that a feature is a plugin for which BASE_FEATURE. i was expecting this question while deciding what should be the column name and ended up using BASE which i think is confusing and should be better

@arvind4501
Copy link
Contributor Author

arvind4501 commented Mar 11, 2026

Colors can sometimes be a pain, this would enforce colors even if Ansible is configured with no colors. I think we either should skip colors or be consistent with Ansible's configuration.

I agree, colors should be consistent, thanks

@arvind4501 arvind4501 requested a review from stejskalleos March 11, 2026 05:28
@stejskalleos stejskalleos self-assigned this Mar 11, 2026
STATE_DIR = pathlib.Path(os.environ.get('OBSAH_STATE', '.var/lib/foremanctl'))


def load_yaml(path: pathlib.Path) -> dict:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file does not exist, it's a bug; we should raise an error.
Or do we expect it to be missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that features.yml must exist as thats where all metadata lives. In

FEATURE_MAP = yaml.safe_load(features_file)

We don't have try and except so i think it can be removed here, i will update that

@@ -0,0 +1,5 @@
---
help: |
List all enabled and available features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my completely fresh installation, where I haven't run deploy command yet, the output of the features command is nothing:

dnf install -y foremanctl-1.2.0-1.20260310092525087654.pr404.20.g4464b74.el9.noarch
Last metadata expiration check: 0:02:05 ago on Wed 11 Mar 2026 08:10:46 AM UTC.
Package foremanctl-1.2.0-1.20260310092525087654.pr404.20.g4464b74.el9.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@stream9 vagrant]# 
[root@stream9 vagrant]# foremanctl --help
usage: foremanctl [-h] action ...

positional arguments:
  action       which action to execute
    checks     Run preflight checks before installing Foreman
    deploy     Install
    features   List all enabled and available features
    pull-images
               Pull necessary container images

optional arguments:
  -h, --help   show this help message and exit
[root@stream9 vagrant]# foremanctl features

PLAY [List features] ******************************************************************************************

TASK [Gathering Facts] ****************************************************************************************
ok: [localhost]

PLAY RECAP ****************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[root@stream9 vagrant]#

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats because you need theforeman/obsah#105 for features to work

for name in sorted(all_features.keys()):
meta = all_features[name] or {}

# Skip internal features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a flag (--show-internals) for the command so I can list internal features as well?
By default, it can be disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants