Skip to content

Commit

Permalink
(maint) Update packaged modules
Browse files Browse the repository at this point in the history
Update to latest modules for next bolt release.

!feature

* **Update puppet modules shipped with bolt packages**

  Modules shipped with bolt packages have been updated to latest.
  • Loading branch information
tlehman committed Aug 20, 2024
1 parent 40b726c commit 9392c1e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5067,4 +5067,4 @@ their containing plan** ([#1167](https://github.com/puppetlabs/bolt/issues/1167)

* **`C:\Program Files\Puppet Labs\Bolt\bin\bolt.bat` is non-functional**

When moving to Ruby 2.5, the .bat scripts in Bolt packaging reverted to hard-coded paths that were not accurate. As a result Bolt would be unusable outside of PowerShell. The .bat scripts have been fixed so they work from cmd.exe as well. ([BOLT-886](https://tickets.puppet.com/browse/BOLT-886))
When moving to Ruby 2.5, the .bat scripts in Bolt packaging reverted to hard-coded paths that were not accurate. As a result Bolt would be unusable outside of PowerShell. The .bat scripts have been fixed so they work from cmd.exe as well. ([BOLT-886](https://tickets.puppet.com/browse/BOLT-886))
8 changes: 4 additions & 4 deletions Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ moduledir File.join(File.dirname(__FILE__), 'modules')

# Core modules used by 'apply'
mod 'puppetlabs-service', '3.0.0'
mod 'puppetlabs-puppet_agent', '4.19.0'
mod 'puppetlabs-facts', '1.4.0'
mod 'puppetlabs-puppet_agent', '4.20.1'
mod 'puppetlabs-facts', '1.6.0'

# Core types and providers for Puppet 6
mod 'puppetlabs-augeas_core', '1.5.0'
mod 'puppetlabs-host_core', '1.3.0'
mod 'puppetlabs-scheduled_task', '4.0.0'
mod 'puppetlabs-sshkeys_core', '2.5.0'
mod 'puppetlabs-zfs_core', '1.5.0'
mod 'puppetlabs-zfs_core', '1.6.1'
mod 'puppetlabs-cron_core', '1.3.0'
mod 'puppetlabs-mount_core', '1.3.0'
mod 'puppetlabs-selinux_core', '1.4.0'
Expand All @@ -32,7 +32,7 @@ mod 'puppetlabs-powershell_task_helper', '0.1.0'
mod 'puppetlabs-ruby_task_helper', '0.6.1'
mod 'puppetlabs-ruby_plugin_helper', '0.2.0'
mod 'puppetlabs-python_task_helper', '0.5.0'
mod 'puppetlabs-bash_task_helper', '2.0.0'
mod 'puppetlabs-bash_task_helper', '2.1.1'

# Plugin modules
mod 'puppetlabs-aws_inventory', '0.7.0'
Expand Down
65 changes: 65 additions & 0 deletions dev-resources/bump_mods.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: true

# Bump the module versions in the Puppetfile to the latest version
# published on https://forge.puppet.com
require 'open-uri'
require 'pry'
require 'rss'

def parse_puppetfile_get_mod_versions
module_re = /^mod 'puppetlabs-([a-z_\-]+)', *'([0-9.]+)'$/i
versions = {}
File.foreach('Puppetfile') do |line|
match = module_re.match(line)
if match
versions[match[1].strip] = match[2].strip
end
end
versions
end

def latest_version_for_module(mod)
url = "https://forge.puppet.com/modules/puppetlabs/#{mod}/rss"
# rubocop:disable Security/Open
feed = RSS::Parser.parse(URI.open(url))
# rubocop:enable Security/Open

feed.items&.first&.description
end

# get modules to update
versions_old = parse_puppetfile_get_mod_versions
versions_new = {}

versions_old.each do |mod, ver|
ver_new = latest_version_for_module(mod)

if !ver_new.nil? && (ver != ver_new)
versions_new[mod] = ver_new
end
end

def puppetfile_set_mod_versions!(versions_new)
module_re = /^mod 'puppetlabs-([a-z_\-]+)', *'([0-9.]+)'$/i
lines = File.open('Puppetfile').readlines

# update lines
lines.each do |line|
next unless line.start_with?("mod 'puppetlabs")
match = module_re.match(line)
next unless match
mod = match[1].strip
ver_old = match[2].strip
ver_new = versions_new[mod]
unless ver_new.nil?
line.gsub!(/'([0-9.]+)'/, "'#{ver_new}'")
puts "Updated #{mod} from #{ver_old} to #{ver_new}"
end
end

# update Puppetfile
File.open('Puppetfile', 'w').puts(lines.join)
end

# Update the Puppetfile with the new versions
puppetfile_set_mod_versions!(versions_new)
2 changes: 1 addition & 1 deletion lib/bolt/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Bolt
VERSION = '3.30.0'
VERSION = '3.31.0'
end

0 comments on commit 9392c1e

Please sign in to comment.