Sha256: f5f6cba67a2ede595788f0a868d493f310a521bf46139f2b9470e89342f8d3dd

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

class Caco::Prometheus::Install < Trailblazer::Operation
  step :check_root
  def check_root(ctx, **)
    ctx[:root] = Settings.prometheus.root
    FileUtils.mkdir_p(Settings.prometheus.root)
  end

  step :build_url
  def build_url(ctx, version:, root:, **)
    ctx[:url] = "https://github.com/prometheus/prometheus/releases/download/v#{version}/prometheus-#{version}.linux-amd64.tar.gz"
    ctx[:dest] = "#{root}/prometheus-#{version}.linux-amd64.tar.gz"
    ctx[:current_target] = "#{root}/prometheus-#{version}.linux-amd64"
    ctx[:current_link] = "#{root}/prometheus-current"
    ctx[:config_file_path] = "#{Settings.prometheus.config_root}/prometheus.yml"
  end

  step Subprocess(Caco::Downloader),
    input: ->(ctx, url:, dest:, **) {{
      url: url,
      dest: dest,
      stubbed_file: ctx[:stubbed_file]    
    }}

  step Subprocess(Caco::Unpacker),
    input: ->(ctx, root:, dest:, **) {{
      pack: dest,
      dest: root
    }}

  step Subprocess(Caco::FileLink),
    input: ->(ctx, current_target:, current_link:, **) {{
      target: current_target,
      link: current_link
    }}

  step Subprocess(Caco::Debian::ServiceInstall),
    input: ->(ctx, current_link:, **) {{
      name: "prometheus",
      command: "#{current_link}/prometheus --config.file=#{Settings.prometheus.config_root}/prometheus.yml --storage.tsdb.path=#{Settings.prometheus.root}/data"
    }}

  step ->(ctx, **) {
      ctx[:content] = Caco::Prometheus::Cell::Conf.({root: Settings.prometheus.config_root}).to_s
    },
    id: :generate_template!

  step Subprocess(Caco::FileWriter),
    input: { content: :content, config_file_path: :path },
    output: { file_changed: :sources_updated }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caco-0.1.0 lib/caco/prometheus/install.rb