Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-40273

redhat.rhel_system_roles.logging role fails to process logging_outputs: of type: "custom"

    • rhel-system-roles-1.84.1-0.1.el9
    • None
    • ZStream
    • 2
    • rhel-sst-system-roles
    • 1
    • QE ack, Dev ack
    • False
    • Hide

      None

      Show
      None
    • Yes
    • Red Hat Enterprise Linux
    • System Roles Sprint 3, System Roles Sprint 4
    • Approved Blocker
    • Enhancement
    • Hide
      .New variable in the `logging` RHEL system role: `logging_custom_config_files`

      You can provide custom logging configuration files by using the following variable for the `logging` RHEL system role:

      `logging_custom_config_files` (list):: Configures a list of configuration files to copy to the default logging configuration directory. For example, for the `rsyslog` service it is the `/etc/rsyslog.d/` directory. This assumes the default logging configuration loads and processes the configuration files in that directory. The default `rsyslog` configuration has a directive such as `$IncludeConfig /etc/rsyslog.d/*.conf`.

      As a result, you can use customized configurations not provided by the `logging` RHEL system role.

      For more details, see the resources in the `/usr/share/doc/rhel-system-roles/logging/` directory.
      Show
      .New variable in the `logging` RHEL system role: `logging_custom_config_files` You can provide custom logging configuration files by using the following variable for the `logging` RHEL system role: `logging_custom_config_files` (list):: Configures a list of configuration files to copy to the default logging configuration directory. For example, for the `rsyslog` service it is the `/etc/rsyslog.d/` directory. This assumes the default logging configuration loads and processes the configuration files in that directory. The default `rsyslog` configuration has a directive such as `$IncludeConfig /etc/rsyslog.d/*.conf`. As a result, you can use customized configurations not provided by the `logging` RHEL system role. For more details, see the resources in the `/usr/share/doc/rhel-system-roles/logging/` directory.
    • Done
    • None

      What were you trying to do that didn't work?

      Configure custom logging using a config file and playbook.

      How reproducible: 

      Every time

      Steps to reproduce

      1. Provision rhel server

      2. subscribe server and yum update

      3. install ansible and rhel-system-roles

      dnf install rhel-system-roles ansible-core

      4. create playbook

      $ cat playbook.yml 
      ---
      - name: Call rhel_system_roles.logging
        hosts: localhost
        gather_facts: true
        
        tasks:
          - name: Include role
            vars:
              logging_outputs:
                - name: datadog
                  type: custom
                  custom_config_files:
                    - files/rsyslog/datadog.conf
            ansible.builtin.include_role:
              name: redhat.rhel_system_roles.logging

      5. create custom config file

      $ cat files/rsyslog/datadog.conf 
      *.=crit;kern.none /var/adm/critical

      6. run playbook

      $ ansible-playbook --become playbook.yml 

      7. receive error

      Expected results

      customer logging is created

      Actual results

       

      (...)
      TASK [redhat.rhel_system_roles.private_logging_subrole_rsyslog : Include output sub-vars] ***********************************************************************************************************************
      failed: [localhost] (item={'name': 'datadog', 'type': 'custom', 'custom_config_files': ['files/rsyslog/datadog.conf']}) => {"ansible_facts": {}, "ansible_included_var_files": [], "ansible_loop_var": "output_item", "changed": false, "message": "Could not find or access '/usr/share/ansible/collections/ansible_collections/redhat/rhel_system_roles/roles/private_logging_subrole_rsyslog/vars/outputs/custom/main.yml' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option", "output_item": {"custom_config_files": ["files/rsyslog/datadog.conf"], "name": "datadog", "type": "custom"}}
      PLAY RECAP ******************************************************************************************************************************************************************************************************
      localhost                  : ok=27   changed=0    unreachable=0    failed=1    skipped=40   rescued=0    ignored=0   
      

       

      WORKAROUND

      modifying the playbooks resolves the issue

      $ cat playbook.yml 
      ---- name: Call rhel_system_roles.logging
        hosts: localhost
        gather_facts: true
        
        tasks:
          - name: Include role
            vars:
              rsyslog_custom_config_files:    #<---- HERE
                - files/rsyslog/datadog.conf  #<---- HERE
              logging_outputs:
                - name: datadog
                  #type: custom               #<---- HERE                     
                  custom_config_files:
                    - files/rsyslog/datadog.conf
            ansible.builtin.include_role:
              name: redhat.rhel_system_roles.logging

       

              rmeggins@redhat.com Richard Megginson
              jbird@redhat.com Jeffrey Bird
              Richard Megginson Richard Megginson
              David Jez David Jez
              Jaroslav Klech Jaroslav Klech
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved: