Jira (BOLT-1538) Updating inventory.yaml from v1 to v2 changes target behavior

3 views
Skip to first unread message

Axton Grams (JIRA)

unread,
Feb 16, 2020, 1:17:05 PM2/16/20
to puppe...@googlegroups.com
Axton Grams created an issue
 
Puppet Task Runner / Bug BOLT-1538
Updating inventory.yaml from v1 to v2 changes target behavior
Issue Type: Bug Bug
Affects Versions: BOLT 1.29.0
Assignee: Unassigned
Components: Executor
Created: 2020/02/16 10:16 AM
Environment:

Version is 1.49.0

[agrams@test1 cdpbootstrap]$ bolt --version
1.49.0

No PuppetDB integration or Puppet Master.

Priority: Normal Normal
Reporter: Axton Grams

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.

 

 

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Axton Grams (JIRA)

unread,
Feb 17, 2020, 12:08:05 AM2/17/20
to puppe...@googlegroups.com
Axton Grams assigned an issue to Axton Grams
 

I was able to access the facts and vars using inventory v2 as follows:

 

plan cdpns::environmentbug2 (
 TargetSpec $targets,
) {
 $targets.apply_prep
 $target = get_targets($targets)[0]
 $targetvars = $target.vars
apply(
 $targets,
 _run_as => root
 ) {
 notify {"targets: ${targets}": }
 notify {"facts for targets: $facts": }
notify {"vars for target $target: $targetvars": }
 }
}

 

Change By: Axton Grams
Resolution: Declined
Assignee: Axton Grams
Status: Open Closed
Reply all
Reply to author
Forward
0 new messages