Skip to content

Commit d1d5c84

Browse files
committed
fix(plan): break long yq command into multiple lines for readability
- Split the yq command string into multiple lines - Use string concatenation to maintain command integrity
1 parent dcaaf36 commit d1d5c84

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

spec/acceptance/peadm_spec/plans/add_inventory_hostnames.pp

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
$t = get_targets('*')
55
wait_until_available($t)
66

7-
await(
7+
$fqdn_results = await(
88
parallelize($t) |$target| {
99
$fqdn = run_command('hostname -f', $target)
10-
$target.set_var('certname', $fqdn.first['stdout'].chomp)
11-
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${target.uri}\").name) = \"${target.vars['certname']}\"' -i ${inventory_file}"
12-
run_command($command, 'localhost')
10+
$target.set_var('certname', $fqdn.first['stdout'].chomp) { 'uri' => $target.uri, 'certname' => $target.vars['certname'] }
1311
}
1412
)
13+
14+
$fqdn_results.each |$result| {
15+
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${result.target.uri}\").name) = \"${result.value}\"' -i ${inventory_file}"
16+
run_command($command, 'localhost')
17+
}
1518
notify { 'Inventory updated': }
1619
}

0 commit comments

Comments
 (0)