Skip to content

Commit

Permalink
Fixes #37733 - Add audits of ansible role changes on hosts
Browse files Browse the repository at this point in the history
This records audits when ansible role is added to a host or removed from
a host.

Defining the `to_label` method is necessary so the name of host ansible
role is shown in the format `role / host` rather than `id / host`.
  • Loading branch information
adamlazik1 committed Aug 21, 2024
1 parent e6ebd6c commit 64eaf2c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/host_ansible_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

# Join model that hosts the connection between hosts and ansible_roles
class HostAnsibleRole < ApplicationRecord
audited associated_with: :host

belongs_to_host
belongs_to :ansible_role
acts_as_list scope: :host

validates :ansible_role_id, :presence => true,
:uniqueness => { :scope => :host_id }

def to_label
ansible_role.name
end
end

0 comments on commit 64eaf2c

Please sign in to comment.