caco 0.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 +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +227 -0
- data/Guardfile +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +97 -0
- data/Rakefile +10 -0
- data/bin/_guard-core +29 -0
- data/bin/bundle +114 -0
- data/bin/byebug +29 -0
- data/bin/caco +29 -0
- data/bin/coderay +29 -0
- data/bin/console +20 -0
- data/bin/eyaml +29 -0
- data/bin/guard +29 -0
- data/bin/listen +29 -0
- data/bin/pry +29 -0
- data/bin/rake +29 -0
- data/bin/safe_yaml +29 -0
- data/bin/setup +8 -0
- data/bin/thor +29 -0
- data/bin/tilt +29 -0
- data/caco.gemspec +43 -0
- data/exe/caco +27 -0
- data/lib/caco.rb +115 -0
- data/lib/caco/barman.rb +10 -0
- data/lib/caco/barman/cell/global.rb +4 -0
- data/lib/caco/barman/cell/node.rb +15 -0
- data/lib/caco/barman/install.rb +25 -0
- data/lib/caco/barman/view/global.erb +7 -0
- data/lib/caco/barman/view/node.erb +8 -0
- data/lib/caco/cell.rb +8 -0
- data/lib/caco/config.rb +23 -0
- data/lib/caco/debian.rb +28 -0
- data/lib/caco/debian/add_user.rb +18 -0
- data/lib/caco/debian/apt_key_install.rb +19 -0
- data/lib/caco/debian/apt_repo_add.rb +17 -0
- data/lib/caco/debian/apt_sources_list.rb +15 -0
- data/lib/caco/debian/apt_update.rb +33 -0
- data/lib/caco/debian/cell/service.rb +19 -0
- data/lib/caco/debian/cell/sources_list.rb +7 -0
- data/lib/caco/debian/package_install.rb +21 -0
- data/lib/caco/debian/package_installed.rb +17 -0
- data/lib/caco/debian/service_enable.rb +26 -0
- data/lib/caco/debian/service_install.rb +31 -0
- data/lib/caco/debian/user_home.rb +17 -0
- data/lib/caco/debian/view/service.erb +18 -0
- data/lib/caco/debian/view/sources_list.erb +10 -0
- data/lib/caco/downloader.rb +41 -0
- data/lib/caco/executer.rb +33 -0
- data/lib/caco/facter.rb +41 -0
- data/lib/caco/file_link.rb +36 -0
- data/lib/caco/file_reader.rb +24 -0
- data/lib/caco/file_writer.rb +57 -0
- data/lib/caco/finder.rb +13 -0
- data/lib/caco/grafana.rb +6 -0
- data/lib/caco/grafana/install.rb +26 -0
- data/lib/caco/haproxy.rb +12 -0
- data/lib/caco/haproxy/cell/conf_postgres.rb +4 -0
- data/lib/caco/haproxy/cell/conf_stats.rb +4 -0
- data/lib/caco/haproxy/conf_get.rb +15 -0
- data/lib/caco/haproxy/conf_set.rb +52 -0
- data/lib/caco/haproxy/install.rb +9 -0
- data/lib/caco/haproxy/view/conf_postgres.erb +25 -0
- data/lib/caco/haproxy/view/conf_stats.erb +6 -0
- data/lib/caco/macro.rb +2 -0
- data/lib/caco/postgres.rb +44 -0
- data/lib/caco/postgres/build_augeas.rb +20 -0
- data/lib/caco/postgres/conf_get.rb +37 -0
- data/lib/caco/postgres/conf_set.rb +54 -0
- data/lib/caco/postgres/database_create.rb +28 -0
- data/lib/caco/postgres/extension_create.rb +28 -0
- data/lib/caco/postgres/hba_set.rb +65 -0
- data/lib/caco/postgres/install.rb +34 -0
- data/lib/caco/postgres/shell.rb +13 -0
- data/lib/caco/postgres/sql.rb +17 -0
- data/lib/caco/postgres/user_change_password.rb +13 -0
- data/lib/caco/postgres/user_create.rb +33 -0
- data/lib/caco/prometheus.rb +15 -0
- data/lib/caco/prometheus/adapter_install_pg.rb +107 -0
- data/lib/caco/prometheus/adapter_install_postgresql.rb +47 -0
- data/lib/caco/prometheus/cell/alertmanager_conf.rb +4 -0
- data/lib/caco/prometheus/cell/alerts.rb +4 -0
- data/lib/caco/prometheus/cell/conf.rb +7 -0
- data/lib/caco/prometheus/exporter_install.rb +35 -0
- data/lib/caco/prometheus/install.rb +50 -0
- data/lib/caco/prometheus/install_alert_manager.rb +62 -0
- data/lib/caco/prometheus/view/alertmanager_conf.erb +13 -0
- data/lib/caco/prometheus/view/alerts.erb +18 -0
- data/lib/caco/prometheus/view/conf.erb +34 -0
- data/lib/caco/rbenv.rb +8 -0
- data/lib/caco/rbenv/cell/profile.rb +4 -0
- data/lib/caco/rbenv/install.rb +56 -0
- data/lib/caco/rbenv/install_version.rb +17 -0
- data/lib/caco/rbenv/view/profile.erb +3 -0
- data/lib/caco/repmgr.rb +15 -0
- data/lib/caco/repmgr/cell/conf.rb +43 -0
- data/lib/caco/repmgr/conf.rb +25 -0
- data/lib/caco/repmgr/install.rb +25 -0
- data/lib/caco/repmgr/node_register_primary.rb +34 -0
- data/lib/caco/repmgr/node_register_standby.rb +25 -0
- data/lib/caco/repmgr/node_registered.rb +15 -0
- data/lib/caco/repmgr/node_role.rb +18 -0
- data/lib/caco/repmgr/view/conf.erb +27 -0
- data/lib/caco/settings_loader.rb +67 -0
- data/lib/caco/settings_loader_monkeypatch.rb +28 -0
- data/lib/caco/ssh.rb +6 -0
- data/lib/caco/ssh/authorized_keys_add.rb +82 -0
- data/lib/caco/sudo.rb +6 -0
- data/lib/caco/sudo/sudoers_add.rb +15 -0
- data/lib/caco/timescale.rb +6 -0
- data/lib/caco/timescale/install.rb +25 -0
- data/lib/caco/unpacker.rb +76 -0
- data/lib/caco/version.rb +3 -0
- metadata +398 -0
data/bin/setup
ADDED
data/bin/thor
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'thor' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("thor", "thor")
|
data/bin/tilt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'tilt' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("tilt", "tilt")
|
data/caco.gemspec
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "caco/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "caco"
|
|
8
|
+
spec.version = Caco::VERSION
|
|
9
|
+
spec.authors = ["Celso Fernandes"]
|
|
10
|
+
spec.email = ["celso.fernandes@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Caco, The Frog}
|
|
13
|
+
spec.description = %q{Caco, configure your machines like you develop your web apps}
|
|
14
|
+
spec.homepage = "https://github.com/fernandes/caco"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = "exe"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_dependency "cells-erb", "~> 0.1"
|
|
27
|
+
spec.add_dependency "cells", "~> 4.1"
|
|
28
|
+
spec.add_dependency "config"
|
|
29
|
+
spec.add_dependency "down", "~> 5.0"
|
|
30
|
+
spec.add_dependency "hiera-eyaml"
|
|
31
|
+
spec.add_dependency "http", "~> 4.0"
|
|
32
|
+
spec.add_dependency "marcel"
|
|
33
|
+
spec.add_dependency "ruby-augeas"
|
|
34
|
+
spec.add_dependency "trailblazer-cells"
|
|
35
|
+
spec.add_dependency "trailblazer", "~> 2.1"
|
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
37
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
39
|
+
spec.add_development_dependency "minitest-reporters"
|
|
40
|
+
spec.add_development_dependency "trailblazer-developer"
|
|
41
|
+
spec.add_development_dependency "fakefs"
|
|
42
|
+
spec.add_development_dependency "webmock"
|
|
43
|
+
end
|
data/exe/caco
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "caco"
|
|
4
|
+
|
|
5
|
+
ENV['CACO_ENV'] ||= 'development'
|
|
6
|
+
APP_PATH = Bundler.root
|
|
7
|
+
|
|
8
|
+
Caco.root = Pathname.new(APP_PATH)
|
|
9
|
+
|
|
10
|
+
Caco::SettingsLoader.(params: {
|
|
11
|
+
keys_path: Caco.root.join("keys"),
|
|
12
|
+
data_path: Caco.root.join("data")
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
# puts "starting"
|
|
16
|
+
|
|
17
|
+
fqdn = Caco::Facter.("networking", "fqdn")
|
|
18
|
+
puts "[Caco] Running for: #{fqdn}"
|
|
19
|
+
|
|
20
|
+
begin
|
|
21
|
+
require Caco.root.join("nodes", fqdn)
|
|
22
|
+
rescue LoadError => e
|
|
23
|
+
path = Caco.root.join("nodes", fqdn).to_s
|
|
24
|
+
puts "Could not find manifest at #{path}.rb"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# puts "finishing"
|
data/lib/caco.rb
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Ruby Dependencies
|
|
2
|
+
require 'delegate'
|
|
3
|
+
require 'digest'
|
|
4
|
+
require 'erb'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'open3'
|
|
7
|
+
|
|
8
|
+
# Gems
|
|
9
|
+
require 'augeas'
|
|
10
|
+
require 'cells-erb'
|
|
11
|
+
require 'config'
|
|
12
|
+
require 'declarative'
|
|
13
|
+
# Monkey Patching to remove !Warning!
|
|
14
|
+
module Declarative
|
|
15
|
+
class Defaults
|
|
16
|
+
def handle_array_and_deprecate(variables)
|
|
17
|
+
wrapped = Defaults.wrap_arrays(variables)
|
|
18
|
+
|
|
19
|
+
variables.merge(wrapped)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require 'down'
|
|
25
|
+
require 'down/http'
|
|
26
|
+
Down.backend Down::Http
|
|
27
|
+
|
|
28
|
+
require 'hiera/backend/eyaml'
|
|
29
|
+
require 'hiera/backend/eyaml/options'
|
|
30
|
+
require 'hiera/backend/eyaml/parser/parser'
|
|
31
|
+
require 'marcel'
|
|
32
|
+
require 'trailblazer'
|
|
33
|
+
require 'trailblazer/cells'
|
|
34
|
+
|
|
35
|
+
# System (order dependant)
|
|
36
|
+
require "caco/config"
|
|
37
|
+
require "caco/macro"
|
|
38
|
+
require "caco/executer"
|
|
39
|
+
|
|
40
|
+
require "caco/facter"
|
|
41
|
+
require "caco/file_writer"
|
|
42
|
+
require "caco/file_reader"
|
|
43
|
+
require "caco/file_link"
|
|
44
|
+
require "caco/downloader"
|
|
45
|
+
require "caco/finder"
|
|
46
|
+
require "caco/unpacker"
|
|
47
|
+
require "caco/settings_loader"
|
|
48
|
+
require "caco/version"
|
|
49
|
+
|
|
50
|
+
# modules
|
|
51
|
+
require "caco/debian"
|
|
52
|
+
|
|
53
|
+
require "caco/barman"
|
|
54
|
+
require "caco/grafana"
|
|
55
|
+
require "caco/haproxy"
|
|
56
|
+
require "caco/postgres"
|
|
57
|
+
require "caco/prometheus"
|
|
58
|
+
require "caco/rbenv"
|
|
59
|
+
require "caco/repmgr"
|
|
60
|
+
require "caco/ssh"
|
|
61
|
+
require "caco/sudo"
|
|
62
|
+
require "caco/timescale"
|
|
63
|
+
|
|
64
|
+
module Caco
|
|
65
|
+
class << self
|
|
66
|
+
attr_accessor :root
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class Error < StandardError; end
|
|
70
|
+
# Your code goes here...
|
|
71
|
+
|
|
72
|
+
class FixtureNotExist < StandardError; end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
module Cell
|
|
76
|
+
# Erb contains helpers that are messed up in Rails and do escaping.
|
|
77
|
+
module Erb
|
|
78
|
+
def template_options_for(_options)
|
|
79
|
+
{
|
|
80
|
+
template_class: ::Tilt::ERBTemplate,
|
|
81
|
+
escape_html: false,
|
|
82
|
+
escape_attrs: false,
|
|
83
|
+
suffix: "erb"
|
|
84
|
+
}
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class Trailblazer::Cell
|
|
90
|
+
include Cell::Erb
|
|
91
|
+
self.view_paths = [File.expand_path("../", __FILE__)]
|
|
92
|
+
|
|
93
|
+
def property(key)
|
|
94
|
+
return nil if model.nil?
|
|
95
|
+
return nil unless model.has_key?(key) and model.is_a?(Hash)
|
|
96
|
+
return model[key]
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class Trailblazer::Operation
|
|
101
|
+
class InvalidParam < StandardError; end
|
|
102
|
+
|
|
103
|
+
def p(message)
|
|
104
|
+
method_name = (caller[0] =~ /`([^']*)'/ and $1)
|
|
105
|
+
puts "#{self.class}##{method_name}: #{message}"
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def trbreaks(klass = nil)
|
|
110
|
+
bind_to = klass.nil? ? self.class : klass
|
|
111
|
+
bind_to.instance_methods(false).each do |m|
|
|
112
|
+
Pry::Byebug::Breakpoints.add_method("#{bind_to}##{m}")
|
|
113
|
+
end
|
|
114
|
+
true
|
|
115
|
+
end
|
data/lib/caco/barman.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Caco::Barman
|
|
2
|
+
class Install < Trailblazer::Operation
|
|
3
|
+
class Repo < Trailblazer::Operation
|
|
4
|
+
step Subprocess(Caco::Debian::AptKeyInstall),
|
|
5
|
+
input: ->(_ctx, **) {{
|
|
6
|
+
url: 'https://dl.2ndquadrant.com/gpg-key.asc',
|
|
7
|
+
fingerprint: '8565 305C EA7D 0B66 4933 D250 9904 CD4B D6BA F0C3'
|
|
8
|
+
}}
|
|
9
|
+
step Subprocess(Caco::Debian::AptRepoAdd),
|
|
10
|
+
input: ->(_ctx, **) {{
|
|
11
|
+
name: '2ndquadrant-dl-default-release',
|
|
12
|
+
url: 'https://dl.2ndquadrant.com/default/release/apt',
|
|
13
|
+
release: "#{Caco::Facter.("os", "distro", "codename")}-2ndquadrant",
|
|
14
|
+
component: 'main'
|
|
15
|
+
}}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
step Subprocess(Repo)
|
|
19
|
+
step Subprocess(Caco::Debian::AptUpdate)
|
|
20
|
+
step Subprocess(Caco::Debian::PackageInstall),
|
|
21
|
+
input: ->(_ctx, **) {{
|
|
22
|
+
package: 'barman'
|
|
23
|
+
}}
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/caco/cell.rb
ADDED
data/lib/caco/config.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Caco
|
|
2
|
+
class << self
|
|
3
|
+
attr_accessor :config
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def self.configure
|
|
7
|
+
self.config ||= Configuration.new
|
|
8
|
+
yield(config)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Configuration
|
|
12
|
+
attr_accessor :root
|
|
13
|
+
attr_accessor :eyaml_parser
|
|
14
|
+
attr_accessor :write_files
|
|
15
|
+
attr_accessor :write_files_root
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@root = 'donotreply@example.com'
|
|
19
|
+
@write_files = true
|
|
20
|
+
@write_files_root = nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/caco/debian.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'caco/debian/apt_repo_add'
|
|
2
|
+
require 'caco/debian/apt_key_install'
|
|
3
|
+
require 'caco/debian/apt_sources_list'
|
|
4
|
+
require 'caco/debian/apt_update'
|
|
5
|
+
require 'caco/debian/package_installed'
|
|
6
|
+
require 'caco/debian/package_install'
|
|
7
|
+
require 'caco/debian/service_enable'
|
|
8
|
+
require 'caco/debian/service_install'
|
|
9
|
+
require 'caco/debian/user_home'
|
|
10
|
+
require 'caco/debian/add_user'
|
|
11
|
+
|
|
12
|
+
# Templates
|
|
13
|
+
require 'caco/debian/cell/service'
|
|
14
|
+
require 'caco/debian/cell/sources_list'
|
|
15
|
+
|
|
16
|
+
module Caco
|
|
17
|
+
module Debian
|
|
18
|
+
@@apt_updated = false
|
|
19
|
+
|
|
20
|
+
def self.apt_updated
|
|
21
|
+
@@apt_updated
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.apt_updated=(value)
|
|
25
|
+
@@apt_updated = !!value
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Caco::Debian
|
|
2
|
+
class AddUser < Trailblazer::Operation
|
|
3
|
+
step Subprocess(Caco::Debian::UserHome),
|
|
4
|
+
input: ->(_ctx, user:, **) {{
|
|
5
|
+
user: user
|
|
6
|
+
}},
|
|
7
|
+
Output(:success) => End(:success),
|
|
8
|
+
Output(:failure) => Track(:success)
|
|
9
|
+
|
|
10
|
+
step Subprocess(Caco::Executer),
|
|
11
|
+
input: ->(_ctx, user:, **) {{
|
|
12
|
+
command: "adduser --disabled-password --gecos '' --quiet --force-badname #{user}"
|
|
13
|
+
}}
|
|
14
|
+
|
|
15
|
+
step ->(ctx, **) { ctx[:created] = true },
|
|
16
|
+
id: :mark_created
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Caco::Debian::AptKeyInstall < Trailblazer::Operation
|
|
2
|
+
step Subprocess(Caco::Executer),
|
|
3
|
+
Output(:failure) => Track(:success),
|
|
4
|
+
Output(:success) => End(:success),
|
|
5
|
+
input: ->(_ctx, fingerprint:, **) {{
|
|
6
|
+
command: "apt-key list|egrep -i '#{fingerprint}'"
|
|
7
|
+
}},
|
|
8
|
+
output: { check_key_exist_exit_code: :exit_code, check_key_exist_output: :output },
|
|
9
|
+
id: :check_key_exist
|
|
10
|
+
|
|
11
|
+
step Subprocess(Class.new(Caco::Executer)),
|
|
12
|
+
input: ->(_ctx, url:, **) {{
|
|
13
|
+
command: "wget -q -O - #{url} | apt-key add -"
|
|
14
|
+
}},
|
|
15
|
+
output: ->(_ctx, exit_code:, output:, **) {{
|
|
16
|
+
install_key_exit_code: exit_code, install_key_output: output, apt_key_executed: true
|
|
17
|
+
}},
|
|
18
|
+
id: :install_key
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Caco::Debian
|
|
2
|
+
class AptRepoAdd < Trailblazer::Operation
|
|
3
|
+
step ->(ctx, url:, release:, component:, **) {
|
|
4
|
+
ctx[:content] = "deb #{url} #{release} #{component}"
|
|
5
|
+
},
|
|
6
|
+
id: :build_repo_content
|
|
7
|
+
|
|
8
|
+
step ->(ctx, name:, **) {
|
|
9
|
+
ctx[:path] = "/etc/apt/sources.list.d/#{name}.list"
|
|
10
|
+
},
|
|
11
|
+
id: :build_repo_path
|
|
12
|
+
|
|
13
|
+
step Subprocess(Caco::FileWriter),
|
|
14
|
+
input: [:path, :content],
|
|
15
|
+
output: { file_created: :repo_created, file_changed: :repo_changed }
|
|
16
|
+
end
|
|
17
|
+
end
|