Class: Ansible::Ruby::DslBuilders::Task
- Inherits:
-
Unit
- Object
- Base
- Unit
- Ansible::Ruby::DslBuilders::Task
show all
- Defined in:
- lib/ansible/ruby/dsl_builders/task.rb
Instance Method Summary
collapse
Methods inherited from Unit
#ansible_when, #become, #become_user, #ignore_errors
Methods inherited from Base
#jinja, #method_missing
Constructor Details
#initialize(name, context, temp_counter_inc) ⇒ Task
Returns a new instance of Task.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 11
def initialize(name, context, temp_counter_inc)
super()
@name = name
@context = context
@module = nil
@inclusion = nil
name_fetcher = lambda do
name = "result_#{temp_counter_inc.call}"
@task_args[:register] = name
name
end
@register = Result.new name_fetcher
end
|
Instance Method Details
#_register ⇒ Object
71
72
73
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 71
def _register
@register
end
|
#_result ⇒ Object
allow for other attributes besides the module in any order
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 76
def _result
args = {
name: @name
}.merge @task_args
args[:module] = @module if @module
args[:inclusion] = @inclusion if @inclusion
task = @context.new args
task.validate! if validate?
task
end
|
#async(value) ⇒ Object
55
56
57
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 55
def async(value)
@task_args[:async] = value
end
|
#changed_when(clause) ⇒ Object
34
35
36
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 34
def changed_when(clause)
@task_args[:changed_when] = clause
end
|
#connection(value) ⇒ Object
30
31
32
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 30
def connection(value)
@task_args[:connection] = value
end
|
#failed_when(clause) ⇒ Object
38
39
40
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 38
def failed_when(clause)
@task_args[:failed_when] = clause
end
|
#no_log(value) ⇒ Object
26
27
28
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 26
def no_log(value)
@task_args[:no_log] = value
end
|
#notify(value) ⇒ Object
63
64
65
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 63
def notify(value)
@task_args[:notify] = value
end
|
#poll(value) ⇒ Object
59
60
61
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 59
def poll(value)
@task_args[:poll] = value
end
|
#respond_to_missing? ⇒ Boolean
67
68
69
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 67
def respond_to_missing?(*)
!@module || super
end
|
#validate? ⇒ Boolean
88
89
90
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 88
def validate?
true
end
|
#with_dict(clause) {|[hash_key, hash_value]| ... } ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 42
def with_dict(clause)
@task_args[:with_dict] = clause
return unless block_given?
hash_key = JinjaItemNode.new('item.key')
hash_value = JinjaItemNode.new('item.value')
yield [hash_key, hash_value]
end
|
#with_items(clause) {|JinjaItemNode.new| ... } ⇒ Object
50
51
52
53
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 50
def with_items(clause)
@task_args[:with_items] = clause
yield JinjaItemNode.new if block_given?
end
|