Skip to content

Commit

Permalink
fix(plan): add await block to ensure parallel tasks completion in add…
Browse files Browse the repository at this point in the history
…_inventory_hostnames

- Wrap parallelize block with await to ensure all tasks complete before proceeding
- Add notification to indicate inventory update completion
  • Loading branch information
CoMfUcIoS committed Sep 19, 2024
1 parent ce44b21 commit dcaaf36
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spec/acceptance/peadm_spec/plans/add_inventory_hostnames.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
$t = get_targets('*')
wait_until_available($t)

parallelize($t) |$target| {
$fqdn = run_command('hostname -f', $target)
$target.set_var('certname', $fqdn.first['stdout'].chomp)
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${target.uri}\").name) = \"${target.vars['certname']}\"' -i ${inventory_file}"
run_command($command, 'localhost')
}
await(
parallelize($t) |$target| {
$fqdn = run_command('hostname -f', $target)
$target.set_var('certname', $fqdn.first['stdout'].chomp)
$command = "yq eval '(.groups[].targets[] | select(.uri == \"${target.uri}\").name) = \"${target.vars['certname']}\"' -i ${inventory_file}"
run_command($command, 'localhost')
}
)
notify { 'Inventory updated': }
}

0 comments on commit dcaaf36

Please sign in to comment.