From 64eaf2c1ba488631e41ae50e2f88b12e168bf86c Mon Sep 17 00:00:00 2001 From: alazik Date: Wed, 14 Aug 2024 14:07:33 +0000 Subject: [PATCH] Fixes #37733 - Add audits of ansible role changes on hosts 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`. --- app/models/host_ansible_role.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/host_ansible_role.rb b/app/models/host_ansible_role.rb index f902de79e..f784477c3 100644 --- a/app/models/host_ansible_role.rb +++ b/app/models/host_ansible_role.rb @@ -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