simp-beaker-helpers 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e51892c7f01f52c49e29840032a8e4b7d5f524a3c3160b3218d3839224bfaf6
4
- data.tar.gz: abbce77cea4030bcc802eaa16359e5f53998fb1dda40cd8dbb5aa11e56fff768
3
+ metadata.gz: 249a3f841428c2b28cbe7961183d25344edc726652e3ae5bb66c084e9a30b2d9
4
+ data.tar.gz: 29fb61f0eb9dd16251d1389dd5b68457b93e3bbd81946e52a153dc82ace40fbd
5
5
  SHA512:
6
- metadata.gz: 3c0c3ef0740aef92c4dcb643b94ac228d5484a0ad524b7b419832f30e28caa63f4ba802bf48d721ae242af7a387cc291582e33e9ad23ef345f6bc88105161f67
7
- data.tar.gz: 61829ea33bf1911ee6da64d46b29f270f907631c01b3e681b62ac4650716ccaeba4d3d8dababc07cfea1eb8400b1bd2ab72d8528940e296bf4e35f290f36ddac
6
+ metadata.gz: d42a18f587b5c613a0ce1d4af8946be6f070e258e1012e8b1811dd63d93caa0fe967205b545ddc3462b87d37d3df58902bb5aca8705528750e08eb80166b80ab
7
+ data.tar.gz: 5ddf2f564b29b9eb93e8d02c5bb5670d3019cf2ed2950c8083cbbc5d0a29ddca349b5009e1ec81242292af0d80b84149c0afcda54c97dc443cbe1b50584bbc9f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 3.1.0 / 2026-07-02
2
+ * Added:
3
+ * `ensure_beaker_ip_on`: detect SUTs whose recorded `host[:ip]` was never
4
+ actually applied (e.g. EL10 under Vagrant, where the legacy ifcfg files
5
+ Vagrant writes for static private-network IPs are no longer supported and
6
+ the interface silently falls back to DHCP) and (re-)apply the expected
7
+ address via NetworkManager (reboot-safe), falling back to `ip addr add`.
8
+ Runs automatically alongside `activate_interfaces` in the global
9
+ `before(:all)` hook; disable with `BEAKER_no_fix_interfaces`.
10
+
1
11
  ### 3.0.0 / 2026-06-24
2
12
  * Changed (**Breaking**):
3
13
  * Dropped support for Puppet 7 / Ruby 2.7. CI now tests Puppet/OpenVox 8 only,
@@ -4,5 +4,5 @@
4
4
  module Simp; end
5
5
 
6
6
  module Simp::BeakerHelpers # rubocop:disable Style/OneClassPerFile
7
- VERSION = '3.0.0'
7
+ VERSION = '3.1.0'
8
8
  end
@@ -1138,6 +1138,64 @@ module Simp::BeakerHelpers # rubocop:disable Style/OneClassPerFile
1138
1138
  end
1139
1139
  end
1140
1140
 
1141
+ # Ensure that the IP address that Beaker has recorded for each SUT is
1142
+ # actually present on the system and (re-)apply it if it is not.
1143
+ #
1144
+ # Some OS/hypervisor combinations silently fail to configure the static IP
1145
+ # for secondary (private) networks. In particular, Vagrant configures
1146
+ # static IPs on RedHat-family guests by writing legacy ifcfg files, which
1147
+ # EL10 no longer supports at all. The interface falls back to NetworkManager
1148
+ # DHCP and receives an arbitrary address, so everything that targets the
1149
+ # recorded `host[:ip]` (cross-SUT traffic, direct Net::SSH logins, etc.)
1150
+ # fails with 'No route to host'.
1151
+ #
1152
+ # This detects the mismatch and applies the expected address to the
1153
+ # interface that is attached to the same network, using NetworkManager so
1154
+ # that the address survives reboots, and falling back to a runtime-only
1155
+ # `ip addr add` when NetworkManager is not in use.
1156
+ def ensure_beaker_ip_on(hosts)
1157
+ return if ENV['BEAKER_no_fix_interfaces']
1158
+
1159
+ block_on(hosts, run_in_parallel: @run_in_parallel) do |host|
1160
+ expected_ip = host[:ip]
1161
+ next unless expected_ip
1162
+ next if host[:platform].include?('windows')
1163
+
1164
+ # All currently assigned IPv4 addresses ('<iface> <address>/<prefix>')
1165
+ addrs = on(host, %(ip -o -4 addr show), accept_all_exit_codes: true).stdout.lines.map { |line|
1166
+ next unless line =~ %r{^\d+:\s+(\S+)\s+inet\s+(\S+)/(\d+)}
1167
+ { iface: Regexp.last_match(1), ip: Regexp.last_match(2), prefix: Regexp.last_match(3) }
1168
+ }.compact
1169
+
1170
+ next if addrs.any? { |a| a[:ip] == expected_ip }
1171
+
1172
+ require 'ipaddr'
1173
+ target = addrs.find do |a|
1174
+ IPAddr.new("#{a[:ip]}/#{a[:prefix]}").include?(expected_ip)
1175
+ rescue IPAddr::Error
1176
+ false
1177
+ end
1178
+
1179
+ unless target
1180
+ puts " -- WARNING: #{host} does not have expected IP #{expected_ip} and no interface on that network could be found"
1181
+ next
1182
+ end
1183
+
1184
+ puts " -- FIXING: #{host} expected IP #{expected_ip} but '#{target[:iface]}' has #{target[:ip]}"
1185
+
1186
+ nm_connection = on(host, %(nmcli -g GENERAL.CONNECTION device show #{target[:iface]}), accept_all_exit_codes: true).stdout.strip
1187
+ if nm_connection.empty?
1188
+ # Not NetworkManager-managed => runtime-only fallback
1189
+ on(host, %(ip addr add #{expected_ip}/#{target[:prefix]} dev #{target[:iface]}), accept_all_exit_codes: true)
1190
+ else
1191
+ # Match Vagrant's static network behavior: fixed address, no gateway,
1192
+ # and never a default route on the private interface
1193
+ on(host, %(nmcli connection modify "#{nm_connection}" ipv4.method manual ipv4.addresses "#{expected_ip}/#{target[:prefix]}" ipv4.gateway "" ipv4.never-default yes))
1194
+ on(host, %(nmcli connection up "#{nm_connection}"))
1195
+ end
1196
+ end
1197
+ end
1198
+
1141
1199
  ## Inline Hiera Helpers ##
1142
1200
  ## These will be integrated into core Beaker at some point ##
1143
1201
 
@@ -1152,6 +1210,10 @@ module Simp::BeakerHelpers # rubocop:disable Style/OneClassPerFile
1152
1210
 
1153
1211
  # We can't guarantee that the upstream vendor isn't disabling interfaces
1154
1212
  activate_interfaces(hosts)
1213
+
1214
+ # Some OS/hypervisor combinations (e.g. EL10 under Vagrant) fail to
1215
+ # apply the static IP that Beaker expects for private networks
1216
+ ensure_beaker_ip_on(hosts)
1155
1217
  end
1156
1218
 
1157
1219
  c.after(:all) do
@@ -4,6 +4,7 @@ require 'simp/beaker_helpers'
4
4
  # redefine methods used in RSpec.configure withing Simp::BeakerHelpers
5
5
  def hosts; end
6
6
  def activate_interfaces(hosts); end
7
+ def ensure_beaker_ip_on(hosts); end
7
8
  def clear_temp_hieradata; end
8
9
 
9
10
  class MyTestClass
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
8
8
  - Trevor Vaughan
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-25 00:00:00.000000000 Z
11
+ date: 2026-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beaker