Sha256: 858bb2c6fd69a5d071a9a3906b08a85766d4efd842dbbaf6ca1f94bc36f3e1ca

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

if defined? ForemanRemoteExecution
  module ForemanAnsible
    # Provider for RemoteExecution that allows to run Ansible playbooks.
    # Read the source of other RemoteExecution providers for more.
    class AnsibleProvider < RemoteExecutionProvider
      class << self
        def ssh_password(host)
          host_setting(host, :remote_execution_ssh_password)
        end

        def ssh_key_passphrase(host)
          host_setting(host, :remote_execution_ssh_key_passphrase)
        end

        def humanized_name
          'Ansible'
        end

        def proxy_command_options(template_invocation, host)
          super(template_invocation, host).merge(
            'ansible_inventory' => ::ForemanAnsible::InventoryCreator.new(
              [host], template_invocation
            ).to_hash.to_json,
            :remote_execution_command => ansible_command?(
              template_invocation.template
            ),
            :name => host.name
          )
        end

        def supports_effective_user?
          true
        end

        def proxy_operation_name
          Setting::Ansible[:ansible_implementation]
        end

        private

        def ansible_command?(template)
          template.remote_execution_features.
            where(:label => 'ansible_run_host').empty?
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_ansible-3.0.9 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.8 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.7 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.6 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.5 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.4 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.3 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.2 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.1 app/models/foreman_ansible/ansible_provider.rb
foreman_ansible-3.0.0 app/models/foreman_ansible/ansible_provider.rb