Bug 1741187

Summary: Can create duplicate ansible variables for one role
Product: Red Hat Satellite Reporter: Lukas Pramuk <lpramuk>
Component: Ansible - Configuration ManagementAssignee: Ondřej Pražák <oprazak>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: oprazak, zhunting
Target Milestone: 6.6.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman_ansible-3.0.7.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-22 19:50:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lukas Pramuk 2019-08-14 13:17:59 UTC
Description of problem:
I can create duplicate ansible variables of the same name for the same role.
These duplicates can be of different types

Duplicates shouldn't be allowed similarly to puppet classes

Version-Release number of selected component (if applicable):
Satellite-6.6.0 Snap14

How reproducible:
deterministic

Steps to Reproduce:
1. Import ansible roles: 
# hammer ansible roles import --proxy-id 1

2. Create ansible variable "my_var" assigned to "theforeman.foreman_scap_client" role:
# hammer ansible variables create --variable my_var --variable-type string --ansible-role theforeman.foreman_scap_client
Ansible variable [my_var] was created.

3. Try to create variable of the same name once again:
# hammer ansible variables create --variable my_var --variable-type boolean --ansible-role theforeman.foreman_scap_client
Ansible variable [my_var] was created.


Actual results:
# hammer ansible variables list --search name=my_var
---|----------|---------------|---------|-------------------------------
ID | VARIABLE | DEFAULT VALUE | TYPE    | ROLE                          
---|----------|---------------|---------|-------------------------------
28 | my_var   |               | boolean | theforeman.foreman_scap_client
27 | my_var   |               | string  | theforeman.foreman_scap_client
---|----------|---------------|---------|-------------------------------

>>> duplicate vars for one role are allowed

Expected results:
2nd "my_var" creation fails with something like
"Validation failed: my_var for the role already exists"

Comment 4 Ondřej Pražák 2019-08-20 06:46:20 UTC
Created redmine issue https://projects.theforeman.org/issues/27663 from this bug

Comment 5 Bryan Kearney 2019-08-20 08:00:24 UTC
Upstream bug assigned to oprazak

Comment 6 Bryan Kearney 2019-08-20 08:00:26 UTC
Upstream bug assigned to oprazak

Comment 7 Lukas Pramuk 2019-09-27 12:21:27 UTC
VERIFIED.

@Satellite 6.6.0 Snap21
tfm-rubygem-foreman_ansible-3.0.7.1-1.el7sat.noarch

by the reproducer described in comment#0:

# hammer ansible roles import --proxy-id 1
Result:   
  The following ansible roles were changed
Imported: 
 1) RedHatInsights.insights-client
 2) theforeman.foreman_scap_client

# hammer ansible variables create --variable my_var --variable-type string --ansible-role theforeman.foreman_scap_client
Ansible variable [my_var] was created.

# hammer ansible variables create --variable my_var --variable-type boolean --ansible-role theforeman.foreman_scap_client
Could not create the ansible variable:
  Key has already been taken

>>> duplicate ansible vars for a role are no longer allowed

Comment 8 Bryan Kearney 2019-10-22 19:50:36 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, 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-2019:3172