Skip to content

Commit 11d0b54

Browse files
committed
fix(plan): replace await with wait in add_inventory_hostnames
- Change await to wait for better compatibility and readability - Ensure all tasks complete before proceeding with the plan
1 parent ee47750 commit 11d0b54

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Diff for: spec/acceptance/peadm_spec/plans/add_inventory_hostnames.pp

+12-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
$t = get_targets('*')
55
wait_until_available($t)
66

7-
$fqdn_results = wait(
8-
parallelize($t) |$target| {
9-
$fqdn = run_command('hostname -f', $target)
10-
$target.set_var('certname', $fqdn.first['stdout'].chomp)
7+
$fqdn_results = $t.map |$target| {
8+
$fqdn = run_command('hostname -f', $target).first
9+
if $fqdn['exit_code'] != 0 {
10+
fail("Failed to get FQDN for target ${target.name}: ${fqdn['stderr']}")
1111
}
12-
)
12+
$target.set_var('certname', $fqdn['stdout'].chomp)
13+
}
1314

1415
$fqdn_results.each |$result| {
15-
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${result.target.uri}\").name) = \"${result.value}\"' -i ${inventory_file}"
16+
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${uri}\").name) = \"${certname}\"' -i ${inventory_file}"
17+
$result = run_command($command, 'localhost').first
18+
if $result['exit_code'] != 0 {
19+
fail("Failed to update inventory file for target ${uri}: ${result['stderr']}")
20+
}
21+
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${uri}\").name) = \"${certname}\"' -i ${inventory_file}"
1622
run_command($command, 'localhost')
1723
}
1824
}

0 commit comments

Comments
 (0)