Skip to content
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

Find a convention for specifying Puppet's version to Gemfile #3

Closed
ekohl opened this issue Jan 11, 2022 · 3 comments · Fixed by #8
Closed

Find a convention for specifying Puppet's version to Gemfile #3

ekohl opened this issue Jan 11, 2022 · 3 comments · Fixed by #8
Milestone

Comments

@ekohl
Copy link
Member

ekohl commented Jan 11, 2022

Vox Pupuli uses https://github.com/voxpupuli/modulesync_config/blob/a87ca50493f5b1ac09956fd7f8c226cf6fc3165f/moduleroot/Gemfile.erb#L38-L39 or:

puppetversion = ENV['PUPPET_VERSION'] || '<%= @configs['puppet_version'] %>'
gem 'puppet', puppetversion, :require => false, :groups => [:test]

The Foreman uses puppetversion = ENV['PUPPET_VERSION'] || '<%= @configs['puppet_version'] %>'
gem 'puppet', puppetversion, :require => false, :groups => [:test] or:

gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '>= 5.5', groups: ['development', 'test']

pdk-templates uses https://github.com/puppetlabs/pdk-templates/blob/b851eaa1db21ee695c07da1a9594a86403bfcc18/moduleroot/Gemfile.erb#L103-L109 or (summarized for readability):

def location_for(place_or_version, fake_version = nil)
  git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
  file_url_regex = %r{\Afile:\/\/(?<path>.*)}

  if place_or_version && (git_url = place_or_version.match(git_url_regex))
    [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
  elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
    ['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
  else
    [place_or_version, { require: false }]
  end
end

puppet_version = ENV['PUPPET_GEM_VERSION']
gem_params = location_for(puppet_version)
gem 'puppet', *gem_params

So none of these really is the same:

  • VP and Foreman use PUPPET_VERSION as the environment variable but PDK uses PUPPET_GEM_VERSION
  • VP and PDK use the full specifier while Foreman forces ~>

If these workflows are to be used by all, it would be good to align on a single convention.

PUPPET_GEM_VERSION does have the benefit that it doesn't overlap with PUPPET_VERSION which is also used in beaker-puppet_install_helper (https://github.com/puppetlabs/beaker-puppet_install_helper/blob/41c355b1f83fde562dd5bd6961e2e4eb8b81421c/lib/beaker/puppet_install_helper.rb#L128) which, while archived, is still used by Vox Pupuli and Foreman in their Beaker setups.

@bastelfreak
Copy link
Member

do you have preference here? My first feelings are we should switch to PUPPET_GEM_VERSION to avoid the overlap. I think for VP we sometimes set the matchet (>=, ~> as well, but foreman only sets the actual version only?

@ekohl
Copy link
Member Author

ekohl commented Jan 12, 2022

I didn't want to push my own idea too much, but I'm also leaning to PUPPET_GEM_VERSION. And I'm ok with including the matcher in Foreman. I rarely if ever change it in my local environment and for CI it's trivial to change.

@bastelfreak
Copy link
Member

using PUPPET_GEM_VERSION sounds good to me.

@ekohl ekohl changed the title FInd a convention for specifying Puppet's version to Gemfile Find a convention for specifying Puppet's version to Gemfile Jan 13, 2022
@ekohl ekohl closed this as completed in #8 Jan 27, 2022
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 a pull request may close this issue.

2 participants