Sha256: 216e7b0d91927053df7ef5995b6533c30764be30c1447876365612079538f0b3
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
class Caco::Haproxy::ConfSet < Trailblazer::Operation step Subprocess(Caco::FileReader), input: ->(_ctx, **) {{ path: "/etc/default/haproxy", }}, output: [:output] step Subprocess(Caco::Haproxy::ConfGet), input: ->(_ctx, name:, **) {{ name: name, }}, output: {value: :existing_value} step :change_value fail :create_value, Output(:success) => Track(:success) step :check_values_are_the_same, Output(:success) => End(:success), Output(:failure) => Track(:success) step Subprocess(Caco::FileWriter), input: ->(_ctx, new_config_content:, **) {{ path: "/etc/default/haproxy", content: new_config_content }} def change_value(ctx, output:, name:, value:, **) ctx[:created] = false ctx[:changed] = true ctx[:new_config_content] = output.gsub!(/^#{name}=\"(.*)\"/, "#{name}=\"#{value}\"") true end def create_value(ctx, output:, name:, value:, **) ctx[:created] = true ctx[:changed] = true output << "#{name}=\"#{value}\"\n" ctx[:new_config_content] = output true end def check_values_are_the_same(ctx, value:, existing_value:, **) if value == existing_value ctx[:changed] = nil ctx[:created] = nil true else false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caco-0.1.0 | lib/caco/haproxy/conf_set.rb |