obs_deploy 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bb058921426d313f82510add524de887bc8f2be01379528680bef135c0ab99f
4
- data.tar.gz: 5a39875b8386d573bf3f4da424c4058eebcd1269dfef8fbe40fe0e104b0d3d4b
3
+ metadata.gz: 8ab8c1bfc4cf824dd5e4efd68d9276e034dfe91015686331e5630c0c558054f8
4
+ data.tar.gz: eb4100e89d9df67106937087ca61998a5ff00fc3631a465b4dbf9b1ff818a19a
5
5
  SHA512:
6
- metadata.gz: dafbd837d3498870b8cccb90d9f486868ad3ee17f7b85ca4febb11700f2f3d56178dd1d18b5c08c8cfc18601bbf6960b8fcddfe98151b08ab8ac3506b3e84f93
7
- data.tar.gz: b33c174b2c3f6bb7d75e73764024fcdf4f98d8b9a3a3f8b68a16572c5c7ae2f4c2c0767d756b8d2bf0ae3e466c3a68d5e64b2d65e9fbcb4852b165e2c4124e5b
6
+ metadata.gz: ea0f667fab7e119b895aaf4fe9215593d17d38af12451cfe679f09b4425bb8de13b3e4f1a8617da2e15fe0e4803f3b8dad697a9151376f5948e65610a226c99c
7
+ data.tar.gz: 07e2d1834cde084672db356d689f7fed31e25a6f384ccbd17a3a29525ff621949d986cc759e2238ae9b350f7158d1802b756803d60cafd6ba869c2ea805e5f01
data/Dockerfile ADDED
@@ -0,0 +1,13 @@
1
+ FROM opensuse/tumbleweed
2
+
3
+ RUN zypper ar -f -G https://download.opensuse.org/repositories/home:/vpereirabr/openSUSE_Tumbleweed/home:vpereirabr.repo
4
+ RUN zypper --gpg-auto-import-keys refresh
5
+ RUN zypper install -y openssh vim iputils
6
+ RUN zypper install -y ruby2.6-rubygem-obs_deploy
7
+
8
+ COPY entrypoint.sh /entrypoint.sh
9
+ RUN chmod +x /entrypoint.sh
10
+ ENTRYPOINT ["/entrypoint.sh"]
11
+
12
+
13
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- obs_deploy (0.1.2)
4
+ obs_deploy (0.1.5)
5
5
  cheetah
6
6
  dry-cli
7
7
  nokogiri
@@ -36,7 +36,7 @@ GEM
36
36
  method_source (~> 1.0)
37
37
  public_suffix (4.0.3)
38
38
  rainbow (3.0.0)
39
- rake (10.5.0)
39
+ rake (13.0.1)
40
40
  rexml (3.2.4)
41
41
  rspec (3.9.0)
42
42
  rspec-core (~> 3.9.0)
@@ -74,7 +74,7 @@ DEPENDENCIES
74
74
  bundler (~> 2.0)
75
75
  obs_deploy!
76
76
  pry
77
- rake (~> 10.0)
77
+ rake (~> 13.0)
78
78
  rspec (~> 3.0)
79
79
  rubocop
80
80
  webmock
data/README.md CHANGED
@@ -6,8 +6,15 @@ Simple tool to deploy OBS via zypper to our reference server
6
6
 
7
7
  Just run:
8
8
 
