Module: Populus::DSL

Included in:
Populus
Defined in:
lib/populus/dsl.rb

Overview

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

Defined Under Namespace

Classes: DSLContext

Instance Method Summary collapse

Instance Method Details

#eval_setting(path) ⇒ Object



51
52
53
54
55
56
# 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) ⇒ Object



45
46
47
48
49
# File 'lib/populus/dsl.rb', line 45

def node(*nodes)
  nodes.each do |node|
    Node.register_host(node)
  end
end

#watch(type, *arg, &b) ⇒ Object



39
40
41
42
43
# 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