-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Describe the Bug
When an inventory variable, which is an array, is used inside a plan, the following error occurs:
undefined method []' for nil:NilClass`
When a scalar value is used, the plan finishes successfully.
Expected Behavior
Both scalar values and arrays should be working inside a plan which applies a manifest block
Steps to Reproduce
I added a plan and two inventory files below in the context section. One inventory file contains a variable which is an array. Running the plan with this inventory should reproduce the failure. The other inventory with the scalar variable is a working example. I just added this to emphasize, that the array var is somehow the reason why it fails.
Environment
- Version 2.14.0 and onwards (earlier versions work)
- Platform macOS 10.15.4 and onwards (not tested with earlier versions)
Additional Context
This bug may be somehow related to #1836 because this bug also occured when I used array inventory vars. This bug was fixed and until 2.14.0 my plan worked flawlessly.
Plan which can the bug be reproduced with
plan reproduce::error (
TargetSpec $targets,
) {
$hosts = get_targets($targets)
$hosts.each |$target| {
$vars = $target.vars()
$roles = $vars['roles']
apply_prep($target)
apply($target) {
notify { 'foo':
message => 'bar'
}
}
}
}
Inventory file which causes problem
---
version: 2
targets:
- alias: web
vars:
roles:
- array
- values
uri: example.org
Inventory file with works
---
version: 2
targets:
- alias: web
vars:
roles: single value
uri: example.org