Class: Teleport::Config::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/teleport/config.rb

Overview

DSL used when parsing Telfile.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DSL

Returns a new instance of DSL.



112
113
114
# File 'lib/teleport/config.rb', line 112

def initialize(config)
  @config = config
end

Instance Method Details

#apt(line, options = {}) ⇒ Object



145
146
147
# File 'lib/teleport/config.rb', line 145

def apt(line, options = {})
  @config.apt << Apt.new(line, options)
end

#packages(*list) ⇒ Object



149
150
151
# File 'lib/teleport/config.rb', line 149

def packages(*list)
  @config.packages += list.flatten
end

#recipes(*list) ⇒ Object



153
154
155
# File 'lib/teleport/config.rb', line 153

def recipes(*list)
  @config.recipes += list.flatten
end

#role(name, options = {}) ⇒ Object



135
136
137
138
# File 'lib/teleport/config.rb', line 135

def role(name, options = {})
  raise "role #{name.inspect} defined twice" if @config.roles.any? { |i| i.name == name }
  @config.roles << Role.new(name, options)
end

#ruby(v) ⇒ Object



116
117
118
119
120
121
# File 'lib/teleport/config.rb', line 116

def ruby(v)
  raise "ruby called twice" if @config.ruby
  raise "ruby must be a string" if !v.is_a?(String)
  raise "don't recognize ruby #{v.inspect}." if !Config::RUBIES.include?(v)
  @config.ruby = v
end

#server(name, options = {}) ⇒ Object



140
141
142
143
# File 'lib/teleport/config.rb', line 140

def server(name, options = {})
  raise "server #{name.inspect} defined twice" if @config.servers.any? { |i| i.name == name }
  @config.servers << Server.new(name, options)
end

#ssh_key(v) ⇒ Object



157
158
159
# File 'lib/teleport/config.rb', line 157

def ssh_key(v)
  @config.ssh_key = v
end

#ssh_options(v) ⇒ Object



129
130
131
132
133
# File 'lib/teleport/config.rb', line 129

def ssh_options(v)
  raise "ssh_options called twice" if @config.ssh_options
  raise "ssh_options must be an Array" if !v.is_a?(Array)
  @config.ssh_options = v
end

#user(v) ⇒ Object



123
124
125
126
127
# File 'lib/teleport/config.rb', line 123

def user(v)
  raise "user called twice" if @config.user
  raise "user must be a string" if !v.is_a?(String)
  @config.user = v
end