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
Class Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Unit
#ansible_when, #become, #become_user, #ignore_errors, #vars
Methods inherited from Base
#jinja, #method_missing
Constructor Details
#initialize(name, model) ⇒ Task
Returns a new instance of Task.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 21
def initialize(name, model)
super()
@name = name
@model = model
@module = nil
@inclusion = nil
name_fetcher = lambda do
self.class.counter_variable += 1
name = "result_#{self.class.counter_variable}"
@task_args[:register] = name
name
end
@register = Result.new name_fetcher
end
|
Class Attribute Details
.counter_variable ⇒ Object
Returns the value of attribute counter_variable.
17
18
19
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 17
def counter_variable
@counter_variable
end
|
Instance Method Details
#_register ⇒ Object
101
102
103
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 101
def _register
@register
end
|
#_result ⇒ Object
allow for other attributes besides the module in any order
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 106
def _result
args = {
name: @name
}.merge @task_args
args[:module] = @module if @module
args[:inclusion] = @inclusion if @inclusion
args[:block] = @block if @block
args[:rescue] = @rescue if @rescue
args[:always] = @always if @always
task = @model.new args
task.validate! if validate?
task
end
|
#ansible_always(&block) ⇒ Object
139
140
141
142
143
144
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 139
def ansible_always(&block)
block_builder = Block.new
block_builder.instance_eval(&block)
@always = block_builder._result
nil
end
|
#ansible_block(&block) ⇒ Object
125
126
127
128
129
130
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 125
def ansible_block(&block)
block_builder = Block.new
block_builder.instance_eval(&block)
@block = block_builder._result
nil
end
|
#ansible_rescue(&block) ⇒ Object
132
133
134
135
136
137
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 132
def ansible_rescue(&block)
block_builder = Block.new
block_builder.instance_eval(&block)
@rescue = block_builder._result
nil
end
|
#async(value) ⇒ Object
68
69
70
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 68
def async(value)
@task_args[:async] = value
end
|
#changed_when(clause) ⇒ Object
45
46
47
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 45
def changed_when(clause)
@task_args[:changed_when] = clause
end
|
#connection(value) ⇒ Object
41
42
43
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 41
def connection(value)
@task_args[:connection] = value
end
|
#delegate_facts(value) ⇒ Object
89
90
91
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 89
def delegate_facts(value)
@task_args[:delegate_facts] = value
end
|
#delegate_to(value) ⇒ Object
85
86
87
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 85
def delegate_to(value)
@task_args[:delegate_to] = value
end
|
#failed_when(clause) ⇒ Object
49
50
51
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 49
def failed_when(clause)
@task_args[:failed_when] = clause
end
|
#local_action ⇒ Object
80
81
82
83
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 80
def local_action
@task_args[:local_action] = true
yield
end
|
#no_log(value) ⇒ Object
37
38
39
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 37
def no_log(value)
@task_args[:no_log] = value
end
|
#notify(value) ⇒ Object
76
77
78
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 76
def notify(value)
@task_args[:notify] = value
end
|
#poll(value) ⇒ Object
72
73
74
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 72
def poll(value)
@task_args[:poll] = value
end
|
#remote_user(value) ⇒ Object
93
94
95
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 93
def remote_user(value)
@task_args[:remote_user] = value
end
|
#respond_to_missing? ⇒ Boolean
97
98
99
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 97
def respond_to_missing?(*)
!@module || super
end
|
#validate? ⇒ Boolean
121
122
123
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 121
def validate?
true
end
|
#with_dict(clause) {|[hash_key, hash_value]| ... } ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 53
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
62
63
64
65
66
|
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 62
def with_items(*clause)
@task_args[:with_items] = clause.length == 1 ? clause[0] : clause
yield JinjaItemNode.new if block_given?
end
|