| Version is 1.49.0
[agrams@test1 cdpbootstrap]$ bolt --version |
1.49.0 |
When converting inventory.yaml from version 1 to version 2, access to vars and facts in plan execution appears to have changed. I may be missing something obvious though. Let me illustrate the issue. Take the following inventory version 1 and plan: inventory.yaml
[agrams@test1 cdpbootstrap]$ cat inventory.yaml |
--- |
groups: |
- name: cdpglobal |
nodes: |
- 10.68.134.9 |
config: |
transport: ssh |
facts: |
cdpenv: global |
role: authoritative |
vars: |
test1: test2 |
site-modules/cdpns/plans/environmentbug.pp
plan cdpns::environmentbug ( |
TargetSpec $targets, |
) { |
$targets.apply_prep |
apply( |
$targets, |
_run_as => root |
) { |
$target = get_targets($targets)[0] |
$targetvars = $target.vars() |
notify { "vars for ${target}: ${targetvars}": } |
} |
}
|
Output from plan execution:
[agrams@test1 cdpbootstrap]$ bolt plan run cdpns::environmentbug --targets cdpglobal --password-prompt -v |
Please enter your password: |
Deprecation Warning: Starting with Bolt 2.0, inventory file v1 will no longer |
be supported. v1 inventory files can be automatically migrated to v2 using |
'bolt project migrate'. Inventory files are modified in place and will not |
preserve formatting or comments. |
CLI arguments ["password"] may be overridden by Inventory: /home/agrams/cdpbootstrap/inventory.yaml |
Starting: plan cdpns::environmentbug |
Starting: plan cdpns::environmentbug |
Starting: install puppet and gather facts on 10.68.134.9 |
Finished: install puppet and gather facts with 0 failures in 5.34 sec |
Starting: apply catalog on 10.68.134.9 |
Started on 10.68.134.9... |
Finished on 10.68.134.9: |
Notice: /Stage[main]/Main/Notify[vars for Target('10.68.134.9', {}): {test1 => test2}]/message: defined 'message' as 'vars for Target(\'10.68.134.9\', {}): {test1 => test2}' |
changed: 1, failed: 0, unchanged: 0 skipped: 0, noop: 0 |
Finished: apply catalog with 0 failures in 6.67 sec |
Finished: plan cdpns::environmentbug in 12.02 sec |
Finished: plan cdpns::environmentbug in 12.02 sec |
Plan completed successfully with no result
|
I receive a deprecation warning for inventory.yaml, but things work as expected. The vars defined in inventory.yaml are printed:
vars for Target(\'10.68.134.9\', {}): {test1 => test2}' |
Now, I upgrade the inventory to version 2:
[agrams@test1 cdpbootstrap]$ bolt project migrate -v --debug |
Loaded configuration from: '/home/agrams/cdpbootstrap/bolt.yaml'Analytics opt-out is set, analytics will be disabled |
Skipping submission of 'project_migrate' screenview because analytics is disabled |
Loading modules from /opt/puppetlabs/bolt/lib/ruby/gems/2.5.0/gems/bolt-1.49.0/bolt-modules:/home/agrams/cdpbootstrap/modules:/home/agrams/cdpbootstrap/site-modules:/home/agrams/cdpbootstrap/site:/opt/puppetlabs/bolt/lib/ruby/gems/2.5.0/gems/bolt-1.49.0/modules |
Loaded inventory from /home/agrams/cdpbootstrap/inventory.yaml |
Deprecation Warning: Starting with Bolt 2.0, inventory file v1 will no longer |
be supported. v1 inventory files can be automatically migrated to v2 using |
'bolt project migrate'. Inventory files are modified in place and will not |
preserve formatting or comments.Successfully migrated Bolt project to latest version
|
inventory.yaml version 2 (converted)
[agrams@test1 cdpbootstrap]$ cat inventory.yaml |
--- |
version: 2 |
groups: |
- name: cdpglobal |
config: |
transport: ssh |
facts: |
cdpenv: global |
role: authoritative |
vars: |
test1: test2 |
targets: |
- 10.68.134.9
|
The output from the same plan after upgrading inventory.yaml:
[agrams@test1 cdpbootstrap]$ bolt plan run cdpns::environmentbug --targets cdpglobal --password-prompt -v |
Please enter your password: |
CLI arguments ["password"] may be overridden by Inventory: /home/agrams/cdpbootstrap/inventory.yaml |
Starting: plan cdpns::environmentbug |
Starting: plan cdpns::environmentbug |
Starting: install puppet and gather facts on 10.68.134.9 |
Finished: install puppet and gather facts with 0 failures in 5.37 sec |
Starting: apply catalog on 10.68.134.9 |
Started on 10.68.134.9... |
Finished on 10.68.134.9: |
Notice: /Stage[main]/Main/Notify[vars for Target('cdpglobal', {}): {}]/message: defined 'message' as 'vars for Target(\'cdpglobal\', {}): {}' |
changed: 1, failed: 0, unchanged: 0 skipped: 0, noop: 0 |
Finished: apply catalog with 0 failures in 6.44 sec |
Finished: plan cdpns::environmentbug in 11.82 sec |
Finished: plan cdpns::environmentbug in 11.82 sec |
Plan completed successfully with no result |
|
On this run, the target name changed from 10.68.134.9 to cdpglobal and as a result the vars are not printed. Expected result is similar behavior before and after updating inventory.yaml from version 1 to version 2. |