You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Route hosts to instance groups from an inventory variable
In deployments with several isolated network zones, each zone has its
own execution nodes grouped in an instance group, because firewalls only
let those nodes reach the hosts of their zone. A job runs on a single
instance group, so the same baseline template (sysctl, users, patching)
has to be duplicated per zone with a different limit and instance group.
This adds an instance_group_routing_var field to job templates: the name
of an inventory variable (usually a group var) whose value names the
instance group each host should run on. At launch, hosts are grouped by
the resolved value and the launch creates the same implicit workflow job
that sliced jobs use, with one node per bucket: each job runs restricted
to its bucket's hosts and assigned to the routed instance group. Hosts
that do not resolve the variable run in an extra job with the normal
instance group selection, and if everything lands in one bucket a plain
job is launched on it. Resolution follows a simplified version of the
Ansible precedence rules (host vars win, then groups by depth, priority
and name) and only considers enabled hosts.
Instance groups are protected by RBAC and the routing variable is
inventory data, so it is not trusted blindly: the launch endpoint checks
the launching user's use permission on every referenced instance group,
the same rule already applied to instance groups prompted at launch, and
unknown names reject the launch instead of falling back silently. The
validated buckets are handed to the job creation so the launch routes to
exactly what was checked. The same checks run again when relaunching a
routed workflow, which recomputes the buckets from current inventory
data. Routing is mutually exclusive with job slicing (also when the
slice count is prompted at launch), prompting instance groups overrides
it, and provisioning callbacks never route, like they never slice.
Launch paths without a requesting user stay loud but safe when a routing
value names a missing instance group: a workflow containing the routed
template is marked failed with the reason instead of crashing the
workflow manager cycle, webhook launches answer 400, and relaunching a
routed child job keeps targeting its original bucket even if the
template's routing variable changed since.
Refs #566
help_text='Name of an inventory variable used to route hosts to instance groups at launch. When set, hosts are grouped by the value of this variable (host variables win over group variables) and the launch spawns one job per group, restricted to its hosts and assigned to the instance group named by the value. Hosts without the variable run in an extra job with the normal instance group selection. Launch fails if a value does not name an existing instance group or the launching user lacks use permission on it. Cannot be combined with job slicing.',
20
+
max_length=1024,
21
+
),
22
+
),
23
+
migrations.AddField(
24
+
model_name='jobtemplate',
25
+
name='instance_group_routing_var',
26
+
field=models.CharField(
27
+
blank=True,
28
+
default='',
29
+
help_text='Name of an inventory variable used to route hosts to instance groups at launch. When set, hosts are grouped by the value of this variable (host variables win over group variables) and the launch spawns one job per group, restricted to its hosts and assigned to the instance group named by the value. Hosts without the variable run in an extra job with the normal instance group selection. Launch fails if a value does not name an existing instance group or the launching user lacks use permission on it. Cannot be combined with job slicing.',
30
+
max_length=1024,
31
+
),
32
+
),
33
+
migrations.AddField(
34
+
model_name='job',
35
+
name='instance_group_routing_value',
36
+
field=models.TextField(
37
+
default=None,
38
+
editable=False,
39
+
help_text="If created by instance group routing, the routing variable value that selected this job's bucket of hosts. An empty string means the bucket of hosts that do not resolve the variable. Null when the job was not routed.",
0 commit comments