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-15.0.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-15.0.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-15.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-14.2.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-14.2.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.7 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-14.2.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-14.1.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-14.1.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.5 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-14.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.3 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.2 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.1 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-13.0.0 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-12.0.7 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-10.4.4 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-7.1.8 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
foreman_ansible-12.0.6 app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb