Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1883503 - Unable to set "override-value-order" for ansible variable via hammer CLI in Red Hat Satellite 6
Summary: Unable to set "override-value-order" for ansible variable via hammer CLI in R...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible - Configuration Management
Version: 6.7.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: 6.10.0
Assignee: satellite6-bugs
QA Contact: Danny Synk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-29 12:22 UTC by Sayan Das
Modified: 2021-11-16 14:09 UTC (History)
8 users (show)

Fixed In Version: tfm-rubygem-hammer_cli_foreman_ansible-0.3.3
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 14:09:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 30976 0 Normal Closed Unable to set "override-value-order" for ansible variable via hammer CLI 2021-07-28 17:23:33 UTC
Red Hat Product Errata RHSA-2021:4702 0 None None None 2021-11-16 14:09:35 UTC

Description Sayan Das 2020-09-29 12:22:14 UTC
Description of problem:

The hammer command to set "override-value-order" sets the order of multiple attributes in a string format rather than setting them in the ORDER specified for any ansible variables.


Version-Release number of selected component (if applicable):
Red Hat Satellite 6.7

How reproducible:
Always.

Steps to Reproduce:
1. Import an ansible role on satellite server with custom variable my_role.

2. Check the information about that variable and note down the order and ID.
   # hammer ansible variables info --name "my_role"

3. Try to set the order in which values are resolved for that variable.
   # hammer ansible variables update --ansible-role motd --variable my_role --override-value-order "hostgroup fqdn os domain" --variable-type string --default-value 'Admin' --override true  --id XX

4. Repeat step 2.


Actual results:

At step 2,
~~
# hammer ansible variables info --name "my_role"
Id:              91
Variable:        my_role
Default Value:   Admin
Type:            string
Role:            motd
Description:     
Hidden Value?:   yes
Validator:       
    Type: 
    Rule:
Override values: 
    Override:            no
    Merge overrides:     no
    Merge default value: no
    Avoid duplicates:    no
    Order:               
      fqdn
      hostgroup
      os
      domain
    Values:
Created at:      2020/09/29 11:57:56
Updated at:      2020/09/29 11:57:56
~~


At Step 4 i.e. after update,
~~
# hammer ansible variables info --name "my_role"
Id:              91
Variable:        my_role
Default Value:   Admin
Type:            string
Role:            motd
Description:     
Hidden Value?:   yes
Validator:       
    Type: 
    Rule:
Override values: 
    Override:            yes
    Merge overrides:     no
    Merge default value: no
    Avoid duplicates:    no
    Order:               
      hostgroupfqdnosdomain
    Values:
Created at:      2020/09/29 11:57:56
Updated at:      2020/09/29 12:15:30
~~


Expected results:

It should be able to set the ORDER properly rather than accepting the values passed as a simple string.


Additional info:

1. Even if we try with CSV\ARRAY format to pass the value for "--override-value-order" , that will accept the value as it is and print it.

   Tried following.
    * hostgroup\nfqdn\nos\ndomain
    * hostgroup\\nfqdn\\nos\\ndomain
    * hostgroup,fqdn,os,domain
    * hostgroup, fqdn, os, domain

2. For puppet variables the issue is not present. As per code for smart_variables, I can see that it processes the value correctly.

~~
    def request_params
      params = super
      override_order = params['smart_variable']['override_value_order']
      params['smart_variable']['override_value_order'] = override_order.join("\n") if override_order.is_a?(Array)
      params
    end
  end
~~
 
   --> But i couldn't find any similar code for the ansible_variables

Comment 1 Shira Maximov 2020-10-05 11:39:08 UTC
Created redmine issue https://projects.theforeman.org/issues/30976 from this bug

Comment 3 Bryan Kearney 2021-06-08 12:06:01 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30976 has been resolved.

Comment 5 Danny Synk 2021-09-28 15:24:38 UTC
Verified on Satellite 6.10, snap 20 (tfm-rubygem-hammer_cli_foreman_ansible-0.3.4-1.el7sat.noarch).

Steps to Test:
1. Import an Ansible role to Satellite 6.10.
2. Create a new Ansible variable assigned to the role imported in step 1.
3. Check the current override value order for the new Ansible variable:

~~~
# hammer ansible variables info --name "my_role"
Id:              24
Variable:        my_role
Default Value:   Admin
Type:            string
Role:            theforeman.foreman_scap_client
Description:     
Hidden Value?:   no
Validator:       
    Type: 
    Rule:
Override values: 
    Override:            yes
    Merge overrides:     no
    Merge default value: no
    Avoid duplicates:    no
    Order:               
      fqdn
      hostgroup
      os
      domain
    Values:
Created at:      2021/09/28 15:03:29
Updated at:      2021/09/28 15:04:28
~~~

4. Modify the override value order for the variable using hammer:

# hammer ansible variables update --ansible-role theforeman.foreman_scap_client --variable my_role --override-value-order "hostgroup, fqdn, os, domain" --variable-type string --default-value 'Admin' --override true --id 24

5. Check the override value order for the variable again:

~~~
# hammer ansible variables info --name "my_role"
Id:              24
Variable:        my_role
Default Value:   Admin
Type:            string
Role:            theforeman.foreman_scap_client
Description:     
Hidden Value?:   no
Validator:       
    Type: 
    Rule:
Override values: 
    Override:            yes
    Merge overrides:     no
    Merge default value: no
    Avoid duplicates:    no
    Order:               
      hostgroup
      fqdn
      os
      domain
    Values:
Created at:      2021/09/28 15:03:29
Updated at:      2021/09/28 15:10:25
~~~

Note:
- It is necessary to use comma-separated values (e.g. `hostgroup, fqdn, os, domain` or `hostgroup,fqdn,os,domain`) as the arguments for the `--override-value-order` parameter when modifying the order. When using spaces or newline characters, the arguments are concatenated into a single string as reported in the description of this bug.

Comment 8 errata-xmlrpc 2021-11-16 14:09:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.10 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:4702


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