Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter ansible_playbook method so that some arguments are optional #18323

Merged
merged 4 commits into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,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 @@ -161,14 +160,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