beaker-docker 2.1.0 → 2.2.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: 68081b2882922ccbb645c18cd13793230a072aad07154d51da1fa5d1b2876186
4
- data.tar.gz: 20894761944fb07007daacdaf6e466bc282a4a418d07d304776bdc77738a23d4
3
+ metadata.gz: 841111065b59b77771dab0534b4f9e3f3963378c0a0daf27d86330ab0c733f7a
4
+ data.tar.gz: '025243139d8c52cad6a50cd5fa27e6cea07414cdb278aadb395072bd1897448d'
5
5
  SHA512:
6
- metadata.gz: 3d12134709510c8508550b7b1b33e68138632ce0c7bc3fe5ac5d72d3a2e5e106933c769f9e9901ce37f27bde1b52c2f6f5f183883246c2e5d96f71214a1f01eb
7
- data.tar.gz: d075fae3a65f02084ebc54f6dd5059381d60849b603cb268d1d55dfe6ba46f50fb6345a21af05eca1f3652398bcafbf1100ffe7d966f69bd3f736f724caefd09
6
+ metadata.gz: 98afc27265b51cd18868d25651e7003e50f9c26785af54ab277d0e9c673d256aad8a2f4b16905e096c1a2917766b247e44c11d75ae7a7f80e8bd6689174325b4
7
+ data.tar.gz: 3d84cef6317f571b79277c17cd3be523184a04fd81aa97bd7e4f3340417aabc19c2a07bbc339c13529e644efbf2b37f099ed1e41e6072d7f00b847e41b3fbb49
@@ -10,7 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  if: github.repository_owner == 'voxpupuli'
12
12
  steps:
13
- - uses: actions/checkout@v3
13
+ - uses: actions/checkout@v4
14
14
  - name: Install Ruby 3.0
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
@@ -13,7 +13,7 @@ jobs:
13
13
  rubocop:
14
14
  runs-on: ubuntu-latest
15
15
  steps:
16
- - uses: actions/checkout@v3
16
+ - uses: actions/checkout@v4
17
17
  - name: Install Ruby 3.2
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
@@ -37,7 +37,7 @@ jobs:
37
37
  COVERAGE: ${{ matrix.coverage }}
38
38
  name: RSpec - Ruby ${{ matrix.ruby }}
39
39
  steps:
40
- - uses: actions/checkout@v3
40
+ - uses: actions/checkout@v4
41
41
  - name: Install Ruby ${{ matrix.ruby }}
42
42
  uses: ruby/setup-ruby@v1
43
43
  with:
@@ -52,7 +52,7 @@ jobs:
52
52
  runs-on: ubuntu-latest
53
53
  name: Docker
54
54
  steps:
55
- - uses: actions/checkout@v3
55
+ - uses: actions/checkout@v4
56
56
  - name: Install Ruby 3.2
57
57
  uses: ruby/setup-ruby@v1
58
58
  with:
@@ -65,7 +65,7 @@ jobs:
65
65
  runs-on: ubuntu-latest
66
66
  name: Docker - Beaker in container connection test
67
67
  steps:
68
- - uses: actions/checkout@v3
68
+ - uses: actions/checkout@v4
69
69
  # use this and not container key from gha to not have a docker network from github
70
70
  - name: Run Beaker in docker container
71
71
  uses: addnab/docker-run-action@v3
@@ -83,7 +83,7 @@ jobs:
83
83
  runs-on: ubuntu-latest
84
84
  name: Podman
85
85
  steps:
86
- - uses: actions/checkout@v3
86
+ - uses: actions/checkout@v4
87
87
  - name: Install Ruby 3.2
88
88
  uses: ruby/setup-ruby@v1
89
89
  with:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-05-05 14:11:54 UTC using RuboCop version 1.50.2.
3
+ # on 2024-03-17 17:48:41 UTC using RuboCop version 1.62.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -26,6 +26,12 @@ RSpec/MultipleExpectations:
26
26
  RSpec/MultipleMemoizedHelpers:
27
27
  Max: 12
28
28
 
29
+ # Offense count: 7
30
+ # This cop supports unsafe autocorrection (--autocorrect-all).
31
+ RSpec/ReceiveMessages:
32
+ Exclude:
33
+ - 'spec/beaker/hypervisor/docker_spec.rb'
34
+
29
35
  # Offense count: 26
30
36
  # This cop supports safe autocorrection (--autocorrect).
