Class: ForemanAnsible::AnsibleProvider
- Inherits:
-
RemoteExecutionProvider
- Object
- RemoteExecutionProvider
- ForemanAnsible::AnsibleProvider
- Defined in:
- app/models/foreman_ansible/ansible_provider.rb
Overview
Provider for RemoteExecution that allows to run Ansible playbooks. Read the source of other RemoteExecution providers for more.
Class Method Summary collapse
- .host_setting(host, setting) ⇒ Object
- .humanized_name ⇒ Object
- .proxy_action_class ⇒ Object
- .proxy_command_options(template_invocation, host) ⇒ Object
- .proxy_operation_name ⇒ Object
- .required_proxy_selector_for(template) ⇒ Object
- .rex_effective_user_password(host) ⇒ Object
- .rex_ssh_password(host) ⇒ Object
- .secrets(host) ⇒ Object
- .ssh_key_passphrase(host) ⇒ Object
- .ssh_password(host) ⇒ Object
- .supports_effective_user? ⇒ Boolean
Class Method Details
.host_setting(host, setting) ⇒ Object
53 54 55 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 53 def host_setting(host, setting) host.params[setting.to_s] || Setting[setting] end |
.humanized_name ⇒ Object
17 18 19 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 17 def humanized_name 'Ansible' end |
.proxy_action_class ⇒ Object
65 66 67 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 65 def proxy_action_class 'ForemanAnsibleCore::TaskLauncher::Playbook::PlaybookRunnerAction' end |
.proxy_command_options(template_invocation, host) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 21 def (template_invocation, host) super(template_invocation, host).merge( 'ansible_inventory' => ::ForemanAnsible::InventoryCreator.new( [host], template_invocation ).to_hash, :verbosity_level => Setting[:ansible_verbosity], :remote_execution_command => ansible_command?( template_invocation.template ), :name => host.name ) end |
.proxy_operation_name ⇒ Object
61 62 63 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 61 def proxy_operation_name 'ansible-runner' end |
.required_proxy_selector_for(template) ⇒ Object
69 70 71 72 73 74 75 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 69 def required_proxy_selector_for(template) if template.remote_execution_features.where(:label => 'ansible_run_capsule_upgrade').any? ::DefaultProxyProxySelector.new else super end end |
.rex_effective_user_password(host) ⇒ Object
49 50 51 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 49 def rex_effective_user_password(host) host_setting(host, 'remote_execution_effective_user_password') end |
.rex_ssh_password(host) ⇒ Object
45 46 47 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 45 def rex_ssh_password(host) host_setting(host, 'remote_execution_ssh_password') end |
.secrets(host) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 34 def secrets(host) { 'per-host' => { host.name => { 'ansible_ssh_pass' => rex_ssh_password(host), 'ansible_become_password' => rex_effective_user_password(host) } } } end |
.ssh_key_passphrase(host) ⇒ Object
13 14 15 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 13 def ssh_key_passphrase(host) host_setting(host, :remote_execution_ssh_key_passphrase) end |
.ssh_password(host) ⇒ Object
9 10 11 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 9 def ssh_password(host) host_setting(host, :remote_execution_ssh_password) end |
.supports_effective_user? ⇒ Boolean
57 58 59 |
# File 'app/models/foreman_ansible/ansible_provider.rb', line 57 def supports_effective_user? true end |