Sha256: 76877b0b94530b7d9f05887cd1637c456d90cf72a78f4371b8f211a6a89324d1

Contents?: true

Size: 1.19 KB

Versions: 23

Compression:

Stored size: 1.19 KB

Contents

module ForemanAnsible
  module Concerns
    # Extra methods to enforce Ansible roles on a host or multiple hosts
    module HostsControllerExtensions
      extend ActiveSupport::Concern
      include ForemanTasks::Triggers
      include JobInvocationHelper

      # Overrides to methods in the original hosts controller
      module Overrides
        def action_permission
          case params[:action]
          when 'multiple_play_roles', 'play_roles'
            :view
          else
            super
          end
        end
      end

      included do
        prepend Overrides
      end

      def play_roles
        find_resource
        composer = job_composer(:ansible_run_host, @host)
        composer.trigger
        redirect_to job_invocation_path(composer.job_invocation)
      rescue Foreman::Exception => e
        error e.message
        redirect_to host_path(@host)
      end

      def multiple_play_roles
        find_multiple
        composer = job_composer(:ansible_run_host, @hosts)
        composer.trigger
        redirect_to job_invocation_path(composer.job_invocation)
      rescue Foreman::Exception => e
        error e.message
        redirect_to hosts_path
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
foreman_ansible-2.2.14 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.13 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.12 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.11 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.10 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.9 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.8 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.7 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.6 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.5 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.3 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.2.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.1.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.1.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.0.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.0.3 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-2.0.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb