Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-25151

Cloudinit default template generates invalid YAML data due to the new subscription_manager_setup snippet

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 6.15.0
    • Provisioning Templates
    • None
    • 0
    • False
    • Hide

      None

      Show
      None
    • False
    • CLOSED
    • 0
    • Rocket
    • Critical
    • True

      Description of problem:

      As a part of https://bugzilla.redhat.com/show_bug.cgi?id=2153548, katello-ca-consumer was replaced with "Global Registration" method and the new snippets and changes with templates, landed in Satellite 6.15.0

      While everything else is fine, It seems

      The cloud-init default template calls for

      • <%= indent(2)

        { snippet 'redhat_register' }

        -%>

      And then this redhat_register snippet calls for another snippet to configure the rhsm.conf on the target host i.e.

      <%= snippet("subscription_manager_setup", variables:

      { subman_setup_scenario: 'provisioning' }

      ).strip -%>

      I believe the problem lies with the data generated by subscription_manager_setup snippet and somehow, even though we add "indent(2)" while calling redhat_register snippet, The whole YAML preview generated for the "Cloudinit Default" template ends up with a broken YAML syntax and indentation.

      This is a regression.

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

      Satellite 6.15.0

      How reproducible:

      Always

      Steps to Reproduce:

      1. Install a Satellite 6.15

      2. Configure it as per https://access.redhat.com/documentation/en-us/red_hat_satellite/6.15/html-single/provisioning_hosts/index#Using_VMware_Cloud_Init_and_Userdata_Templates_for_Provisioning_vmware-provisioning to deploy a RHEL 8.9 or 9.3 system

      3. Once the build is submitted for a VM, Access the VM console, wait for some time, and then check the cloudinit-related logs.

      Actual results:

      In step 3, After cloud-init fetched the rendered version of the "Cloudinit default" template from satellite, It tried to validate the file content and failed to validate it as a good YAML formatted content to use.

      Due to the same, no post-provisioning steps were executed and the system remained in build mode without getting registered with satellite at all.

      Log errors:

      2024-05-14 19:12:54,549 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 3 column 1: "while parsing a block mapping
      in "<unicode string>", line 3, column 1:
      hostname: testud.example.com ...
      ^
      expected <block end>, but found '<scalar>'
      in "<unicode string>", line 45, column 3:
      if [ -z "$PKG_MANAGER" ]; then
      ^"
      2024-05-14 19:12:54,714 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 3 column 1: "while parsing a block mapping
      in "<unicode string>", line 3, column 1:
      hostname: testud.example.com ...
      ^
      expected <block end>, but found '<scalar>'
      in "<unicode string>", line 45, column 3:
      if [ -z "$PKG_MANAGER" ]; then
      ^"
      2024-05-14 19:12:54,714 - cloud_config.py[WARNING]: Failed at merging in cloud config part from part-001: empty cloud config
      Generating public/private rsa key pair.


      1. cat /var/log/cloud-init.log | grep "Failed loading yaml blob" -A10 -B5
        2024-05-14 19:12:54,543 - handlers.py[DEBUG]: finish: init-network/setup-datasource: SUCCESS: setting up datasource
        2024-05-14 19:12:54,543 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/i-2a79f1412094587348/user-data.txt - wb: [600] 9897 bytes
        2024-05-14 19:12:54,544 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-2a79f1412094587348/user-data.txt (recursive=False)
        2024-05-14 19:12:54,545 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-2a79f1412094587348/user-data.txt (recursive=False)
        2024-05-14 19:12:54,545 - util.py[DEBUG]: Attempting to load yaml from string of length 9897 with allowed root types (<class 'dict'>,)
        2024-05-14 19:12:54,549 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 3 column 1: "while parsing a block mapping
        in "<unicode string>", line 3, column 1:
        hostname: testud.example.com ...
        ^
        expected <block end>, but found '<scalar>'
        in "<unicode string>", line 45, column 3:
        if [ -z "$PKG_MANAGER" ]; then
        ^"
        2024-05-14 19:12:54,589 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/i-2a79f1412094587348/user-data.txt.i - wb: [600] 10202 bytes
        2024-05-14 19:12:54,591 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-2a79f1412094587348/user-data.txt.i (recursive=False)
        2024-05-14 19:12:54,593 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-2a79f1412094587348/user-data.txt.i (recursive=False)

        2024-05-14 19:12:54,707 - _init.py[DEBUG]: Calling handler BootHookPartHandler: [['text/cloud-boothook']] (begin_, None, 2) with frequency once-per-instance
        2024-05-14 19:12:54,707 - _init.py[DEBUG]: Calling handler JinjaTemplatePartHandler: [['text/jinja2']] (begin_, None, 3) with frequency once-per-instance
        2024-05-14 19:12:54,707 - _init_.py[DEBUG]: {'MIME-Version': '1.0', 'Content-Type': 'text/cloud-config', 'Content-Disposition': 'attachment; filename="part-001"'}

        2024-05-14 19:12:54,707 - _init_.py[DEBUG]: Calling handler CloudConfigPartHandler: [['text/cloud-config', 'text/cloud-config-jsonp']] (text/cloud-config, part-001, 3) with frequency once-per-instance
        2024-05-14 19:12:54,707 - util.py[DEBUG]: Attempting to load yaml from string of length 9897 with allowed root types (<class 'dict'>,)
        2024-05-14 19:12:54,714 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 3 column 1: "while parsing a block mapping
        in "<unicode string>", line 3, column 1:
        hostname: testud.example.com ...
        ^
        expected <block end>, but found '<scalar>'
        in "<unicode string>", line 45, column 3:
        if [ -z "$PKG_MANAGER" ]; then
        ^"
        2024-05-14 19:12:54,714 - cloud_config.py[WARNING]: Failed at merging in cloud config part from part-001: empty cloud config
        2024-05-14 19:12:54,714 - _init.py[DEBUG]: Calling handler CloudConfigPartHandler: [['text/cloud-config', 'text/cloud-config-jsonp']] (end_, None, 3) with frequency once-per-instance
        2024-05-14 19:12:54,716 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/i-2a79f1412094587348/cloud-config.txt - wb: [600] 77 bytes

      Expected results:

      No such errors should happen and the build should be successful.

      Additional info:

      This is a regression due to https://bugzilla.redhat.com/show_bug.cgi?id=2153548 in Sat 6.15

            rh-ee-nalfassi Nofar Alfassi
            jira-bugzilla-migration RH Bugzilla Integration
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: