machine-tags: optionally support key/value pairs as machine tags

Other systems (kubernetes…) allow tagging machines with key/value pairs.
Let's extend our allowed syntax slightly to allow that too. Thankfully,
we enforced a pretty strict ruleset on machine tags, hence we can
introduce this without breaking compatibility.

This basically allows tags to contain "=". If so, then the left-hand
side of it must be unique among machine tags.

When matching against a machine tag, we apply the same rules as before.
This means, that if people want to check if a tag with value applies
they can do:

    ConditionMachineTag=foo=bar

If they just want to check if "foo=" is set to anything, they can use
the usual glob matching:

    ConditionMachineTag=foo=*
This commit is contained in:
Lennart Poettering
2026-06-19 23:05:36 +02:00
parent 4552dce3b5
commit 9afeae5e8a
4 changed files with 83 additions and 9 deletions
+11
View File
@@ -2083,6 +2083,17 @@
negated by prepending an exclamation mark, in which case it is satisfied if none of the configured
tags matches.</para>
<para>Tags may be parameterized with a value in the form
<literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal>; the
<literal>=</literal> and the value are part of the tag and thus part of the string the pattern is
matched against. Hence <literal>ConditionMachineTag=role=webserver</literal> matches the tag
<literal>role=webserver</literal> exactly, <literal>ConditionMachineTag=role=*</literal> matches any
value assigned to the <literal>role</literal> key, and <literal>ConditionMachineTag=role</literal>
(without <literal>=</literal>) does <emphasis>not</emphasis> match <literal>role=webserver</literal>.
See
<citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for the precise syntax of machine tags.</para>
<xi:include href="version-info.xml" xpointer="v261"/>
</listitem>
</varlistentry>