31
37
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.0](https://github.com/voxpupuli/beaker-docker/tree/2.2.0) (2024-03-17)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.1.0...2.2.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Implement writing out a containerfile for a host [\#125](https://github.com/voxpupuli/beaker-docker/pull/125) ([ekohl](https://github.com/ekohl))
10
+ - Support Amazon Linux 2023 [\#123](https://github.com/voxpupuli/beaker-docker/pull/123) ([treydock](https://github.com/treydock))
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Rakefile: Use rubocop tasks from voxpupuli-rubocop [\#131](https://github.com/voxpupuli/beaker-docker/pull/131) ([bastelfreak](https://github.com/bastelfreak))
15
+ - voxpupuli-rubocop: Update 1.2-\>2.6 [\#129](https://github.com/voxpupuli/beaker-docker/pull/129) ([bastelfreak](https://github.com/bastelfreak))
16
+ - README.md: Document CLI; Add ToC [\#127](https://github.com/voxpupuli/beaker-docker/pull/127) ([bastelfreak](https://github.com/bastelfreak))
17
+
3
18
  ## [2.1.0](https://github.com/voxpupuli/beaker-docker/tree/2.1.0) (2023-05-05)
4
19
 
5
20
  [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.0.0...2.1.0)
@@ -84,7 +99,6 @@
84
99
 
85
100
  **Merged pull requests:**
86
101
 
87
- - Bump actions/checkout from 2 to 3 [\#90](https://github.com/voxpupuli/beaker-docker/pull/90) ([dependabot[bot]](https://github.com/apps/dependabot))
88
102
  - dependabot: check for github actions as well [\#89](https://github.com/voxpupuli/beaker-docker/pull/89) ([bastelfreak](https://github.com/bastelfreak))
89
103
 
90
104
  ## [1.3.0](https://github.com/voxpupuli/beaker-docker/tree/1.3.0) (2022-12-18)
data/README.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  Beaker library to use docker hypervisor
12
12
 
13
+ * [How to use this wizardry](#how-to-use-this-wizardry)
14
+ * [Nodeset Options](#nodeset-options)
15
+ * [Privileged containers](#privileged-containers)
16
+ * [Cleaning up after tests](#cleaning-up-after-tests)
17
+ * [Working with `podman`](#working-with-podman)
18
+ * [Generating a Dockerfile](#generating-a-dockerfile)
19
+ * [Spec tests]()
20
+ * [Acceptance tests]()
21
+ * [Transfer Notice](#transfer-notice)
22
+ * [License](#license)
23
+ * [Release Information](#release-information)
24
+
13
25
  ## How to use this wizardry
14
26
 
15
27
  This gem that allows you to use hosts with [docker](docker.md) hypervisor with [beaker](https://github.com/voxpupuli/beaker).
@@ -102,6 +114,56 @@ See the
102
114
  [HostConfig](https://any-api.com/docker_com/engine/docs/Definitions/HostConfig)
103
115
  portion of the docker API for more information.
104
116
 
117
+ ## Generating a Dockerfile
118
+
119
+ Usually beaker-docker is used to provision docker instances with beaker. During
120
+ this step beaker-docker generates a Dockerfile and posts it to the docker daemon
121
+ API.
122
+
123
+ There's also a small CLI command to only generate the file:
124
+
125
+ ```
126
+ bundle exec beaker-docker dockerfile archlinux-64
127
+ ```
128
+
129
+ Will generate a local `Dockerfile`:
130
+
131
+ ```dockerfile
132
+ FROM archlinux/archlinux
133
+ ENV container docker
134
+ RUN pacman --sync --refresh --noconfirm archlinux-keyring && pacman --sync --refresh --noconfirm --sysupgrade && pacman --sync --noconfirm curl ntp net-tools openssh && ssh-keygen -A && sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config && systemctl enable sshd
135
+ RUN mkdir -p /var/run/sshd && echo root:root | chpasswd
136
+ RUN sed -ri -e 's/^#?PermitRootLogin .*/PermitRootLogin yes/' -e 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' -e 's/^#?UseDNS .*/UseDNS no/' -e 's/^#?MaxAuthTries.*/MaxAuthTries 1000/' /etc/ssh/sshd_config
137
+ EXPOSE 22
138
+ CMD ["/sbin/init"]
139
+ ```
140
+
141
+ This works by calling
142
+ (beaker-hostgenerator](https://github.com/voxpupuli/beaker-hostgenerator?tab=readme-ov-file#beaker-host-generator).
143
+ So you can provide any host string that's supported by beaker-hostgenerator.
144
+
145
+ For non-rolling release distros this is usually `$os$majorversion-$architecture`
146
+
147
+ ```
148
+ beaker-docker dockerfile centos9-64
149
+ ```
150
+
151
+ ```dockerfile
152
+ FROM quay.io/centos/centos:stream9
153
+ ENV container docker
154
+ RUN dnf clean all && dnf install -y sudo openssh-server openssh-clients chrony && ssh-keygen -A && sed 's@session *required *pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/*
155
+ RUN mkdir -p /var/run/sshd && echo root:root | chpasswd
156
+ RUN sed -ri -e 's/^#?PermitRootLogin .*/PermitRootLogin yes/' -e 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' -e 's/^#?UseDNS .*/UseDNS no/' -e 's/^#?MaxAuthTries.*/MaxAuthTries 1000/' /etc/ssh/sshd_config
157
+ RUN cp /bin/true /sbin/agetty
158
+ RUN dnf install -y cronie crontabs initscripts iproute openssl wget which glibc-langpack-en hostname
159
+ EXPOSE 22
160
+ CMD ["/sbin/init"]
161
+ ```
162
+
163
+ This requires a running docker daemon. You can also request a containerfile.
164
+ This will currently generate a `Containerfile` but with the same content (this
165
+ may change in the future, depending on the API spec).
166
+
105
167
  ## Spec tests
106
168
 
107
169
  Spec test live under the `spec` folder. There are the default rake task and therefore can run with a simple command:
data/Rakefile CHANGED
@@ -3,16 +3,9 @@
3
3
  require 'rspec/core/rake_task'
4
4
 
5
5
  begin
6
- require 'rubocop/rake_task'
6
+ require 'voxpupuli/rubocop/rake'
7
7
  rescue LoadError
8
- # RuboCop is an optional group
9
- else
10
- RuboCop::RakeTask.new(:rubocop) do |task|
11
- # These make the rubocop experience maybe slightly less terrible
12
- task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
13
- # Use Rubocop's Github Actions formatter if possible
14
- task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
15
- end
8
+ # the voxpupuli-rubocop gem is optional
16
9
  end
17
10
 
18
11
  namespace :test do
@@ -73,7 +66,7 @@ rescue LoadError
73
66
  # Do nothing if no required gem installed
74
67
  else
75
68
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
76
- config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog]
69
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
77
70
  config.user = 'voxpupuli'
78
71
  config.project = 'beaker-docker'
79
72
  gem_version = Gem::Specification.load("#{config.project}.gemspec").version
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency 'fakefs', '>= 1.3', '< 3.0'
29
29
  s.add_development_dependency 'rake', '~> 13.0'
30
30
  s.add_development_dependency 'rspec', '~> 3.0'
31
- s.add_development_dependency 'voxpupuli-rubocop', '~> 1.2'
31
+ s.add_development_dependency 'voxpupuli-rubocop', '~> 2.6.0'
32
32
 
33
33
  # Run time dependencies
34
34
  s.add_runtime_dependency 'beaker', '>= 4', '< 6'
data/bin/beaker-docker CHANGED
@@ -2,8 +2,27 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'rubygems' unless defined?(Gem)
5
+ require 'beaker'
5
6
  require 'beaker-docker'
6
7
 
8
+ def dockerfile(hostspec, filename)
9
+ ENV['BEAKER_HYPERVISOR'] = 'docker'
10
+ options = Beaker::Options::Parser.new.parse_args(['--hosts', hostspec || '', '--no-provision'])
11
+ options[:logger] = Beaker::Logger.new(options)
12
+ network_manager = Beaker::NetworkManager.new(options, options[:logger])
13
+ network_manager.provision
14
+ hosts = network_manager.hosts
15
+
16
+ if hosts.size != 1
17
+ options[:logger].error "Found #{hosts.size} hosts, expected 1"
18
+ exit(1)
19
+ end
20
+
21
+ hypervisor = network_manager.hypervisors['docker']
22
+ # TODO: private method
23
+ File.write(filename, hypervisor.send(:dockerfile_for, hosts.first))
24
+ end
25
+
7
26
  VERSION_STRING = <<'VER'
8
27
  _ .--.
9
28
  ( ` )
@@ -25,6 +44,13 @@ VERSION_STRING = <<'VER'
25
44
  '=='
26
45
  VER
27
46
 
28
- puts VERSION_STRING % BeakerDocker::VERSION
47
+ case ARGV[0]
48
+ when 'containerfile'
49
+ dockerfile(ARGV[1], ARGV[2] || 'Containerfile')
50
+ when 'dockerfile'
51
+ dockerfile(ARGV[1], ARGV[2] || 'Dockerfile')
52
+ else
53
+ puts VERSION_STRING % BeakerDocker::VERSION
54
+ end
29
55
 
30
56
  exit 0
@@ -165,7 +165,7 @@ module Beaker
165
165
  # Container to container
166
166
  unless ip && port
167
167
  ip = network_settings['IPAddress']
168
- port = ip && !ip.empty? ? 22 : nil
168
+ port = (ip && !ip.empty?) ? 22 : nil
169
169
  end
170
170
 
171
171
  # Container through gateway
@@ -195,7 +195,7 @@ module Beaker
195
195
  port = port22[0]['HostPort'] if port22
196
196
  end
197
197
 
198
- ssh_connection_info[:ip] = ip == '0.0.0.0' ? '127.0.0.1' : ip
198
+ ssh_connection_info[:ip] = (ip == '0.0.0.0') ? '127.0.0.1' : ip
199
199
  ssh_connection_info[:port] = port || '22'
200
200
  ssh_connection_info
201
201
  end
@@ -375,7 +375,7 @@ module Beaker
375
375
  container.exec(%w[apt-get update])
376
376
  container.exec(%w[apt-get install -y openssh-server openssh-client])
377
377
  container.exec(%w[sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/*])
378
- when /el-[89]/, /fedora-(2[2-9]|3[0-9])/
378
+ when /el-[89]/, /fedora-(2[2-9]|3[0-9])/, /amazon-2023/
379
379
  container.exec(%w[dnf clean all])
380
380
  container.exec(%w[dnf install -y sudo openssh-server openssh-clients])
381
381
  container.exec(%w[ssh-keygen -A])
@@ -509,7 +509,7 @@ module Beaker
509
509
  RUN apt-get update \
510
510
  && apt-get install -y openssh-server openssh-client #{additional_packages.join(' ')}
511
511
  DF
512
- when /el-[89]/, /fedora-(2[2-9]|3)/
512
+ when /el-[89]/, /fedora-(2[2-9]|3)/, /amazon-2023/
513
513
  dockerfile += <<~DF
514
514
  RUN dnf clean all \
515
515
  && dnf install -y sudo openssh-server openssh-clients #{additional_packages.join(' ')} \
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeakerDocker
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
@@ -11,6 +11,7 @@ module Beaker
11
11
  'centos-7-x86_64',
12
12
  'sles-12-x86_64',
13
13
  'archlinux-2017.12.27-x86_64',
14
+ 'amazon-2023-x86_64',
14
15
  ]
15
16
 
16
17
  describe Docker do
@@ -206,7 +207,7 @@ module Beaker
206
207
  end
207
208
  end
208
209
 
209
- it 'will tag the image with the value of the tag' do
210
+ it 'tags the image with the value of the tag' do
210
211
  expect(image).to receive(:tag).with({ repo: 'my_tag' }).exactly(3).times
211
212
  docker.provision
212
213
  end
@@ -308,8 +309,8 @@ module Beaker
308
309
  },
309
310
  },
310
311
  'Labels' => {
311
- 'one' => (index == 2 ? 3 : 1),
312
- 'two' => (index == 2 ? 4 : 2),
312
+ 'one' => ((index == 2) ? 3 : 1),
313
+ 'two' => ((index == 2) ? 4 : 2),
313
314
  },
314
315
  'name' => /\Abeaker-/,
315
316
  })
@@ -339,8 +340,8 @@ module Beaker
339
340
  },
340
341
  },
341
342
  'Labels' => {
342
- 'one' => (index == 2 ? 3 : 1),
343
- 'two' => (index == 2 ? 4 : 2),
343
+ 'one' => ((index == 2) ? 3 : 1),
344
+ 'two' => ((index == 2) ? 4 : 2),
344
345
  },
345
346
  })
346
347
  end
@@ -396,8 +397,8 @@ module Beaker
396
397
  },
397
398
  },
398
399
  'Labels' => {
399
- 'one' => (index == 2 ? 3 : 1),
400
- 'two' => (index == 2 ? 4 : 2),
400
+ 'one' => ((index == 2) ? 3 : 1),
401
+ 'two' => ((index == 2) ? 4 : 2),
401
402
  },
402
403
  'name' => /\Abeaker-/,
403
404
  })
@@ -424,8 +425,8 @@ module Beaker
424
425
  'CapAdd' => %w[NET_ADMIN SYS_ADMIN],
425
426
  },
426
427
  'Labels' => {
427
- 'one' => (index == 2 ? 3 : 1),
428
- 'two' => (index == 2 ? 4 : 2),
428
+ 'one' => ((index == 2) ? 3 : 1),
429
+ 'two' => ((index == 2) ? 4 : 2),
429
430
  },
430
431
  'name' => /\Abeaker-/,
431
432
  })
@@ -458,8 +459,8 @@ module Beaker
458
459
  },
459
460
  },
460
461
  'Labels' => {
461
- 'one' => (index == 2 ? 3 : 1),
462
- 'two' => (index == 2 ? 4 : 2),
462
+ 'one' => ((index == 2) ? 3 : 1),
463
+ 'two' => ((index == 2) ? 4 : 2),
463
464
  },
464
465
  'name' => /\Abeaker-/,
465
466
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-05-05 00:00:00.000000000 Z
14
+ date: 2024-03-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fakefs
@@ -67,14 +67,14 @@ dependencies:
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '1.2'
70
+ version: 2.6.0
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '1.2'
77
+ version: 2.6.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: beaker
80
80
  requirement: !ruby/object:Gem::Requirement