5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/rbbt/workflow/integration/ansible/workflow.rb', line 5
def self.extended(object)
class << object
attr_accessor :ans_tasks
end
object.helper :register do |task_info|
desc = task.description if task
name ||= desc || short_path
task_info = {"name" => name}.merge(task_info)
@ans_tasks ||= []
@ans_tasks << task_info
task
end
object.helper :ans do |name, info|
register({ name => info})
end
object.helper :add do |name, info|
@ans_tasks.last[name.to_s] = info
end
object.helper :shell do |cmd|
register({"shell" => cmd.strip})
end
object.helper :sudo do |cmd|
register({"shell" => cmd.strip, "become" => 'yes'})
end
object.helper :singularity do |scmd|
img = config :singularity_img, :build, :test, :small, :default => '/data/img/singularity/rbbt/rbbt.simg'
container = config :singularity_container, :build, :test, :small, :default => '/data/img/sandbox/mvazque2/'
cmd = <<-EOF
singularity exec -C -H '#{container}' '#{img}' #{scmd}
EOF
register({"shell" => cmd.strip, "name" => short_path})
end
object.helper :produce_task do
@ans_tasks
end
end
|