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
Also worth noting that there's an indentation discrepancy between the documentation on the tags in the following two locations: https://github.com/linux-system-roles/rhc vs. 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
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
(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