module Populus::DSL

Populus.node ‘web001.exapmle.jp’, ‘web002.exapmle.jp’

Populus.watch :event, name: “sample” do

cond {|data| data.has_key?('Payload') }
runs do |data|
  Populus.logger.info Base64.decode(data['Payload'])
end

end

Populus.watch :event, name: “sample2” do

cond {|data| data.has_key?('Payload') }
runs do |data|
  on 'web001.exapmle.jp' do
    execute 'whoami'
  end
end

end

Public Instance Methods

eval_setting(path) click to toggle source
# File lib/populus/dsl.rb, line 51
def eval_setting(path)
  load path
rescue => e
  STDERR.puts "Invalid setting format! #{path}", "error is:", e.class, e.message, e.backtrace
  exit 1
end
node(*nodes) click to toggle source
# File lib/populus/dsl.rb, line 45
def node(*nodes)
  nodes.each do |node|
    Node.register_host(node)
  end
end
watch(type, *arg, &b) click to toggle source
# File lib/populus/dsl.rb, line 39
def watch(type, *arg, &b)
  accepter = find_accepter(type.to_s).new(metadata: arg.first)
  DSLContext.new(accepter).instance_eval(&b)
  Pool.register_object accepter
end

Private Instance Methods

find_accepter(type) click to toggle source
# File lib/populus/dsl.rb, line 60
def find_accepter(type)
  const = type.gsub(/(^.|_.)/) {|c| c.tr('_', '').upcase }
  Accepter.const_get(const)
end