Skip to content

Commit

Permalink
Pass verbosity from services to ansible runner
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonin committed Jul 17, 2019
1 parent 2466763 commit 5b9bb52
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
7 changes: 4 additions & 3 deletions app/models/manageiq/providers/ansible_playbook_workflow.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ManageIQ::Providers::AnsiblePlaybookWorkflow < ManageIQ::Providers::AnsibleRunnerWorkflow
def self.job_options(env_vars, extra_vars, playbook_options, timeout, poll_interval, hosts, credentials)
def self.job_options(env_vars, extra_vars, playbook_options, timeout, poll_interval, hosts, credentials, verbosity)
{
:credentials => credentials,
:env_vars => env_vars,
Expand All @@ -8,6 +8,7 @@ def self.job_options(env_vars, extra_vars, playbook_options, timeout, poll_inter
:playbook_path => playbook_options[:playbook_path],
:timeout => timeout,
:poll_interval => poll_interval,
:verbosity => verbosity
}
end

Expand All @@ -17,9 +18,9 @@ def pre_playbook
end

def run_playbook
credentials, env_vars, extra_vars, hosts, playbook_path = options.values_at(:credentials, :env_vars, :extra_vars, :hosts, :playbook_path)
credentials, env_vars, extra_vars, hosts, playbook_path, verbosity = options.values_at(:credentials, :env_vars, :extra_vars, :hosts, :playbook_path, :verbosity)

response = Ansible::Runner.run_async(env_vars, extra_vars, playbook_path, :hosts => hosts, :credentials => credentials)
response = Ansible::Runner.run_async(env_vars, extra_vars, playbook_path, :hosts => hosts, :credentials => credentials, :verbosity => verbosity)
if response.nil?
queue_signal(:abort, "Failed to run ansible playbook", "error")
else
Expand Down
5 changes: 3 additions & 2 deletions app/models/manageiq/providers/ansible_role_workflow.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ManageIQ::Providers::AnsibleRoleWorkflow < ManageIQ::Providers::AnsibleRunnerWorkflow
def self.job_options(env_vars, extra_vars, role_options, timeout, poll_interval, hosts, credentials)
def self.job_options(env_vars, extra_vars, role_options, timeout, poll_interval, hosts, credentials, verbosity)
{
:credentials => credentials,
:env_vars => env_vars,
Expand All @@ -9,7 +9,8 @@ def self.job_options(env_vars, extra_vars, role_options, timeout, poll_interval,
:roles_path => role_options[:roles_path],
:role_skip_facts => role_options[:role_skip_facts],
:timeout => timeout,
:poll_interval => poll_interval
:poll_interval => poll_interval,
:verbosity => verbosity
}
end

Expand Down
8 changes: 6 additions & 2 deletions app/models/manageiq/providers/ansible_runner_workflow.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class ManageIQ::Providers::AnsibleRunnerWorkflow < Job
def self.create_job(env_vars, extra_vars, role_or_playbook_options, hosts = ["localhost"], credentials = [], timeout: 1.hour, poll_interval: 1.second)
super(name, job_options(env_vars, extra_vars, role_or_playbook_options, timeout, poll_interval, hosts, credentials))
def self.create_job(env_vars, extra_vars, role_or_playbook_options,
hosts = ["localhost"], credentials = [],
timeout: 1.hour, poll_interval: 1.second, verbosity: 0)
options = job_options(env_vars, extra_vars, role_or_playbook_options, timeout,
poll_interval, hosts, credentials, verbosity)
super(name, options)
end

def current_job_timeout(_timeout_adjustment = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def run(vars = {})
credentials = collect_credentials(vars)

kwargs = {}
kwargs[:timeout] = vars[:execution_ttl].to_i.minutes if vars[:execution_ttl].present?
kwargs[:timeout] = vars[:execution_ttl].to_i.minutes if vars[:execution_ttl].present?
kwargs[:verbosity] = vars[:verbosity].to_i if vars[:verbosity].present?

workflow.create_job({}, extra_vars, playbook_vars, vars[:hosts], credentials, kwargs).tap do |job|
job.signal(:start)
Expand Down
1 change: 1 addition & 0 deletions app/models/service_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def get_job_options(action)
hosts
network_credential_id
vault_credential_id
verbosity
].freeze

def config_options(action)
Expand Down

0 comments on commit 5b9bb52

Please sign in to comment.