Sha256: 51dda3ec2e2cc50df6578549a8e5d7c135a62a7ba43f0501f387c76e95a4df7e

Contents?: true

Size: 1.59 KB

Versions: 67

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

# Simple model to store basic info about the Ansible role
class AnsibleRole < ApplicationRecord
  audited
  include Authorizable

  self.include_root_in_json = false
  validates :name, :presence => true, :uniqueness => true
  has_many :host_ansible_roles
  has_many_hosts :through => :host_ansible_roles, :dependent => :destroy
  has_many :hostgroup_ansible_roles
  has_many :hostgroups, :through => :hostgroup_ansible_roles,
                        :dependent => :destroy
  has_many :ansible_variables, :inverse_of => :ansible_role,
                               :dependent => :destroy,
                               :class_name => 'AnsibleVariable'

  scoped_search :on => :name, :complete_value => true
  scoped_search :on => :id, :complete_value => false
  scoped_search :on => :updated_at
  scoped_search :relation => :hosts,
                :on => :id, :rename => :host_id, :only_explicit => true
  scoped_search :relation => :hosts,
                :on => :name, :rename => :host, :only_explicit => true
  scoped_search :relation => :hostgroups,
                :on => :id, :rename => :hostgroup_id, :only_explicit => true
  scoped_search :relation => :hostgroups,
                :on => :name, :rename => :hostgroup, :only_explicit => true

  apipie :class, "A class representing #{model_name.human} object" do
    name 'Ansible role'
    refs 'AnsibleRole'
    sections only: %w[all additional]
    property :name, String, desc: 'Returns name of the ansible role'
  end
  # Methods to be allowed in any template with safemode enabled
  class Jail < Safemode::Jail
    allow :name
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
foreman_ansible-12.0.3 app/models/ansible_role.rb
foreman_ansible-12.0.2 app/models/ansible_role.rb
foreman_ansible-12.0.1 app/models/ansible_role.rb
foreman_ansible-12.0.0 app/models/ansible_role.rb
foreman_ansible-11.2.1 app/models/ansible_role.rb
foreman_ansible-7.1.7 app/models/ansible_role.rb
foreman_ansible-11.2.0 app/models/ansible_role.rb
foreman_ansible-11.1.2 app/models/ansible_role.rb
foreman_ansible-7.1.6 app/models/ansible_role.rb
foreman_ansible-11.1.1 app/models/ansible_role.rb
foreman_ansible-10.4.1 app/models/ansible_role.rb
foreman_ansible-7.1.5 app/models/ansible_role.rb
foreman_ansible-11.1.0 app/models/ansible_role.rb
foreman_ansible-10.4.0 app/models/ansible_role.rb
foreman_ansible-10.3.0 app/models/ansible_role.rb
foreman_ansible-11.0.0 app/models/ansible_role.rb
foreman_ansible-10.2.0 app/models/ansible_role.rb
foreman_ansible-10.1.0 app/models/ansible_role.rb
foreman_ansible-10.0.1 app/models/ansible_role.rb
foreman_ansible-10.0.0 app/models/ansible_role.rb