forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#18057 from lfu/service_ansible_mixin
Normalize extra_vars support for Ansible Tower playbooks.
- Loading branch information
Showing
5 changed files
with
86 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module AnsibleExtraVarsMixin | ||
extend ActiveSupport::Concern | ||
|
||
def manageiq_env(user, miq_group, request_task = nil) | ||
{ | ||
'api_url' => api_url, | ||
'api_token' => api_token(user), | ||
'user' => user.href_slug, | ||
'group' => miq_group.href_slug, | ||
'X_MIQ_Group' => user.current_group.description, | ||
}.merge(task_url(request_task)) | ||
end | ||
|
||
def manageiq_connection_env(user) | ||
{ | ||
'url' => api_url, | ||
'token' => api_token(user), | ||
'X_MIQ_Group' => user.current_group.description | ||
} | ||
end | ||
|
||
private | ||
|
||
def api_token(user) | ||
@api_token ||= Api::UserTokenService.new.generate_token(user.userid, 'api') | ||
end | ||
|
||
def api_url | ||
@api_url ||= MiqRegion.my_region.remote_ws_url | ||
end | ||
|
||
def task_url(request_task) | ||
request_task ? {'request_task' => "#{request_task.miq_request.href_slug}/#{request_task.href_slug}", 'request' => request_task.miq_request.href_slug} : {} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters