Module: ForemanAnsible::HostManagedExtensions
- Defined in:
- app/models/concerns/foreman_ansible/host_managed_extensions.rb
Overview
Relations to make Host::Managed ‘have’ ansible roles
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #all_ansible_roles ⇒ Object
- #inherited_ansible_roles ⇒ Object
-
#play_ansible_roles ⇒ Object
This one should be fixed, disabled for the moment as we’re in a rush to get the release out.
Class Method Details
.prepended(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/concerns/foreman_ansible/host_managed_extensions.rb', line 7 def self.prepended(base) base.instance_eval do include ::ForemanAnsible::Concerns::JobInvocationHelper has_many :host_ansible_roles, :foreign_key => :host_id has_many :ansible_roles, :through => :host_ansible_roles, :dependent => :destroy scoped_search :relation => :ansible_roles, :on => :name, :complete_value => true, :rename => :ansible_role, :only_explicit => true before_provision :play_ansible_roles audit_associations :ansible_roles end base.singleton_class.prepend ClassMethods end |
Instance Method Details
#all_ansible_roles ⇒ Object
49 50 51 |
# File 'app/models/concerns/foreman_ansible/host_managed_extensions.rb', line 49 def all_ansible_roles (ansible_roles + inherited_ansible_roles).uniq end |
#inherited_ansible_roles ⇒ Object
25 26 27 28 |
# File 'app/models/concerns/foreman_ansible/host_managed_extensions.rb', line 25 def inherited_ansible_roles return [] unless hostgroup hostgroup.inherited_and_own_ansible_roles end |
#play_ansible_roles ⇒ Object
This one should be fixed, disabled for the moment as we’re in a rush to get the release out
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/concerns/foreman_ansible/host_managed_extensions.rb', line 32 def play_ansible_roles return true unless ansible_roles.present? || inherited_ansible_roles.present? composer = job_composer(:ansible_run_host, self) composer.triggering.mode = :future composer.triggering.start_at = ( Time.zone.now + Setting::Ansible[:ansible_post_provision_timeout].to_i.seconds ) composer.trigger! logger.info("Task for Ansible roles on #{self} before_provision: "\ "#{job_invocation_path(composer.job_invocation)}") rescue Foreman::Exception => e logger.info("Error running Ansible roles on #{self} before_provision: "\ "#{e.}") end |