puppetlabs / puppetlabs-vcsrepo

Support for source control repositories
http://forge.puppetlabs.com/puppetlabs/vcsrepo
GNU General Public License v2.0
223 stars 284 forks source link

Error occuring ``Could not autoload puppet/type/vcsrepo...puppet/provider/vcsrepo/cvs`` #609

Closed gavindidrichsen closed 1 year ago

gavindidrichsen commented 1 year ago

Describe the Bug

vcsrepo has begun to fail for me with Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs. For example:

Failed on pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal:
  The task failed with exit code 1 and no stdout, but stderr contained:
  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load': Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs: /tmp/d20230525-31962-bugb9w/modules/vcsrepo/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected ']' (Puppet::Error)
          @rev = contents[1..]
                             ^
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:93:in `block in loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:91:in `each'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:91:in `loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:196:in `loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:126:in `block in newtype'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:73:in `newtype'
        from /tmp/d20230525-31962-bugb9w/modules/vcsrepo/lib/puppet/type/vcsrepo.rb:6:in `<top (required)>'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:182:in `load'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:171:in `block in type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:154:in `type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:401:in `resource_type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:389:in `resource_type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:273:in `initialize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:584:in `new'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:584:in `copy_as_resource'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:619:in `block in to_catalog'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:615:in `each'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:615:in `to_catalog'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:508:in `to_ral'
        from /tmp/dd4de6a2-a836-4b10-98c0-6515b5b69c73/apply_catalog.rb:101:in `block in <main>'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:297:in `override'
        from /tmp/dd4de6a2-a836-4b10-98c0-6515b5b69c73/apply_catalog.rb:93:in `<main>'

Expected Behavior

It should successfully clone my repo. Code snippet is as follows:

    vcsrepo { "${userhome}/${repo}":
      ensure   => latest,
      provider => git,
      source   => $repository_url,
      revision => $branch,
      require  => Class['bigbird::profile::utilities::github::private_key'],
    }

Where

Steps to Reproduce

Steps to reproduce the behavior: See above

Environment

Additional Context

gavindidrichsen commented 1 year ago

I've noticed the following:


plan output

 bigbird git:(development) ✗ pbpr github::clone::usage --targets=all
/opt/puppetlabs/bin/bolt plan run bigbird::github::clone::usage --targets=all --verbose
Starting: plan bigbird::github::clone::usage
Starting: install puppet and gather facts on pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal, beefylinux-804019-0.us-west1-c.c.customer-support-scratchpad.internal, beefylinux-804019-1.us-west1-b.c.customer-support-scratchpad.internal, beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal
Finished: install puppet and gather facts with 0 failures in 54.99 sec
Starting: apply catalog on pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal, beefylinux-804019-0.us-west1-c.c.customer-support-scratchpad.internal, beefylinux-804019-1.us-west1-b.c.customer-support-scratchpad.internal, beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal
Started on pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal...
Started on beefylinux-804019-1.us-west1-b.c.customer-support-scratchpad.internal...
Started on beefylinux-804019-0.us-west1-c.c.customer-support-scratchpad.internal...
Started on beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal...
Finished on beefylinux-804019-1.us-west1-b.c.customer-support-scratchpad.internal:
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: Creating repository from latest
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: created
  changed: 1, failed: 0, unchanged: 21 skipped: 0, noop: 0
Finished on beefylinux-804019-0.us-west1-c.c.customer-support-scratchpad.internal:
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: Creating repository from latest
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: created
  changed: 1, failed: 0, unchanged: 21 skipped: 0, noop: 0
Failed on pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal:
  The task failed with exit code 1 and no stdout, but stderr contained:
  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load': Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs: /tmp/d20230525-31962-bugb9w/modules/vcsrepo/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected ']' (Puppet::Error)
          @rev = contents[1..]
                             ^
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:93:in `block in loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:91:in `each'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:91:in `loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:196:in `loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:126:in `block in newtype'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:73:in `newtype'
        from /tmp/d20230525-31962-bugb9w/modules/vcsrepo/lib/puppet/type/vcsrepo.rb:6:in `<top (required)>'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:182:in `load'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:171:in `block in type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:154:in `type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:401:in `resource_type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:389:in `resource_type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:273:in `initialize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:584:in `new'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:584:in `copy_as_resource'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:619:in `block in to_catalog'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:615:in `each'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:615:in `to_catalog'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:508:in `to_ral'
        from /tmp/dd4de6a2-a836-4b10-98c0-6515b5b69c73/apply_catalog.rb:101:in `block in <main>'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:297:in `override'
        from /tmp/dd4de6a2-a836-4b10-98c0-6515b5b69c73/apply_catalog.rb:93:in `<main>'
Finished on beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal:
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Exec[clone usage repository on windows]/returns: executed successfully
  changed: 1, failed: 0, unchanged: 11 skipped: 0, noop: 0
Finished: apply catalog with 1 failure in 60.91 sec
Finished: plan bigbird::github::clone::usage in 1 min, 56 sec
Failed on pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal:
  The task failed with exit code 1 and no stdout, but stderr contained:
  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load': Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs: /tmp/d20230525-31962-bugb9w/modules/vcsrepo/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected ']' (Puppet::Error)
          @rev = contents[1..]
                             ^
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:93:in `block in loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:91:in `each'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:91:in `loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:196:in `loadall'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:126:in `block in newtype'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:73:in `newtype'
        from /tmp/d20230525-31962-bugb9w/modules/vcsrepo/lib/puppet/type/vcsrepo.rb:6:in `<top (required)>'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:182:in `load'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:171:in `block in type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:154:in `type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:401:in `resource_type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:389:in `resource_type'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:273:in `initialize'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:584:in `new'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:584:in `copy_as_resource'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:619:in `block in to_catalog'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:615:in `each'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:615:in `to_catalog'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:508:in `to_ral'
        from /tmp/dd4de6a2-a836-4b10-98c0-6515b5b69c73/apply_catalog.rb:101:in `block in <main>'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:297:in `override'
        from /tmp/dd4de6a2-a836-4b10-98c0-6515b5b69c73/apply_catalog.rb:93:in `<main>'
Finished on beefylinux-804019-0.us-west1-c.c.customer-support-scratchpad.internal:
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: Creating repository from latest
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: created
  changed: 1, failed: 0, unchanged: 21 skipped: 0, noop: 0
Finished on beefylinux-804019-1.us-west1-b.c.customer-support-scratchpad.internal:
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: Creating repository from latest
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Vcsrepo[/root/usage]/ensure: created
  changed: 1, failed: 0, unchanged: 21 skipped: 0, noop: 0
Finished on beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal:
  Notice: /Stage[main]/Main/Bigbird::Profile::Utilities::Github[install usage]/Exec[clone usage repository on windows]/returns: executed successfully
  changed: 1, failed: 0, unchanged: 11 skipped: 0, noop: 0
Successful on 3 targets: beefylinux-804019-0.us-west1-c.c.customer-support-scratchpad.internal,beefylinux-804019-1.us-west1-b.c.customer-support-scratchpad.internal,beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal
Failed on 1 target: pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal
Ran on 4 targets

puppet version on my failing server: pe-server-205802-0.us-west1-a.c.customer-support-scratchpad.internal

root@pe-server-205802-0 control-repo (development)$ puppet --version
6.28.0
root@pe-server-205802-0 control-repo (development)$ 

whereas

puppet version on my successful servers: e.g., beefywin-804019-0.us-west1-c.c.customer-support-scratchpad.internal

root@beefylinux-804019-0 ~ $ puppet --version
7.24.0
root@beefylinux-804019-0 ~ $ 

Granted my 6.28.0 is an EOL PE at 2019.8.12...

Note also that I've been able to keep my code working across old an new servers by replacing the vcsrepo statement with the following:

    exec { "clone ${repo} repository on linux":
      path      => ['/usr/bin', '/usr/sbin', '/bin', '/sbin', '/usr/local/bin', '/usr/local/sbin'],
      command   => "rm -rf /root/development && git clone --branch ${branch} ${repository_url} ${userhome}/${repo}",
      cwd       => $userhome,
      unless    => "/bin/test -d ${userhome}/${repo}/.git",
      logoutput => true,
      require   => Class['bigbird::profile::utilities::github::private_key'],
    }
gavindidrichsen commented 1 year ago

Since puppetlabs/vcsrepo is only supported for puppet version >= 7.0.0 and I've found a workaround for < 7.0.0, I'm recording the following and closing this ticket:

    # NOTE:  puppetlabs/vcsrepo is only supported for puppet version >= 7.0.0 (in fact it fails on puppet 6.24.0)
    if versioncmp($facts['puppetversion'], '7.0.0') < 0 {
      # puppet version is < 7.0.0 so using an exec
      exec { "clone ${repo} repository on linux":
        path      => ['/usr/bin', '/usr/sbin', '/bin', '/sbin', '/usr/local/bin', '/usr/local/sbin'],
        command   => "rm -rf /root/development && git clone --branch ${branch} ${repository_url} ${userhome}/${repo}",
        cwd       => $userhome,
        unless    => "/bin/test -d ${userhome}/${repo}/.git",
        logoutput => true,
        require   => Class['bigbird::profile::utilities::github::private_key'],
      }
    } else {
      # puppet version is >=7.0.0 so using vcsrepo
      vcsrepo { "${userhome}/${repo}":
        ensure   => latest,
        provider => git,
        source   => $repository_url,
        revision => $branch,
        require  => Class['bigbird::profile::utilities::github::private_key'],
      }
    }