Sha256: 182a4848292d78bcb7375e0fa4b23fe87fcfa0799bd4f8c53dde686c384549b2

Contents?: true

Size: 1.22 KB

Versions: 104

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

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

104 entries across 104 versions & 1 rubygems

Version Path
foreman_ansible-10.2.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-10.1.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-10.0.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-10.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.1.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-9.0.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.1.3 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-9.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.1.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.1.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-8.0.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-8.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.0.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.1.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.0.3 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.0.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.0.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-6.3.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-6.3.3 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb