module Ansible
Public Class Methods
Source
# File lib/rbbt/workflow/integration/ansible.rb, line 22 def self.clean_symbols(hash) new = {} hash.each do |key,value| key = key.to_s value = case value when Symbol value.to_s when Hash self.clean_symbols(value) else value end new[key] = value end new end
Source
# File lib/rbbt/workflow/integration/ansible.rb, line 5 def self.play(playbook, inventory = nil, verbose = false) inventory = Rbbt.etc.ansible_inventory.find Log.with_severity 0 do TmpFile.with_file do |tmp| if Hash === playbook Open.write(tmp, [playbook].to_yaml) playbook = tmp end if verbose CMD.cmd_log("ansible-playbook -i #{inventory} -v #{playbook}") else CMD.cmd_log("ansible-playbook -i #{inventory} #{playbook}") end end end end
Source
# File lib/rbbt/workflow/integration/ansible.rb, line 50 def self.playbook(file, task = nil, options = {}) task = task.to_sym if String === task workflow = Workflow === file ? file : Workflow.require_workflow(file) task = workflow.tasks.keys.last if workflow.tasks[task].nil? workflow2playbook workflow, task, options end
Source
# File lib/rbbt/workflow/integration/ansible.rb, line 39 def self.workflow2playbook(workflow, task, options = {}) job_options = workflow.get_SOPT(workflow.tasks[task]) tasks = workflow.job(task, nil, job_options).exec hosts = options[:hosts] || 'localhost' clean_tasks = tasks.collect{|task| self.clean_symbols task } {"hosts" => hosts, "tasks" => clean_tasks} end