This message was deleted.
# bolt
s
This message was deleted.
y
IIRC vars() has a Target parameter, not Targets
So you may want to use each() or map() to iterate over your targets
m
Thanks to your pointers I was able to solve this:
Copy code
plan myplan (
  TargetSpec $targets = 'localhost',
) {
  $mytargets = get_targets($targets)
  $mytargets.each | $target | {
    out::message($target.vars)
  }
}
A bit bloated but I didn't find another way to access vars set for each target. My inventory.yaml looks like this
Copy code
groups:
  - name: production
    vars:
      environment: 'production'
    targets:
      - someotherhost.home.arpa
  - name: test
    vars:
      environment: 'test'
    targets:
      - myothehost.home.arpa
      - localhost
The result is
Copy code
bolt plan run myplan targets=test
Starting: plan myplan
These are myothehost.home.arpa
{
  "environment": "test"
}
These are localhost
{
  "environment": "test"
}
Finished: plan myplan in 0.02 sec
Plan completed successfully with no result