9
- ```ruby
10
- gem 'obs_deploy'
9
+ ```
10
+ gem install obs_deploy
11
+ ```
12
+
13
+ or
14
+
15
+ ```
16
+ zypper ar https://download.opensuse.org/repositories/home:/vpereirabr/openSUSE_Tumbleweed/home:vpereirabr.repo
17
+ zypper in ruby2.6-rubygem-obs_deploy
11
18
  ```
12
19
 
13
20
  ## Usage
@@ -46,6 +53,30 @@ On the checked out source, run the following:
46
53
 
47
54
  `ruby -Ilib bin/obs_deploy -v`
48
55
 
56
+ if you want to run it against the OBS appliance running on VirtualBox:
57
+
58
+ - Make sure that you can ssh without password into your VM
59
+ - Make sure the appliance is running in __bridge__ mode
60
+ - build the docker image as:
61
+
62
+ ```
63
+ docker build -t $USER/obs_deploy .
64
+ ```
65
+
66
+ - then run the container as:
67
+
68
+ ```
69
+ docker run --rm -it -v "$HOME/.ssh:/tmp/.ssh:ro" $USER/obs_deploy bash
70
+ ```
71
+ Now you are inside the container and should be able to ping the obs appliance.
72
+
73
+ From there:
74
+
75
+ ```
76
+ $ obs_deploy refresh-repositories --host=$APPLIANCE_IP
77
+ ```
78
+
79
+
49
80
  ## Hacking
50
81
 
51
82
  If you want to add new command to the cli, please read the `dry-cli` documentation https://dry-rb.org/gems/dry-cli/0.4/. The commands are in the `obs_deploy/cli/commands` directory.
data/bin/obs_deploy CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
+
4
6
  require 'obs_deploy'
5
7
  require 'dry/cli'
6
8
  require 'obs_deploy/cli/commands'
@@ -19,10 +19,10 @@
19
19
  %define mod_name obs_deploy
20
20
  %define mod_full_name %{mod_name}-%{version}
21
21
  Name: rubygem-obs_deploy
22
- Version: 0.1.1
22
+ Version: 0.1.2
23
23
  Release: 0
24
24
  Summary: OBS Deployment tool
25
- License:
25
+ License: MIT
26
26
  Group: Development/Languages/Ruby
27
27
  URL: https://openbuildservice.org
28
28
  Source: https://rubygems.org/gems/%{mod_full_name}.gem
data/entrypoint.sh ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ cp -R /tmp/.ssh /root/.ssh
5
+ chmod 700 /root/.ssh
6
+ chmod 644 /root/.ssh/id_rsa.pub
7
+ chmod 600 /root/.ssh/id_rsa
8
+
9
+ exec "$@"
data/lib/obs_deploy.rb CHANGED
@@ -3,54 +3,15 @@
3
3
  require 'open-uri'
4
4
  require 'net/http'
5
5
  require 'cheetah'
6
+ require 'logger'
7
+
6
8
  require 'nokogiri'
7
9
  require 'obs_deploy/version'
8
10
  require 'obs_deploy/check_diff'
9
11
  require 'obs_deploy/ssh'
12
+ require 'obs_deploy/zypper'
13
+ require 'obs_deploy/systemctl'
10
14
 
11
15
  module ObsDeploy
12
16
  class Error < StandardError; end
13
- class Systemctl
14
- class << self
15
- def status
16
- 'systemctl status obs-api-support.target'
17
- end
18
-
19
- def list_dependencies
20
- 'systemctl list-dependencies obs-api-support.target'
21
- end
22
- end
23
- end
24
-
25
- class Zypper
26
- def update(dry_run: true)
27
- if dry_run
28
- run ['zypper'] + update_params + dry_run_params + package_name
29
- else
30
- run ['zypper'] + update_params + package_name
31
- end
32
- end
33
-
34
- def refresh
35
- run ['zypper', '--non-interactive', '--gpg-auto-import-keys', 'refresh']
36
- end
37
-
38
- private
39
-
40
- def run(params)
41
- params
42
- end
43
-
44
- def package_name
45
- ['obs-api']
46
- end
47
-
48
- def update_params
49
- ['--non-interactive', 'update', '--best-effort', '--details']
50
- end
51
-
52
- def dry_run_params
53
- ['--dry-run --download-only']
54
- end
55
- end
56
17
  end
@@ -9,6 +9,7 @@ module ObsDeploy
9
9
  autoload :Deploy, File.join(__dir__, 'commands/deploy.rb')
10
10
  autoload :GetPackageVersion, File.join(__dir__, 'commands/get_package_version.rb')
11
11
  autoload :GetDeployedVersion, File.join(__dir__, 'commands/get_deployed_version.rb')
12
+ autoload :Systemctl, File.join(__dir__, 'commands/systemctl.rb')
12
13
 
13
14
  # register the commands and its command line
14
15
  register 'available-package', GetPackageVersion
@@ -16,6 +17,7 @@ module ObsDeploy
16
17
  register 'version', Version, aliases: ['v', '-v', '--version']
17
18
  register 'deploy', Deploy
18
19
  register 'refresh-repositories', RefreshRepositories
20
+ register 'systemctl', Systemctl
19
21
  end
20
22
  end
21
23
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pry'
4
+ module ObsDeploy
5
+ module CLI
6
+ module Commands
7
+ class Systemctl < Dry::CLI::Command
8
+ desc 'run systemd commands to verify application state'
9
+
10
+ option :user, type: :string, default: 'root', desc: 'User'
11
+ option :host, type: :string, default: 'localhost', desc: 'Set the server address'
12
+ option :port, type: :int, default: 22, desc: 'Set the server port'
13
+
14
+ def call(user:, host:, port:, **)
15
+ ssh_driver = ObsDeploy::SSH.new(user: user, server: host, port: port)
16
+ ssh_driver.run(ObsDeploy::Systemctl.new.status)
17
+ ssh_driver.run(ObsDeploy::Systemctl.new.list_dependencies)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -9,6 +9,7 @@ module ObsDeploy
9
9
  @server = opts[:server] || 'localhost'
10
10
  @port = opts[:port] || 22
11
11
  @identity_file = opts[:identity_file]
12
+ @debug = opts[:debug] || false
12
13
  end
13
14
 
14
15
  def build_command
@@ -18,9 +19,15 @@ module ObsDeploy
18
19
  end
19
20
 
20
21
  def run(cmd)
21
- results, errors = Cheetah.run(build_command + cmd, stdout: :capture, stderr: :capture)
22
- puts results
23
- puts errors
22
+ Cheetah.run(build_command + cmd, logger: logger)
23
+ end
24
+
25
+ def logger
26
+ Logger.new(STDOUT, level: logger_level)
27
+ end
28
+
29
+ def logger_level
30
+ @debug ? Logger::DEBUG : Logger::INFO
24
31
  end
25
32
  end
26
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ObsDeploy
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.5'
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ObsDeploy
4
+ class Zypper
5
+ def update(dry_run: true)
6
+ if dry_run
7
+ run ['zypper'] + update_params + dry_run_params + package_name
8
+ else
9
+ run ['zypper'] + update_params + package_name
10
+ end
11
+ end
12
+
13
+ def refresh
14
+ run ['zypper', '--non-interactive', '--gpg-auto-import-keys', 'refresh']
15
+ end
16
+
17
+ private
18
+
19
+ def run(params)
20
+ params
21
+ end
22
+
23
+ def package_name
24
+ ['obs-api']
25
+ end
26
+
27
+ def update_params
28
+ ['--non-interactive', 'update', '--best-effort', '--details']
29
+ end
30
+
31
+ def dry_run_params
32
+ ['--dry-run --download-only']
33
+ end
34
+ end
35
+ end
data/lib/systemctl.rb ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ObsDeploy
4
+ class Systemctl
5
+ def status
6
+ run ['systemctl'] + ['status'] + target
7
+ end
8
+
9
+ def list_dependencies
10
+ run ['systemctl'] + ['list-dependencies'] + target
11
+ end
12
+
13
+ private
14
+
15
+ def target
16
+ ['obs-api-support.target']
17
+ end
18
+
19
+ def run(params)
20
+ params + ['--no-pager']
21
+ end
22
+ end
23
+ end
data/obs_deploy.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 2.0'
31
31
  spec.add_development_dependency 'pry'
32
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rake', '~> 13.0'
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'rubocop'
35
35
  spec.add_development_dependency 'webmock'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obs_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pereira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,7 @@ files:
150
150
  - ".gitignore"
151
151
  - ".rspec"
152
152
  - ".travis.yml"
153
+ - Dockerfile
153
154
  - Gemfile
154
155
  - Gemfile.lock
155
156
  - README.md
@@ -159,6 +160,7 @@ files:
159
160
  - bin/setup
160
161
  - dist/Makefile
161
162
  - dist/rubygem-obs_deploy.spec
163
+ - entrypoint.sh
162
164
  - lib/obs_deploy.rb
163
165
  - lib/obs_deploy/check_diff.rb
164
166
  - lib/obs_deploy/cli/commands.rb
@@ -166,9 +168,12 @@ files:
166
168
  - lib/obs_deploy/cli/commands/get_deployed_version.rb
167
169
  - lib/obs_deploy/cli/commands/get_package_version.rb
168
170
  - lib/obs_deploy/cli/commands/refresh_repositories.rb
171
+ - lib/obs_deploy/cli/commands/systemctl.rb
169
172
  - lib/obs_deploy/cli/commands/version.rb
170
173
  - lib/obs_deploy/ssh.rb
171
174
  - lib/obs_deploy/version.rb
175
+ - lib/obs_deploy/zypper.rb
176
+ - lib/systemctl.rb
172
177
  - obs_deploy.gemspec
173
178
  homepage: https://openbuildservice.org
174
179
  licenses: []