Skip to content

Update to use puppetcore puppet and facter #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gavindidrichsen
Copy link

@gavindidrichsen gavindidrichsen commented Mar 10, 2025

This change

  • Introduces a change to the Gemfile that enables a "switch" on PUPPET_AUTH_TOKEN environment variable. In other words, when not-set, then all gem dependencies will be resolved from https://rubygems.org. If set, then puppet and facter will be resolved from the https://rubygems-puppetcore.puppet.com
  • Adds a github action that verifies the puppetcore gems are in fact downloaded

For instructions on how to setup authentication and consume the puppetcore gems, see https://github.com/puppetlabs/puppetcore-gems/blob/main/docs/how-to/how_to_consume_the_private_puppetcore_gems.md.

Unfortunately, I wasn't able to add the rspec test to verify the puppetcore modules. See #564 and fix.

@gavindidrichsen
Copy link
Author

gavindidrichsen commented Mar 10, 2025

Verify bundle install WITHOUT PUPPET_AUTH_TOKEN set

This proves that the bundle install on the peadm should work as-before (apart from the upgrade to ruby 3) without pulling in any puppetcore gems:

# clear all existing ruby configuration
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ rgc
+ rm -f Gemfile.lock
+ rm -rf .bundle .direnv vendor/bundle vendor/bin vendor/gems
+ set +x

# setup local bundler configuration
bundle config --local gemfile Gemfile
bundle config --local path vendor/bundle
bundle config --local bin vendor/bin

# set local ruby to be 3.x because the new puppet requires ruby 3
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ rbenv local 3.2.5

# bundle install
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ bundle install
Your Gemfile lists the gem puppetlabs_spec_helper (~> 6.0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching rake 13.2.1
Installing rake 13.2.1
...
...
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ bundle exec rspec spec/support/gemfile_spec.rb 

# verify the source for puppet and facter are https://rubygems.org
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ cat Gemfile.lock | grep -E "(remote:|specs:| puppet | facter | hiera )"
  remote: https://rubygems.org/
  specs:
      puppet (>= 6.18.0)
    facter (4.10.0)
      facter (< 5.0.0)
    puppet (8.10.0-universal-darwin)
      facter (>= 4.3.0, < 5)
      puppet (>= 6)
      puppet (>= 5)
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗

Verify bundle install WITH PUPPET_AUTH_TOKEN set

In other words, PUPPET_AUTH_TOKEN is set on the environment and is a valid Forge token

# clear everything ruby config
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ rgc
+ rm -f Gemfile.lock
+ rm -rf .bundle .direnv vendor/bundle vendor/bin vendor/gems
+ set +x
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ 

# setup local bundler configuration
bundle config --local gemfile Gemfile
bundle config --local path vendor/bundle
bundle config --local bin vendor/bin

# set the PUPPET_AUTH_TOKEN
export PUPPET_AUTH_TOKEN=<REDACTED_VALID_FORGE_TOKEN>

# add bundle authentication
bundle config --local https://rubygems-puppetcore.puppet.com "forge-key:${PUPPET_AUTH_TOKEN}"

# bundle install
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ bundle install
Your Gemfile lists the gem puppetlabs_spec_helper (~> 6.0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
Fetching gem metadata from https://rubygems-puppetcore.puppet.com/..
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching rake 13.2.1
...
...


# verify the gem source for puppet and facter is https://rubygems-puppetcore.puppet.com/
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ cat Gemfile.lock | grep -E "(remote:|specs:| puppet | facter | hiera )"
  remote: https://rubygems-puppetcore.puppet.com/
  specs:
    facter (4.11.0)
    puppet (8.11.0-universal-darwin)
      facter (>= 4.3.0, < 5)
  remote: https://rubygems.org/
  specs:
      puppet (>= 6.18.0)
      facter (< 5.0.0)
      puppet (>= 6)
      puppet (>= 5)
  facter (~> 4.0)!
  puppet (~> 8.11)!
➜  puppetlabs-peadm git:(gavin_puppetcore_update) ✗ 

@gavindidrichsen gavindidrichsen force-pushed the gavin_puppetcore_update branch 3 times, most recently from 8b542f5 to 84c0702 Compare March 11, 2025 16:16
@gavindidrichsen gavindidrichsen force-pushed the gavin_puppetcore_update branch from 9686978 to db16f01 Compare March 18, 2025 17:18
@davidmalloncares davidmalloncares force-pushed the gavin_puppetcore_update branch from 6fc5760 to d3c964f Compare March 24, 2025 15:26
@davidmalloncares davidmalloncares marked this pull request as ready for review March 24, 2025 15:26
@davidmalloncares davidmalloncares requested review from a team as code owners March 24, 2025 15:26
This change
*  Introduces a change to the Gemfile that enables a "switch" on PUPPET_AUTH_TOKEN environment variable.  In other words, when not-set, then all gem dependencies will be resolved from https://rubygems.org.  If set, then puppet and facter will be resolved from the https://rubygems-puppetcore.puppet.com

This commit enables the peadm development team to test its functionality using the puppetcore puppet and facter gems.

the  Signed-off-by: Gavin Didrichsen <[email protected]>
@gavindidrichsen gavindidrichsen force-pushed the gavin_puppetcore_update branch from d3c964f to 2f9597f Compare April 15, 2025 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant