Bug #15003
openEnable removing override values from sc-params by specifying --match
Description
When adding an sc-param it is possible to specify a --match for an FQDN/Hostgroup;
> hammer sc-param add-override-value --help Usage: hammer sc-param add-override-value [OPTIONS] Options: --match MATCH Override match --puppet-class PUPPET_CLASS_NAME Puppet class name --puppet-class-id PUPPET_CLASS_ID ID of Puppet class --smart-class-parameter SMART_CLASS_PARAMETER_NAME Smart class parameter name --smart-class-parameter-id SMART_CLASS_PARAMETER_ID --use-puppet-default USE_PUPPET_DEFAULT --value VALUE Override value -h, --help print help
This is not possible with removing the sc-param;
> hammer sc-param remove-override-value --help Usage: hammer sc-param remove-override-value [OPTIONS] Options: --id ID --puppet-class PUPPET_CLASS_NAME Puppet class name --puppet-class-id PUPPET_CLASS_ID ID of Puppet class --smart-class-parameter SMART_CLASS_PARAMETER_NAME Smart class parameter name --smart-class-parameter-id SMART_CLASS_PARAMETER_ID -h, --help print help
This would be especially useful as when you try to re-assign the parameter using Hammer (using add-override-value) it refuses;
Could not create the override_value: Validation failed: Match has already been taken
Updated by Tomáš Strachota over 7 years ago
- Tracker changed from Bug to Feature
- Subject changed from Can't remove a sc-param match using Hammer to Enable removing override values from sc-params by specifying --match
- Description updated (diff)
- Category changed from Foreman commands (obsolete) to Smart variables
- Target version set to 115
- Bugzilla link set to 1465199
Updated by Tomáš Strachota over 7 years ago
Note that at the moment it's possible to use --id to specify which override value to remove:
> hammer sc-param remove-override-value -h Usage: hammer sc-param remove-override-value [OPTIONS] Options: --id ID --puppet-class PUPPET_CLASS_NAME Puppet class name --puppet-class-id PUPPET_CLASS_ID ID of Puppet class --smart-class-parameter SMART_CLASS_PARAMETER_NAME Smart class parameter name --smart-class-parameter-id SMART_CLASS_PARAMETER_ID -h, --help print help > hammer sc-param remove-override-value --smart-class-parameter-id 53 --id 6 Override value deleted
Updated by Jamie Campbell about 7 years ago
- Tracker changed from Feature to Bug
Tomáš Strachota wrote:
Note that at the moment it's possible to use --id to specify which override value to remove:
[...]
This should be a bug, not a feature. And it's a pretty serious bug at that.
If I am able to add an override value to a single host using fqdn matcher with a CLI command, I should be able to reverse that action. Currently it is possible to make thousands of host-specific overrides and then have no way to remove them (except the GUI).
That sort of 'one-way-street' is clearly a bug, and it's a bug that sets people up for disaster.
And to Tomáš Strachota's point, the ID is not helpful here. If I have overridden the same value on multiple hosts, they will all have the same ID number so removing them one host at a time is not possible using ID as my criteria.
Updated by Iain Walmsley about 7 years ago
Just to add to this, this is very much the issue we have. We have implemented (semi-elaborate) ways of caching all ids to get around this functionality at the moment and using them instead but it does complicate things heavily. Seeing the same issue using the API.
Updated by Ondřej Pražák about 5 years ago
- Triaged set to Yes
- Team Backlog deleted (
Marek)
Updated by Kasper Siminski over 1 year ago
Hello,
If anyone else is still trying to remove matchers from smart class parameters here is my workaround:
1) Find ID of smart class parameter:
sc_param_id=$(su -c "psql -qtAX -d foreman -c \" select id from lookup_keys where key='<NAME_OF_SC_PARAM>' ; \" " postgres)
2) Delete matcher for sc param (in this example for fqdn)
su -c "psql -d foreman -c \" delete from lookup_values where match = 'fqdn=<FQDN>' and lookup_key_id = $sc_param_id ; \" " postgres
Hope that it will help someone else.
Kasper.