Skip to content

Commit

Permalink
Merge pull request #18323 from djberg96/conversion_host_ansible_playbook
Browse files Browse the repository at this point in the history
Alter ansible_playbook method so that some arguments are optional

(cherry picked from commit 6585812)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702020
  • Loading branch information
agrare authored and simaishi committed Apr 22, 2019
1 parent 958ec64 commit 3f30559
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/models/conversion_host.rb
Expand Up @@ -93,8 +93,7 @@ def enable_conversion_host_role(v2v_vddk_package_url = nil)
def disable_conversion_host_role
install_conversion_host_module
playbook = "/usr/share/ovirt-ansible-v2v-conversion-host/playbooks/conversion_host_disable.yml"
extra_vars = {}
ansible_playbook(playbook, extra_vars)
ansible_playbook(playbook)
ensure
check_conversion_host_role
end
Expand Down Expand Up @@ -149,14 +148,15 @@ def miq_ssh_util_args_manageiq_providers_openstack_cloudmanager_vm
[hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }]
end

def ansible_playbook(playbook, extra_vars, connection)
command = "ansible-playbook #{playbook}"
if connection == 'local'
command += " -i localhost, -c #{connection}"
else
command += " -i #{ipaddress},"
end
# Run the specified ansible playbook using the ansible-playbook command. The
# +extra_vars+ option should be a hash of key/value pairs which, if present,
# will be passed to the '-e' flag.
#
def ansible_playbook(playbook, extra_vars = {})
command = "ansible-playbook #{playbook} -i #{ipaddress}"

extra_vars.each { |k, v| command += " -e '#{k}=#{v}'" }

connect_ssh { |ssu| ssu.shell_exec(command) }
rescue => e
_log.error("Ansible playbook '#{playbook}' failed for '#{resource.name}' with [#{e.class}: #{e}]")
Expand Down

0 comments on commit 3f30559

Please sign in to comment.