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

Returns a new instance of Play.



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

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



75
76
77
78
79
80
81
82
83
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 75

def _result
  tasks = super
  raise 'Includes cannot be used in a play using a role. They can only be used in task files or in plays with a task list.' if tasks.inclusions.any? && @play_args[:roles]

  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



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

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

#become_user(value) ⇒ Object



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

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

#block(&block) ⇒ Object



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

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

#connection(value) ⇒ Object



33
34
35
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 33

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

#gather_facts(value) ⇒ Object



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

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

#hosts(value) ⇒ Object



17
18
19
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 17

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

#ignore_errors(*args) ⇒ Object



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

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

#local_hostObject



63
64
65
66
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 63

def local_host
  hosts 'localhost'
  connection :local
end

#no_log(value) ⇒ Object



25
26
27
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 25

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

#roles(value) ⇒ Object



29
30
31
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 29

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

#serial(value) ⇒ Object



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

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

#user(value) ⇒ Object



37
38
39
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 37

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

#vars(value) ⇒ Object



21
22
23
# File 'lib/ansible/ruby/dsl_builders/play.rb', line 21

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