Class: Ansible::Ruby::DslBuilders::Play

Inherits:
Tasks
  • Object
show all
Defined in:
lib/ansible/ruby/dsl_builders/play.rb

Instance Method Summary collapse

Methods inherited from Tasks

#ansible_include, context, contexts, #respond_to_missing?

Methods inherited from Base

#jinja, #method_missing, #respond_to_missing?

Constructor Details

#initialize(name = nil) ⇒ Play



9
10
11
12
13
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 9

def initialize(name = nil)
  super :tasks
  @play_args = {}
  @play_args[:name] = name if name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ansible::Ruby::DslBuilders::Base

Instance Method Details

#_resultObject

allow any order



65
66
67
68
69
70
71
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 65

def _result
  tasks = super
  args = @play_args.merge({})
  # Don't want to trigger validation
  args[:tasks] = tasks if tasks.items.any?
  Models::Play.new args
end

#become(*args) ⇒ Object



39
40
41
42
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 39

def become(*args)
  value = _implicit_bool args
  @play_args[:become] = value
end

#become_user(value) ⇒ Object



44
45
46
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 44

def become_user(value)
  @play_args[:become_user] = value
end

#block(&block) ⇒ Object



58
59
60
61
62
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 58

def block(&block)
  builder = Block.new
  builder.instance_eval(&block)
  @items << builder._result
end

#connection(value) ⇒ Object



23
24
25
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 23

def connection(value)
  @play_args[:connection] = value
end

#gather_facts(value) ⇒ Object



35
36
37
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 35

def gather_facts(value)
  @play_args[:gather_facts] = value
end

#hosts(value) ⇒ Object



15
16
17
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 15

def hosts(value)
  @play_args[:hosts] = value
end

#ignore_errors(*args) ⇒ Object



48
49
50
51
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 48

def ignore_errors(*args)
  value = _implicit_bool args
  @play_args[:ignore_errors] = value
end

#local_hostObject



53
54
55
56
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 53

def local_host
  hosts 'localhost'
  connection :local
end

#roles(value) ⇒ Object



19
20
21
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 19

def roles(value)
  @play_args[:roles] = value
end

#serial(value) ⇒ Object



31
32
33
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 31

def serial(value)
  @play_args[:serial] = value
end

#user(value) ⇒ Object



27
28
29
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 27

def user(value)
  @play_args[:user] = value
end