Page MenuHomePhabricator

improve host select for puppet compiler
Closed, ResolvedPublic

Description

The puppet compiler currently allows you to specify a regex in the nodes filed using the format R:${regex}. it would be useful if we could also specify hosts using the cumin query language. At the very least it would be useful to run on all hosts with a specific role/class/resource which could be done by querying the local puppetdb api directly but i wonder if we could leverage the query syntax already available in puppet.

@Volans is cumin worth exploring or should we just query puppetdb?

Event Timeline

jbond updated the task description. (Show Details)
jbond updated the task description. (Show Details)

@jbond I'm not sure, depends on the current status of the puppet compiler. To my understanding it doesn't have a fully populated PuppetDB but we import only the facts, so I'm not sure to which queries we would be limited, and the difference might be weird as only some queries will work and others not.

From the technical point of view, assuming a working PuppetDB that's totally doable adding Cumin as a dependency (deb package or venv), add its configuration file and then use it with:

import cumin

from cumin import query

config = cumin.Config()
hosts = query.Query(config).execute(query_param_from_jenkins)
# hosts here is a ClusterShell NodeSet() but can be iterated or converted to list at will

Until I release a new Cumin version there might be a small trick required, feel free to ping me if you're doing it.

@Volans The puppetdb on the compilers doesn't have all hosts but i think the data it has is complete i.e. it has catalogues, reports, facts and exported resources but it could still be limited in some way. We probably don't need to support the full cumin syntax but might make sense to use it on the backend regardless. ill have a play and see where it get. cheers

Change 579579 had a related patch set uploaded (by Jbond; owner: John Bond):
[operations/software/puppet-compiler@master] pick_nodes: add ability to pick nodes based on a puppet class

https://gerrit.wikimedia.org/r/579579

Change 579579 merged by Jbond:
[operations/software/puppet-compiler@master] pick_nodes: add ability to pick nodes based on a puppet class

https://gerrit.wikimedia.org/r/579579

Change 651800 had a related patch set uploaded (by Jbond; owner: John Bond):
[operations/software/puppet-compiler@master] nodegen: add cumin support

https://gerrit.wikimedia.org/r/651800

Change 651800 merged by jenkins-bot:
[operations/software/puppet-compiler@master] nodegen: add cumin support

https://gerrit.wikimedia.org/r/651800