Bug 1465199 - [RFE] Enable removing override values from sc-params by specifying --match
[RFE] Enable removing override values from sc-params by specifying --match
Status: NEW
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Smart Variables (Show other bugs)
Unspecified
All Linux
unspecified Severity medium (vote)
: Unspecified
: --
Assigned To: satellite6-bugs
Katello QA List
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-26 20:24 EDT by jalviso
Modified: 2017-12-24 01:52 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 15003 None None None 2017-06-26 20:38 EDT

  None (edit)
Description jalviso 2017-06-26 20:24:21 EDT
Description of problem:

While it is possible to specify a match for an FQDN or Hostgroup using
"hammer sc-param", it is not possible to specify a match with removing sc-param;

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

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 

Version-Release number of selected component (if applicable): 6.2+

How reproducible: Always

Steps to Reproduce:

1. Identify the smart class parameter id:

# hammer sc-param list
---|--------------------|-----------------------------------------------------|----------|-----------------------
ID | PARAMETER          | DEFAULT VALUE                                       | OVERRIDE | PUPPET CLASS          
---|--------------------|-----------------------------------------------------|----------|-----------------------
20 | template           | motd/motd.erb                                       | true     | motd   

# hammer sc-param remove-override-value --smart-class-parameter-id 20 --match fqdn=rhel7.gsslab.bne.redhat.com

Actual results:

# hammer sc-param remove-override-value --smart-class-parameter-id 20 --match fqdn=rhel7.gsslab.bne.redhat.com
Could not delete the override value:
  Error: Unrecognised option '--match'
  
  See: 'hammer sc-param remove-override-value --help'


Expected results:

The appropriate override should be removed by looking up the FQDN match but there is no available option  "--match MATCH Override match".

Additional info:

It would be useful to have the ability to remove an override via a matcher in the same way it can be added.
Comment 1 jalviso 2017-06-26 20:25:26 EDT
Upstream bugzilla exist with this same issue;

http://projects.theforeman.org/issues/15003
Can't remove a sc-param match using Hammer
Comment 2 Tomas Strachota 2017-06-27 07:32:21 EDT
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
Comment 3 jalviso 2017-06-28 00:49:54 EDT
Hi Tomas,

Thank you for your update.

Here is the customer's reason as to why --match option is useful than specifying --id:

+------------------------------------------------------------------------------+
To give you an idea of why that isn't a useful solution I'll outline what we're trying to achieve.
We use puppet to control who has sudo access on individual hosts. This requires we create a matcher against the fqdn of the host with the appropriate sudo rules as an override to our default set of rules. That works fine. The problem is, Foreman doesn't allow you to replace a fqdn match with a new one, you have to actually remove the match then read it, otherwise foreman throws an error that the match is already taken. Accurately determining which id applies to which match programmatically is very difficult, so its not practical to specify the match we want to remove via id. Instead we need to be able to specify the match via the fqdn of the host. At present we have to manually look at the output from hammer, find the id that matches up to the fqdn we're working with, manually remove it then readd the match. That's not sustainable going forward as we migrate more of our fleet to Satellite 6 and require more complicated and frequently changing sudo rules.
+------------------------------------------------------------------------------+

Regards,

Josephine
Comment 4 Tomas Strachota 2017-06-28 04:07:40 EDT
Thank you for additional info. This is valuable feedback.

As a support for the described workflow we could also add a '--force' option to 'add-override-value' command that would replace the value if the match is found.

Note You need to log in before you can comment on or make changes to this bug.