biemond / biemond-orawls

Puppet 3/4 module for WebLogic provisioning module ( Linux & Solaris )
Apache License 2.0
63 stars 104 forks source link

hiera overrides not being applied #544

Open LBanzato opened 5 years ago

LBanzato commented 5 years ago

We have a scenario where we use the orawls (release 2.0.19) module and where puppet is run as a non-root user. Due to the limited permissions of the user running puppet it doesn't have access to /etc, so we defined the override_wls_setting_file to create the wls_settings.yaml file somewhere else:

wls_domains_file:           &wls_domains_file           '/opt/oracle/wls_domains.yaml'
wls_setting_file:           &wls_setting_file           '/opt/oracle/wls_setting.yaml'
override_wls_domains_file:                              "%{lookup('wls_domains_file')}"
override_wls_setting_file:                              "%{lookup('wls_setting_file')}"

However, it seems the module is not picking that up and using its default (thus failing due to the lack for permissions):

Error: /Stage[main]/Domains/Wls_setting[ut01osb_domain]: Could not evaluate: Permission denied @ rb_sysopen - /etc/wls_setting.yaml
/vagrant/puppet/modules/modules-standard/orawls/lib/puppet/provider/wls_setting/yaml.rb:32:in `initialize'
/vagrant/puppet/modules/modules-standard/orawls/lib/puppet/provider/wls_setting/yaml.rb:32:in `open'
/vagrant/puppet/modules/modules-standard/orawls/lib/puppet/provider/wls_setting/yaml.rb:32:in `write_yaml'
/vagrant/puppet/modules/modules-standard/orawls/lib/puppet/provider/wls_setting/yaml.rb:14:in `flush'

If I do a hiera lookup, it does find my custom location (/opt/oracle instead of /etc):

$ puppet lookup override_wls_setting_file
--- "/opt/oracle/wls_setting.yaml"

As a work around I changed both ruby scripts to use the location we want as a default: orawls/lib/puppet/type/wls_setting.rb orawls/lib/utils/settings.rb

But I am curious to know if you came across any similar issues.

Thanks, Luigi

ds2000 commented 5 years ago

Hi Luigi, You need to set the overrides as either an environment variable :

FACTER_override_wls_domains_file=/opt/oracle/wls_domains.yaml FACTER_override_wls_setting_file=/opt/oracle/wls_setting.yaml

or in your manifest which calls Edwins module:

if ebsEnabled == "true" then
  Facter.add(:override_wls_domains_file) do
    setcode do
      override_wls_domains_file="/opt/weblogic/user_projects/wls_domains.yaml"
    end
  end

  Facter.add(:override_wls_setting_file) do
    setcode do
      override_wls_setting_file="/opt/weblogic/user_projects/wls_settings.yaml"
    end
  end
end

However, there is a bug in the module. The domains file override doesn't work. In the copydomain.pp and domain.pp the value is hardcoded:

String $wls_domains_file = /etc/wls_domains.yaml',

I'm going to write a separate bug to Edwin to confirm this.