Module: Puppet_X::Coi::Jboss::Provider::SecurityDomain
- Defined in:
- lib/puppet_x/coi/jboss/provider/securitydomain.rb
Overview
A class for JBoss security domain provider
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/puppet_x/coi/jboss/provider/securitydomain.rb', line 3 def create cmd = "/subsystem=security/security-domain=#{@resource[:name]}/authentication=classic:add(login-modules=[{code=>\"#{@resource[:code]}\",flag=>\"#{@resource[:codeflag]}\",module-options=>[" = [] @resource[:moduleoptions].keys.sort.each do |key| value = @resource[:moduleoptions][key] val = value.to_s.gsub(/\n/, ' ').strip << '%s => "%s"' % [key, val] end cmd += .join(',') + "]}])" cmd = compilecmd(cmd) cmd2 = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}:add(cache-type=default)" bringUp('Security Domain Cache Type', cmd2)[:result] bringUp('Security Domain', cmd)[:result] end |
#destroy ⇒ Object
18 19 20 21 |
# File 'lib/puppet_x/coi/jboss/provider/securitydomain.rb', line 18 def destroy cmd = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}:remove()" bringDown('Security Domain', cmd)[:result] end |
#exists? ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/puppet_x/coi/jboss/provider/securitydomain.rb', line 23 def exists? cmd = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}/authentication=classic:read-resource()" res = executeWithoutRetry cmd if not res[:result] Puppet.debug "Security Domain does NOT exist" return false end undefined = nil lines = preparelines res[:lines] data = eval(lines)['result'] Puppet.debug "Security Domain exists: #{data.inspect}" existinghash = Hash.new givenhash = Hash.new unless @resource[:moduleoptions].nil? @resource[:moduleoptions].each do |key, value| givenhash["#{key}"] = value.to_s.gsub(/\n/, ' ').strip end end data['login-modules'][0]['module-options'].each do |key, value| existinghash[key.to_s] = value.to_s.gsub(/\n/, ' ').strip end if !existinghash.nil? && !givenhash.nil? && existinghash != givenhash diff = givenhash.to_a - existinghash.to_a Puppet.notice "Security domain should be recreated. Diff: #{diff.inspect}" Puppet.debug "Security domain moduleoptions existing hash => #{existinghash.inspect}" Puppet.debug "Security domain moduleoptions given hash => #{givenhash.inspect}" destroy return false end return true end |