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

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

Instance Attribute Summary

Attributes inherited from Base

#result

Instance Method Summary collapse

Methods inherited from Tasks

#process_method, #task

Methods inherited from Base

#method_missing, #respond_to_missing?

Constructor Details

#initialize(name = nil) ⇒ Play

Returns a new instance of Play.



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

def initialize(name = nil)
  super()
  @playbook_args = {}
  @playbook_args[:name] = 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

#connection(value) ⇒ Object



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

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

#evaluateObject



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

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

#gather_facts(value) ⇒ Object



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

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

#hosts(value) ⇒ Object



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

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

#local_hostObject



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

def local_host
  hosts 'localhost'
  connection :local
end

#roles(value) ⇒ Object



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

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

#serial(value) ⇒ Object



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

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

#user(value) ⇒ Object



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

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