RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 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 "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". 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 "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-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 2209200 - rhc system role does not apply Insights tags
Summary: rhc system role does not apply Insights tags
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: rhel-system-roles
Version: 9.2
Hardware: All
OS: All
high
low
Target Milestone: rc
: 9.3
Assignee: Rich Megginson
QA Contact: Jakub Haruda
Sagar Dubewar
URL:
Whiteboard: role:rhc
Depends On:
Blocks: 2209441 2214284
TreeView+ depends on / blocked
 
Reported: 2023-05-23 05:16 UTC by Benjamin Blasco
Modified: 2024-03-07 04:25 UTC (History)
12 users (show)

Fixed In Version: rhel-system-roles-1.22.0-0.7.el9
Doc Type: Bug Fix
Doc Text:
.Insights tags created by using the `rhc` role are now applied correctly Previously, when you created Insights tags by using the `rhc` role, tags were not stored in the correct file. Consequently, tags were not sent to Insights and as a result they were not applied to the systems in the Insights inventory. With this fix, tags are stored correctly and applied to the systems present in the Insights inventory.
Clone Of:
: 2209441 2214284 (view as bug list)
Environment:
Last Closed: 2023-11-07 08:29:47 UTC
Type: Bug
Target Upstream Version:
Embargoed:
fkrska: needinfo+
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github linux-system-roles rhc pull 102 0 None open fix: fix filename with insights-client tags 2023-05-23 06:29:44 UTC
Red Hat Issue Tracker RHELPLAN-157891 0 None None None 2023-05-23 05:16:52 UTC
Red Hat Product Errata RHEA-2023:6390 0 None None None 2023-11-07 08:30:09 UTC

Description Benjamin Blasco 2023-05-23 05:16:30 UTC
Description of problem:
Following the documentation outlined below, it is not possible to get the rhc system role to apply Insights tags to a system during registration.  

Following documentation here:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/automating_system_administration_by_using_rhel_system_roles/index#configuring-insights-tags-using-rhc-system-role_using-the-rhc-system-role-to-register-the-system

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

How reproducible:
100% of the time

Steps to Reproduce:
1. Deploy a new RHEL system
2. Run an Ansible playbook containing the following code snippet (or similar):
```
  vars:
    rhc_auth:
      activation_keys:
        keys:
          - "{{ activation_key }}"

    rhc_organization: "{{ organization_id }}"

    rhc_insights:
      state: present
      autoupdate: true
      remediation: present
      tags:
        environment: dev
        location: "au/vic/melbourne"

  tasks:

    - name: Run the RHC role
      include_role:
        name: linux-system-roles.rhc
      tags:
        - rhc

3. Check the tags in the Hybrid Cloud Console inventory here: https://console.redhat.com/insights/inventory/

Actual results:
The registered system(s) do not have any tags set in the Hybrid Cloud Consoleeven though they are defined in the yaml files as shown below:

```
[bblasco@opti rhel]$ ansible 'rhel9*' -m shell -a "cat /etc/insights-client/tags.yml"
rhel92.opti.blasco.id.au | CHANGED | rc=0 >>
environment: dev
location: au/vic/melbourne
rhel91.opti.blasco.id.au | CHANGED | rc=0 >>
environment: dev
location: au/vic/melbourne
```

Expected results:
The registered systems should have the tags defined in the role variables


Additional info:
The (upstream) code snippet turning the variables into yaml for the tags is here: https://github.com/linux-system-roles/rhc/blob/main/tasks/insights-client.yml

```
- name: Add insights tags
  copy:
    dest: /etc/insights-client/tags.yml
    content: "{{ rhc_insights.tags | to_nice_yaml(indent=2) }}"
    mode: '0644'
  register: __insights_tags_added
  when:
    - rhc_insights.tags is defined
    - rhc_insights.tags != __rhc_state_absent
    - rhc_insights.tags | d({}) | length > 0
```

By contrast I have used another insights-client role and successfully added tags to the systems with the hybrid cloud console.  See example below

Code snippet from the RHEL role located at: https://github.com/RedHatInsights/ansible-collections-insights/blob/master/roles/insights_client/tasks/main.yml
```
- name: Deploy Custom Tags
  copy:
    dest: /etc/insights-client/tags.yaml
    content: "{{ insights_tags | to_nice_yaml }}"
    mode: og=r
  become: true
  when: insights_tags is defined
  notify: Run insights-client
```

Example use of the role:
```
  vars:
    insights_tags:
      environment: dev
      #application: web
      location:
        country: au
        state: vic
        city: melbourne
  tasks:
    - name: Run the Insights Client Role
      include_role:
        name: "{{ item }}"
      loop:
        - redhatinsights.insights.insights_client
```

Contents of tags.yaml
```
[bblasco@aap ~]$ cat /etc/insights-client/tags.yaml 
environment: dev
location:
    city: melbourne
    country: au
    state: vic
```
The tags above then appear as the following in the hybrid cloud console:
Name              Value      Tag source
environment       dev        insights-client
location:city     melbourne  insights-client
location:state	  vic        insights-client
location:country  au         insights-client

Comment 2 Benjamin Blasco 2023-05-23 06:17:07 UTC
I have found the issue.

The role is templating out a file called tags.yml when insights expects it to be tags.yaml (YAML not YML).  The code that does this can be found on line 15 here:
https://github.com/linux-system-roles/rhc/blob/main/tasks/insights-client.yml

Comment 3 Pino Toscano 2023-05-23 06:29:44 UTC
(In reply to Benjamin Blasco from comment #2)
> I have found the issue.
> 
> The role is templating out a file called tags.yml when insights expects it
> to be tags.yaml (YAML not YML).  The code that does this can be found on
> line 15 here:
> https://github.com/linux-system-roles/rhc/blob/main/tasks/insights-client.yml

d'oh, thanks!

hopefully easy fix for this: https://github.com/linux-system-roles/rhc/pull/102

Comment 15 errata-xmlrpc 2023-11-07 08:29:47 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 (rhel-system-roles bug fix and enhancement update), 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/RHEA-2023:6390

Comment 16 Red Hat Bugzilla 2024-03-07 04:25:48 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


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