puppetlabs / puppetlabs-node_manager

Create and manage PE node groups as resources.
Apache License 2.0
10 stars 21 forks source link

'puppet resource node_group' generates code that violates PE 2021 schema #63

Open kreeuwijk opened 3 years ago

kreeuwijk commented 3 years ago

When using puppet resource node_group to generate Puppet code for existing node groups, creating node groups on PE 2021 from this code fails due to 2 schema violations:

Either issue causes the Puppet run to fail with: node_manager failed with error type 'schema-violation': The object(s) in your submitted request did not conform to the schema. The problem is: ([:rule "The rule is malformed. Please consult the group documentation for details on the rule grammar."])

Manual modification is currently needed to convert the string values to booleans, and to remove any occurrence of rule => [''].

Desired behavior:

vchepkov commented 3 years ago

I experience similar issue in PE2019, environmental group is not idempotent:

node_group { 'All Environments':
  ensure               => 'present',
  description          => 'Environment group parent and default',
  environment          => 'default_production',
  override_environment => 'true',
  parent               => 'All Nodes',
  rule                 => ['and',['~', 'name', '.*']],
}

# puppet apply env.pp 
Notice: Compiled catalog for primary.localdomain in environment production in 0.02 seconds
Notice: /Stage[main]/Main/Node_group[All Environments]/override_environment: override_environment changed 'true' to true
Notice: Applied catalog in 0.43 seconds
tyler-francis-nih commented 3 years ago

Using Node Manager with PE 2021 usually works, but creating a not rule with != or with !~ causes a schema error. For example: ["!=", ["fact", "key"], "value"] causes:

Error: node_manager failed with error type 'schema-violation': The object(s) in your submitted request did not conform to the schema. The problem is: ([:rule [nil nil (not (some-matching-condition? a-clojure.lang.PersistentVector))]])

WhatsARanjit commented 3 years ago

My understanding was the RAL always prints Booleans as Strings?

# puppet resource service puppet
service { 'puppet':
  ensure   => 'stopped',
  enable   => 'false',
  provider => 'launchd',
}

If there's a way to enforce a Boolean, I'd be happy to look at an example. I have marked this property as a Boolean here: https://github.com/WhatsARanjit/puppet-node_manager/blob/master/lib/puppet/type/node_group.rb#L21

TJM commented 1 year ago

I almost feel like that may be the problem. No matter whether we put 'true' or true as the value, we get a corrective change like:

/Stage[main]/Profile::Puppet::Classifier/Node_group[Agent-Specified Environment]/override_environment: override_environment changed 'true' to true (corrective)

I would prefer it was treated as a boolean, but apparently whatever is returning the current value is thinking it is a string?

vchepkov commented 1 year ago

this was probably fixed by #67, any chance for a new release, @WhatsARanjit ? thanks

rwaffen commented 1 year ago

@WhatsARanjit may we have a new forge release pls? 😃