Skip to content

node_group function and node_group resource are inconsistent #92

@bastelfreak

Description

@bastelfreak

Describe the Bug

From https://www.puppet.com/docs/pe/2023.7/groups_endpoint#get_v1_groups-get-v1-groups-response-format:

The classifier API endpoint /v1/groups has different attributes per group. One is config_data. We can verify this on PE 2019/2021/2023:

cert="$(puppet config print hostcert)"
cacert="$(puppet config print localcacert)"
key="$(puppet config print hostprivkey)"
uri="https://$(puppet config print server):4433/classifier-api/v1/groups"
curl --silent --header "$type_header" --cert "$cert" --cacert "$cacert" --key "$key" "$uri" | jq '.[] | select(.name=="PE Master")'

Which gives us:

{
  "parent": "e60ebca5-1cc0-44da-93d8-53a91d2ff448",
  "environment_trumps": false,
  "name": "PE Master",
  "rule": [
    "or",
    [
      "and",
      [
        "=",
        [
          "trusted",
          "extensions",
          "pp_auth_role"
        ],
        "pe_compiler"
      ]
    ],
    [
      "=",
      "name",
      "pe.tim.betadots.training"
    ]
  ],
  "variables": {
    "pe_master": true
  },
  "id": "0588e587-f8e6-446d-98b1-fe5ce24bd513",
  "environment": "production",
  "last_edited": "2024-07-19T10:53:20.184Z",
  "serial_number": 6,
  "classes": {
    "pe_repo": {},
    "pe_repo::platform::el_8_x86_64": {},
    "pe_repo::platform::windows_x86_64": {},
    "pe_repo::platform::windowsfips_x86_64": {},
    "puppet_enterprise::profile::master": {
      "replication_mode": "none"
    }
  },
  "config_data": {
    "puppet_enterprise::profile::master": {
      "code_manager_auto_configure": true,
      "r10k_remote": "https://github.com/bastelfreak/testcontrolrepo"
    },
    "pe_repo": {
      "compile_master_pool_address": "pe.tim.betadots.training"
    }
  }
}

but:

# puppet resource node_group 'PE Master'
node_group { 'PE Master':
  ensure               => 'present',
  classes              => {
  'pe_repo' => {

  },
  'pe_repo::platform::el_8_x86_64' => {

  },
  'pe_repo::platform::windows_x86_64' => {

  },
  'pe_repo::platform::windowsfips_x86_64' => {

  },
  'puppet_enterprise::profile::master' => {
    'replication_mode' => 'none'
  }
},
  data                 => {
  'pe_repo' => {
    'compile_master_pool_address' => 'pe.tim.betadots.training'
  },
  'puppet_enterprise::profile::master' => {
    'code_manager_auto_configure' => true,
    'r10k_remote' => 'https://github.com/bastelfreak/testcontrolrepo'
  }
},
  environment          => 'production',
  id                   => '0588e587-f8e6-446d-98b1-fe5ce24bd513',
  override_environment => 'false',
  parent               => 'PE Infrastructure',
  provider             => 'https',
  rule                 => ['or',
  ['and',
    ['=',
      ['trusted', 'extensions', 'pp_auth_role'],
      'pe_compiler']],
  ['=', 'name', 'pe.tim.betadots.training']],
  variables            => {
  'pe_master' => true
},
}

It's inconsistent. The node_group resource type uses data. The node_group() function uses config_data. I've scenarios where we use the node_group() function to get information about a group, modify it, write it back. This gets a bit complicated when function and resource type aren't consistent.

Expected Behavior

A clear and concise description of what you expected to happen.

Steps to Reproduce

See above.

Environment

  • PE 2019/2021/2023
  • puppetlabs/node_manager v1.0.1

Additional Context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions