Closed Sharpie closed 7 years ago
Starting here.
# puppet resource node_group 'Canary group'
node_group { 'Canary group':
ensure => 'present',
classes => {'test_module' => {'foo' => 'hi'}},
description => 'testing new version',
environment => 'testing',
id => '8a38e581-be84-4c96-8c89-68351e6561a0',
override_environment => 'true',
parent => 'All Nodes',
}
Trying curl:
# /usr/bin/curl -s -X POST \
> --cert $(puppet config print hostcert) \
> --key $(puppet config print hostprivkey) \
> --cacert $(puppet config print cacert) \
> -H "Content-Type: application/json" \
> -X POST --data '{ "classes": { "test_module": {} } }' \
> https://$(puppet config print server):4433/classifier-api/v1/groups/8a38e581-be84-4c96-8c89-68351e6561a0
{"description":"testing new version","parent":"00000000-0000-4000-8000-000000000000","environment_trumps":true,"name":"Canary group","variables":{},"id":"8a38e581-be84-4c96-8c89-68351e6561a0","environment":"production","classes":{"test_module":{"foo":"hi"}}}
Doesn't update it.
Ok so POST
ing a null
seems to obliterate the classes
hash?
# /usr/bin/curl -s -X POST \
> --cert $(puppet config print hostcert) \
> --key $(puppet config print hostprivkey) \
> --cacert $(puppet config print cacert) \
> -H "Content-Type: application/json" \
> --data '{ "classes": { "test_module": null } }' \
> https://$(puppet config print server):4433/classifier-api/v1/groups/8a38e581-be84-4c96-8c89-68351e6561a0
{"description":"testing new version","parent":"00000000-0000-4000-8000-000000000000","environment_trumps":true,"name":"Canary group","variables":{},"id":"8a38e581-be84-4c96-8c89-68351e6561a0","environment":"production","classes":{}}
# puppet resource node_group 'Canary group'
node_group { 'Canary group':
ensure => 'present',
description => 'testing new version',
environment => 'production',
id => '8a38e581-be84-4c96-8c89-68351e6561a0',
override_environment => 'true',
parent => 'All Nodes',
}
Yeah, POSTing a null for the params hash will take out an entire class. POSTing a null for a specific parameter should delete only that parameter:
The classes and variables keys of the delta will be merged with the node group, and then any keys of the resulting object that have a null value will be deleted. This allows you to remove classes, class parameters, or variables from the node group by setting them to null in the delta
https://docs.puppet.com/pe/latest/nc_groups.html#post-v1groupsid
Merged #29
Tried a couple ways of removing a parameter from the "PE Infrastructure" node:
Result:
mcollective_middleware_hosts
parameter is set to the string "undef".Node manager produces a message indicating that all parameters are being removed from the group:
But, no change actually happens.
Not sure the second one should work, but it would be nice to have a way of explicitly removing a parameter from a class in a node group.