Sha256: 6e96b3576815e00614764fbcc91585f6a7b52a473881d37c4f20b9db1cb0c036

Contents?: true

Size: 848 Bytes

Versions: 58

Compression:

Stored size: 848 Bytes

Contents

module ForemanAnsible
  # Service which resolves override values for hosts
  class OverrideResolver
    attr_reader :overrides, :ansible_variables

    def initialize(host, variable_ids = [])
      raise(Foreman::Exception.new('OverrideResolver needs a host to resolve overrides')) unless host
      @ansible_variables = if variable_ids.empty?
                             AnsibleVariable.where(:ansible_role_id => host.all_ansible_roles, :override => true)
                           else
                             AnsibleVariable.where(:id => variable_ids, :override => true)
                           end
      @overrides = @ansible_variables.values_hash(host).raw
    end

    def resolve(ansible_variable)
      override = @overrides[ansible_variable.id]
      return unless override
      override[ansible_variable.key]
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
foreman_ansible-15.0.2 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-15.0.1 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-15.0.0 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-14.2.2 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-14.2.1 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.7 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-14.2.0 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-14.1.1 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-14.1.0 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.5 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-14.0.0 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.4 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.3 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.2 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.1 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-13.0.0 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-12.0.7 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-10.4.4 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-7.1.8 app/services/foreman_ansible/override_resolver.rb
foreman_ansible-12.0.6 app/services/foreman_ansible/override_resolver.rb