Class: Ansible::Ruby::DslBuilders::FileLevel
- Inherits:
-
Base
- Object
- Base
- Ansible::Ruby::DslBuilders::FileLevel
show all
- Defined in:
- lib/ansible/ruby/dsl_builders/file_level.rb
Instance Attribute Summary
Attributes inherited from Base
#result
Instance Method Summary
collapse
Methods inherited from Base
#method_missing, #respond_to_missing?
Constructor Details
Returns a new instance of FileLevel.
9
10
11
12
13
|
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 9
def initialize
@plays = []
@tasks_builder = nil
@context = nil
end
|
Instance Method Details
#evaluate ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 33
def evaluate(*)
super
case @context
when :playbook
Models::Playbook.new plays: @plays
when :tasks
@tasks_builder.evaluate {}
else
raise "Unknown context #{@context}"
end
end
|
#play(name = nil, &block) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 15
def play(name = nil, &block)
if @context == :tasks
raise 'This is a tasks file due to a task coming before this play, cannot use play here!'
end
@context = :playbook
play_builder = Play.new name
@plays << play_builder.evaluate(&block)
end
|
#process_method(id) ⇒ Object
46
47
48
|
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 46
def process_method(id, *)
raise "undefined local variable or method `#{id}'"
end
|
#task(name, &block) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 24
def task(name, &block)
if @context == :playbook
raise 'This is a playbook file due to a play coming before this task, cannot use task here!'
end
@context = :tasks
@tasks_builder ||= Tasks.new
@tasks_builder.task name, &block
end
|