obs_deploy 0.2.4 → 0.3.3
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 +4 -4
- data/Dockerfile.dev +8 -0
- data/{Dockerfile → Dockerfile.rpm} +0 -0
- data/Gemfile.lock +7 -5
- data/Makefile +9 -0
- data/README.md +13 -1
- data/dist/Makefile +1 -1
- data/dist/_service +9 -1
- data/dist/rubygem-obs_deploy.spec +3 -6
- data/lib/obs_deploy.rb +1 -0
- data/lib/obs_deploy/apache_sysconfig.rb +43 -8
- data/lib/obs_deploy/check_diff.rb +9 -3
- data/lib/obs_deploy/cli/commands.rb +8 -6
- data/lib/obs_deploy/cli/commands/get_diff.rb +20 -0
- data/lib/obs_deploy/cli/commands/refresh_repositories.rb +1 -2
- data/lib/obs_deploy/version.rb +1 -1
- data/lib/obs_deploy/zypper.rb +19 -4
- metadata +10 -8
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31f63b8788107bedb1301441ad228264914e7bee05fde3818b293c6c65601ca5
|
|
4
|
+
data.tar.gz: 06a350ca3015869e292b5f1303e4155abd7d5d7cb751bb8e607b15135834bdad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c13028e79c56e20c27dabfa96f5abc3e2896ca83ac3b05df3ccfc78d52bb8e4f66aad42b45898dfe190acab54ed5b5d1ca6e67420452737e33fe7ed4381ca26c
|
|
7
|
+
data.tar.gz: 56c9454fd932d2516e2c6979eef5f7654b631a6c6e7effabfe6598efb5c170d10b08403492e23ed234fc9276712dd3de9dab80549678a1b3c0bd6602a39abdf5
|
data/Dockerfile.dev
ADDED
|
File without changes
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
obs_deploy (0.
|
|
4
|
+
obs_deploy (0.3.3)
|
|
5
5
|
cheetah
|
|
6
6
|
dry-cli
|
|
7
7
|
nokogiri
|
|
@@ -16,7 +16,7 @@ GEM
|
|
|
16
16
|
cheetah (0.5.2)
|
|
17
17
|
abstract_method (~> 1.2)
|
|
18
18
|
coderay (1.1.2)
|
|
19
|
-
concurrent-ruby (1.1.
|
|
19
|
+
concurrent-ruby (1.1.7)
|
|
20
20
|
crack (0.4.3)
|
|
21
21
|
safe_yaml (~> 1.0.0)
|
|
22
22
|
diff-lcs (1.3)
|
|
@@ -25,9 +25,10 @@ GEM
|
|
|
25
25
|
hashdiff (1.0.1)
|
|
26
26
|
jaro_winkler (1.5.4)
|
|
27
27
|
method_source (1.0.0)
|
|
28
|
-
mini_portile2 (2.
|
|
29
|
-
nokogiri (1.
|
|
30
|
-
mini_portile2 (~> 2.
|
|
28
|
+
mini_portile2 (2.5.0)
|
|
29
|
+
nokogiri (1.11.0)
|
|
30
|
+
mini_portile2 (~> 2.5.0)
|
|
31
|
+
racc (~> 1.4)
|
|
31
32
|
parallel (1.19.1)
|
|
32
33
|
parser (2.7.0.5)
|
|
33
34
|
ast (~> 2.4.0)
|
|
@@ -35,6 +36,7 @@ GEM
|
|
|
35
36
|
coderay (~> 1.1)
|
|
36
37
|
method_source (~> 1.0)
|
|
37
38
|
public_suffix (4.0.3)
|
|
39
|
+
racc (1.5.2)
|
|
38
40
|
rainbow (3.0.0)
|
|
39
41
|
rake (13.0.1)
|
|
40
42
|
rexml (3.2.4)
|
data/Makefile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
docker-dev:
|
|
2
|
+
docker build -f Dockerfile.dev -t $(USER)/obs_deploy_dev .
|
|
3
|
+
docker run --rm -it -v "$(HOME)/.ssh:/tmp/.ssh:ro" -v "$(PWD):/obs_deploy" $(USER)/obs_deploy_dev bash
|
|
4
|
+
|
|
5
|
+
docker-rpm:
|
|
6
|
+
docker build -f Dockerfile.rpm -t $(USER)/obs_deploy_dev .
|
|
7
|
+
docker run --rm -it -v "$(HOME)/.ssh:/tmp/.ssh:ro" -v "$(PWD):/obs_deploy" $(USER)/obs_deploy_dev bash
|
|
8
|
+
|
|
9
|
+
|
data/README.md
CHANGED
|
@@ -5,6 +5,9 @@ Simple tool to deploy OBS via zypper to our reference server
|
|
|
5
5
|
## Build Status
|
|
6
6
|
[](https://app.circleci.com/pipelines/github/vpereira/obs_deploy)
|
|
7
7
|
|
|
8
|
+
## Codebeat
|
|
9
|
+
[](https://codebeat.co/projects/github-com-vpereira-obs_deploy-master)
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
## Installation
|
|
10
13
|
|
|
@@ -84,7 +87,7 @@ if you want to run it against the OBS appliance running on VirtualBox:
|
|
|
84
87
|
- then run the container as:
|
|
85
88
|
|
|
86
89
|
```
|
|
87
|
-
docker
|
|
90
|
+
make docker-dev
|
|
88
91
|
```
|
|
89
92
|
Now you are inside the container and should be able to ping the obs appliance.
|
|
90
93
|
|
|
@@ -101,6 +104,15 @@ If you want to add new command to the cli, please read the `dry-cli` documentati
|
|
|
101
104
|
|
|
102
105
|
The commands are being sent via ssh and ssh is being called via `cheetah` https://github.com/openSUSE/cheetah. Please Read the `ssh.rb` file, specially the `SSH#run` method
|
|
103
106
|
|
|
107
|
+
## RPM Building
|
|
108
|
+
|
|
109
|
+
Under dist/ we have the necessary files to use to build the gem as rpm. The
|
|
110
|
+
`_service` still not used. Mainly because we need either to build the rubygem
|
|
111
|
+
dependencies or use https://github.com/openSUSE/obs-service-bundle_gems
|
|
112
|
+
|
|
113
|
+
Today as it is, you have to push the gem to rubygems and then generate the spec
|
|
114
|
+
and push it to build service
|
|
115
|
+
|
|
104
116
|
## Contributing
|
|
105
117
|
|
|
106
118
|
Bug reports and pull requests are welcome on GitHub at https://github.com/vpereira/obs_deploy.
|
data/dist/Makefile
CHANGED
data/dist/_service
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
<services>
|
|
2
|
-
<service name="
|
|
2
|
+
<service name="tar_scm">
|
|
3
|
+
<param name="scm">git</param>
|
|
4
|
+
<param name="url">git://github.com/vpereira/obs_deploy.git</param>
|
|
5
|
+
<param name="revision">master</param>
|
|
6
|
+
<param name="version">0.2.0</param>
|
|
3
7
|
</service>
|
|
8
|
+
<service name="recompress">
|
|
9
|
+
<param name="file">*.tar</param>
|
|
10
|
+
<param name="compression">xz</param>
|
|
11
|
+
</service>
|
|
4
12
|
</services>
|
|
@@ -18,23 +18,21 @@
|
|
|
18
18
|
|
|
19
19
|
%define mod_name obs_deploy
|
|
20
20
|
%define mod_full_name %{mod_name}-%{version}
|
|
21
|
-
%define rb_suffix ruby2.6
|
|
22
21
|
Name: rubygem-obs_deploy
|
|
23
|
-
Version: 0.
|
|
22
|
+
Version: 0.3.0
|
|
24
23
|
Release: 0
|
|
25
24
|
Summary: OBS Deployment tool
|
|
26
|
-
License:
|
|
25
|
+
License:
|
|
27
26
|
Group: Development/Languages/Ruby
|
|
28
27
|
URL: https://openbuildservice.org
|
|
29
28
|
Source: https://rubygems.org/gems/%{mod_full_name}.gem
|
|
30
29
|
BuildRequires: %{rubygem gem2rpm}
|
|
31
30
|
BuildRequires: %{ruby}
|
|
32
31
|
BuildRequires: ruby-macros >= 5
|
|
33
|
-
BuildRequires:
|
|
32
|
+
BuildRequires: update-alternatives
|
|
34
33
|
# FIXME: use proper Requires(pre/post/preun/...)
|
|
35
34
|
PreReq: update-alternatives
|
|
36
35
|
|
|
37
|
-
|
|
38
36
|
%description
|
|
39
37
|
OBS Deployment tool.
|
|
40
38
|
|
|
@@ -43,7 +41,6 @@ OBS Deployment tool.
|
|
|
43
41
|
%build
|
|
44
42
|
|
|
45
43
|
%install
|
|
46
|
-
%rails_fix_ruby_shebang bin/
|
|
47
44
|
%gem_install \
|
|
48
45
|
--symlink-binaries \
|
|
49
46
|
--doc-files="README.md" \
|
data/lib/obs_deploy.rb
CHANGED
|
@@ -2,29 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
module ObsDeploy
|
|
4
4
|
class ApacheSysconfig
|
|
5
|
-
attr_reader :
|
|
5
|
+
attr_reader :path
|
|
6
6
|
|
|
7
7
|
def initialize
|
|
8
|
-
@
|
|
8
|
+
@path = '/etc/sysconfig/apache2'
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def enable_maintenance_mode
|
|
12
|
-
|
|
12
|
+
unless maintenance_mode?
|
|
13
|
+
content = File.read(path).gsub(/^#{server_flags}=\"STATUS\"$/,
|
|
14
|
+
apache_status_line(maintenance))
|
|
15
|
+
write_apache_sysconfig(content)
|
|
16
|
+
end
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
def disable_maintenance_mode
|
|
16
|
-
|
|
20
|
+
if maintenance_mode?
|
|
21
|
+
content = File.read(path).gsub(/^#{server_flags}=\"STATUS MAINTENANCE\"/,
|
|
22
|
+
apache_status_line(no_maintenance))
|
|
23
|
+
write_apache_sysconfig(content)
|
|
24
|
+
end
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
def maintenance_mode?
|
|
20
|
-
|
|
28
|
+
find_server_flags.all? { |r| r.include?('MAINTENANCE') }
|
|
21
29
|
end
|
|
22
30
|
|
|
23
31
|
private
|
|
24
32
|
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
def no_maintenance
|
|
34
|
+
'STATUS'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def maintenance
|
|
38
|
+
'STATUS MAINTENANCE'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def server_flags
|
|
42
|
+
'APACHE_SERVER_FLAGS'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def apache_status_line(status)
|
|
46
|
+
"#{server_flags}=\"#{status}\""
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def find_server_flags
|
|
50
|
+
File.readlines(path).grep(/^#{server_flags}=/)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def write_apache_sysconfig(content)
|
|
54
|
+
f = Tempfile.new
|
|
55
|
+
f.write(content)
|
|
56
|
+
begin
|
|
57
|
+
File.rename(f.path, path)
|
|
58
|
+
rescue SystemCallError => e
|
|
59
|
+
puts e.inspect
|
|
60
|
+
ensure
|
|
61
|
+
f.unlink
|
|
62
|
+
f.close
|
|
28
63
|
end
|
|
29
64
|
end
|
|
30
65
|
end
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module ObsDeploy
|
|
4
4
|
class CheckDiff
|
|
5
|
-
def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4')
|
|
5
|
+
def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4', project: 'OBS:Server:Unstable', target_server: 'https://api.opensuse.org')
|
|
6
6
|
@server = server
|
|
7
7
|
@product = product
|
|
8
|
+
@project = project
|
|
9
|
+
@target_server = target_server
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def package_version
|
|
@@ -25,6 +27,10 @@ module ObsDeploy
|
|
|
25
27
|
Net::HTTP.get(URI("https://github.com/openSUSE/open-build-service/compare/#{obs_running_commit}...#{package_commit}.diff"))
|
|
26
28
|
end
|
|
27
29
|
|
|
30
|
+
def new_version_available?
|
|
31
|
+
obs_running_commit != package_commit
|
|
32
|
+
end
|
|
33
|
+
|
|
28
34
|
def has_migration?
|
|
29
35
|
return true if github_diff.nil? || github_diff.empty?
|
|
30
36
|
|
|
@@ -50,11 +56,11 @@ module ObsDeploy
|
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
def package_url
|
|
53
|
-
URI("#{@server}/public/build
|
|
59
|
+
URI("#{@server}/public/build/#{@project}/#{@product}/x86_64/obs-server")
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
def about_url
|
|
57
|
-
URI("#{@
|
|
63
|
+
URI("#{@target_server}/about")
|
|
58
64
|
end
|
|
59
65
|
end
|
|
60
66
|
end
|
|
@@ -11,15 +11,17 @@ module ObsDeploy
|
|
|
11
11
|
autoload :GetDeployedVersion, File.join(__dir__, 'commands/get_deployed_version.rb')
|
|
12
12
|
autoload :Systemctl, File.join(__dir__, 'commands/systemctl.rb')
|
|
13
13
|
autoload :GetPendingMigration, File.join(__dir__, 'commands/get_pending_migration.rb')
|
|
14
|
+
autoload :GetDiff, File.join(__dir__, 'commands/get_diff.rb')
|
|
14
15
|
|
|
15
16
|
# register the commands and its command line
|
|
16
|
-
register 'available-package', GetPackageVersion
|
|
17
|
-
register 'deployed-version', GetDeployedVersion
|
|
17
|
+
register 'available-package', GetPackageVersion, aliases: ['ap']
|
|
18
|
+
register 'deployed-version', GetDeployedVersion, aliases: ['dv']
|
|
18
19
|
register 'version', Version, aliases: ['v', '-v', '--version']
|
|
19
|
-
register 'deploy', Deploy
|
|
20
|
-
register 'refresh-repositories', RefreshRepositories
|
|
21
|
-
register 'systemctl', Systemctl
|
|
22
|
-
register 'pending-migrations', GetPendingMigration
|
|
20
|
+
register 'deploy', Deploy, aliases: ['dp']
|
|
21
|
+
register 'refresh-repositories', RefreshRepositories, aliases: ['rr']
|
|
22
|
+
register 'systemctl', Systemctl, aliases: ['sys']
|
|
23
|
+
register 'pending-migrations', GetPendingMigration, aliases: ['pm']
|
|
24
|
+
register 'check-diff', GetDiff, aliases: ['cd']
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
module CLI
|
|
5
|
+
module Commands
|
|
6
|
+
class GetDiff < Dry::CLI::Command
|
|
7
|
+
desc 'Get diff between deployed package and available package'
|
|
8
|
+
option :url, type: :string, default: 'https://api.opensuse.org', desc: 'API url'
|
|
9
|
+
option :package, type: :string, default: 'obs-api', desc: 'Package name'
|
|
10
|
+
option :project, type: :string, default: 'OBS:Server:Unstable', desc: 'Project name'
|
|
11
|
+
option :product, type: :string, default: 'SLE_12_SP4', desc: 'Product name'
|
|
12
|
+
option :architecture, type: :string, default: 'x86_64', desc: 'Architecture'
|
|
13
|
+
|
|
14
|
+
def call(url:, product:, project:, **)
|
|
15
|
+
puts "diff : #{ObsDeploy::CheckDiff.new(server: url, project: project, product: product).github_diff}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -6,13 +6,12 @@ module ObsDeploy
|
|
|
6
6
|
class RefreshRepositories < Dry::CLI::Command
|
|
7
7
|
desc 'Refresh zypper repositories'
|
|
8
8
|
option :user, type: :string, default: 'root', desc: 'User'
|
|
9
|
-
option :dry_run, type: :bool, default: true, desc: 'Dry run'
|
|
10
9
|
option :host, type: :string, default: 'localhost', desc: 'Set the server address'
|
|
11
10
|
option :port, type: :int, default: 22, desc: 'Set the server port'
|
|
12
11
|
|
|
13
12
|
def call(user:, dry_run:, host:, port:, **)
|
|
14
13
|
ssh_driver = ObsDeploy::SSH.new(user: user, server: host, port: port)
|
|
15
|
-
zypper = ObsDeploy::Zypper.new
|
|
14
|
+
zypper = ObsDeploy::Zypper.new(dry_run: dry_run)
|
|
16
15
|
ssh_driver.run(zypper.refresh)
|
|
17
16
|
end
|
|
18
17
|
end
|
data/lib/obs_deploy/version.rb
CHANGED
data/lib/obs_deploy/zypper.rb
CHANGED
|
@@ -10,11 +10,26 @@ module ObsDeploy
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def update
|
|
13
|
-
run [
|
|
13
|
+
run %w[zypper] + update_string + package_name
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def refresh
|
|
17
|
-
run [
|
|
17
|
+
run %w[zypper --non-interactive --gpg-auto-import-keys refresh]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# TODO
|
|
21
|
+
# check if we want to lock from specific repositories
|
|
22
|
+
def add_lock
|
|
23
|
+
run %w[zypper addlock] + package_name
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def remove_lock
|
|
27
|
+
run %w[zypper removelock] + package_name
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def locked?
|
|
31
|
+
# check the return value
|
|
32
|
+
run %w[zypper locks] + package_name
|
|
18
33
|
end
|
|
19
34
|
|
|
20
35
|
private
|
|
@@ -36,11 +51,11 @@ module ObsDeploy
|
|
|
36
51
|
end
|
|
37
52
|
|
|
38
53
|
def update_params
|
|
39
|
-
[
|
|
54
|
+
%w[--non-interactive update --best-effort --details]
|
|
40
55
|
end
|
|
41
56
|
|
|
42
57
|
def dry_run_params
|
|
43
|
-
[
|
|
58
|
+
%w[--dry-run --download-only]
|
|
44
59
|
end
|
|
45
60
|
end
|
|
46
61
|
end
|
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.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Victor Pereira
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -136,7 +136,7 @@ dependencies:
|
|
|
136
136
|
- - ">="
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: '0'
|
|
139
|
-
description:
|
|
139
|
+
description:
|
|
140
140
|
email:
|
|
141
141
|
- vpereira@suse.de
|
|
142
142
|
executables:
|
|
@@ -150,10 +150,11 @@ files:
|
|
|
150
150
|
- ".gitignore"
|
|
151
151
|
- ".rspec"
|
|
152
152
|
- ".rubocop.yml"
|
|
153
|
-
-
|
|
154
|
-
- Dockerfile
|
|
153
|
+
- Dockerfile.dev
|
|
154
|
+
- Dockerfile.rpm
|
|
155
155
|
- Gemfile
|
|
156
156
|
- Gemfile.lock
|
|
157
|
+
- Makefile
|
|
157
158
|
- README.md
|
|
158
159
|
- Rakefile
|
|
159
160
|
- bin/console
|
|
@@ -169,6 +170,7 @@ files:
|
|
|
169
170
|
- lib/obs_deploy/cli/commands.rb
|
|
170
171
|
- lib/obs_deploy/cli/commands/deploy.rb
|
|
171
172
|
- lib/obs_deploy/cli/commands/get_deployed_version.rb
|
|
173
|
+
- lib/obs_deploy/cli/commands/get_diff.rb
|
|
172
174
|
- lib/obs_deploy/cli/commands/get_package_version.rb
|
|
173
175
|
- lib/obs_deploy/cli/commands/get_pending_migration.rb
|
|
174
176
|
- lib/obs_deploy/cli/commands/refresh_repositories.rb
|
|
@@ -185,7 +187,7 @@ metadata:
|
|
|
185
187
|
allowed_push_host: https://rubygems.org
|
|
186
188
|
homepage_uri: https://openbuildservice.org
|
|
187
189
|
source_code_uri: https://github.com/vpereira/obs_deploy.git
|
|
188
|
-
post_install_message:
|
|
190
|
+
post_install_message:
|
|
189
191
|
rdoc_options: []
|
|
190
192
|
require_paths:
|
|
191
193
|
- lib
|
|
@@ -201,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
201
203
|
version: '0'
|
|
202
204
|
requirements: []
|
|
203
205
|
rubygems_version: 3.0.6
|
|
204
|
-
signing_key:
|
|
206
|
+
signing_key:
|
|
205
207
|
specification_version: 4
|
|
206
208
|
summary: OBS Deployment tool
|
|
207
209
|
test_files: []
|