Ask Your Question
0

Can you pin a node to a node group with the node classifier API?

asked 2014-12-07 21:38:09 -0500

Can you pin a node to a node group with the node classifier API? I've seen actions for writing additional rules with the API, but can you classify a single specific node to a known group?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-12-09 11:09:08 -0500

reidmv gravatar image

updated 2017-07-10 13:32:12 -0500

UPDATE: starting in PE 2016.1, there now IS an API endpoint that can be used to directly pin and unpin nodes. See the documentation here.

Original Response:

Yes. But there is no specific API call. A "pinned" node is just part of a matching rule.

A node that shows as having been "pinned" to a group in the Node Manager UI is just a convention for displaying a certain kind of rule. Specifically, the Node Manager UI uses the following logic to display rules and pinned nodes.

  • the first element MUST be the "or" bool
  • IF the second elements first element is a bool, AND the second element IS NOT a complex rule, it is the fact rule
  • the remaining elements MUST be ["=", "name", <value>] rules

That last part represents the pinned nodes. If the following Node Group is defined graphically in the Puppet Enterprise 3.7.0 UI:

image description

The JSON for this group, as retrieved from the /v1/groups API endpoint, looks as follows.

{
    "name": "RedHat Linux Servers",
    "id": "a44f2ceb-018e-4f6a-a61c-40f8984c7406",
    "parent": "00000000-0000-4000-8000-000000000000",
    "environment": "production",
    "environment_trumps": false,
    "rule": [
        "or",
        [
            "and",
            [
                "=",
                [
                    "fact",
                    "osfamily"
                ],
                "RedHat"
            ],
            [
                "=",
                [
                    "fact",
                    "kernel"
                ],
                "Linux"
            ]
        ],
        [
            "=",
            "name",
            "ubuntu1404b.syd.puppetlabs.demo"
        ],
        [
            "=",
            "name",
            "ubuntu1404a.pdx.puppetlabs.demo"
        ]
    ],
    "classes": {},
    "variables": {}
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-12-07 21:38:09 -0500

Seen: 514 times

Last updated: Jul 10