Skip to content

Commit

Permalink
Add a method to queue an Ansible::Runner.run
Browse files Browse the repository at this point in the history
This adds a way to queue an Ansible::Runner.run and wraps it in a task
so that it can be invoked asynchronously from automate.
  • Loading branch information
agrare committed Jul 13, 2018
1 parent d101c79 commit 653b072
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/ansible/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ def run(env_vars, extra_vars, playbook_path)
run_via_cli(env_vars, extra_vars, playbook_path)
end

def run_queue(env_vars, extra_vars, playbook_path, user_id, queue_opts)
queue_opts = {
:args => [env_vars, extra_vars, playbook_path],
:queue_name => "generic",
:class_name => name,
:method_name => "run",
}.merge(queue_opts)

task_opts = {
:action => "Run Ansible Playbook",
:userid => user_id,
}

MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

private

def run_via_cli(env_vars, extra_vars, playbook_path)
Expand Down

0 comments on commit 653b072

Please sign in to comment.