You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
5.6KB

  1. #
  2. # cookbook::oracle_client_fx
  3. # resource::oracle_client_fx
  4. #
  5. # author::fxinnovation
  6. # description::Installs oracle client on linux
  7. #
  8. resource_name :oracle_client_fx
  9. provides :oracle_client_fx, os: 'linux'
  10. property :java_version, %w(8 10 11), default: '8'
  11. property :user, String, default: 'oracle'
  12. property :group, String, default: 'dba'
  13. property :version, ['11.2'], default: '11.2'
  14. property :source, String
  15. property :checksum, String
  16. property :sqlnet_options, Hash, default: {}
  17. property :tnsnames_options, String, default: ''
  18. property :tls_certificate_url, String, default: ''
  19. action :build do
  20. base_path = '/opt/oracle'
  21. var_path = '/var/oracle'
  22. home_path = "#{base_path}/product/#{new_resource.version}"
  23. bin_path = "#{home_path}/bin"
  24. lib_path = "#{home_path}/lib"
  25. wallet_path = "#{home_path}/ssl_wallet"
  26. dependencies = %w(compat-libstdc++-33.i686 glibc.i686 unixODBC.i686 gcc-c++ gcc compat-libstdc++-33 glibc unixODBC elfutils-libelf-devel libstdc++ libaio-devel unixODBC-devel sysstat)
  27. node.default['java']['jdk_version'] = new_resource.java_version
  28. include_recipe 'java::default'
  29. declare_resource(:group, new_resource.group) do
  30. append true
  31. system true
  32. end
  33. declare_resource(:user, new_resource.user) do
  34. comment 'Oracle user.'
  35. gid new_resource.group
  36. system true
  37. manage_home false
  38. end
  39. dependencies.each do |oracle_dependency|
  40. package oracle_dependency
  41. end
  42. template '/etc/profile.d/oracle.sh' do
  43. source 'etc/profile.d/oracle.sh.erb'
  44. owner 'root'
  45. group 'root'
  46. mode '0755'
  47. variables(
  48. home_path: home_path,
  49. bin_path: bin_path,
  50. lib_path: lib_path,
  51. var_path: var_path
  52. )
  53. verify 'bash -n %{path}'
  54. end
  55. directory base_path do
  56. owner new_resource.user
  57. group new_resource.group
  58. mode '2755'
  59. action :create
  60. end
  61. directory var_path do
  62. owner new_resource.user
  63. group new_resource.group
  64. mode '2775'
  65. action :create
  66. end
  67. template "#{var_path}/oraInst.loc" do
  68. source "oracle-inventory/#{new_resource.version}/oraInst.loc.erb"
  69. owner new_resource.user
  70. group new_resource.group
  71. mode '0664'
  72. variables(
  73. var_path: var_path,
  74. group: new_resource.group
  75. )
  76. end
  77. unzip_fx "linux-oracle_client-#{new_resource.version}" do
  78. source new_resource.source
  79. checksum new_resource.checksum if new_resource.property_is_set?('checksum')
  80. mode '0755'
  81. recursive true
  82. creates 'client'
  83. target_dir "/linux-oracle_client-#{new_resource.version}"
  84. action :extract
  85. end
  86. template "linux-oracle_client-#{new_resource.version}/client/install/oraparam.ini" do
  87. source "oracle-home/#{new_resource.version}/install/oraparam.ini.erb"
  88. owner new_resource.user
  89. group new_resource.group
  90. mode '0644'
  91. end
  92. template "linux-oracle_client-#{new_resource.version}/client/response/client_install.rsp" do
  93. source "oracle-home/#{new_resource.version}/response/client_install.rsp.erb"
  94. owner new_resource.user
  95. group new_resource.group
  96. mode '0644'
  97. variables(
  98. base_path: base_path,
  99. group: new_resource.group,
  100. home_path: home_path,
  101. bin_path: bin_path,
  102. lib_path: lib_path,
  103. var_path: var_path
  104. )
  105. end
  106. execute 'run oracle installer' do
  107. not_if { ::File.exist?("#{home_path}/root.sh") }
  108. command "source /etc/profile && ./runInstaller -noconfig -silent -waitforcompletion -ignoreprereq -ignoreSysprereqs -responseFile /linux-oracle_client-#{new_resource.version}/client/response/client_install.rsp -invPtrLoc #{var_path}/oraInst.loc"
  109. cwd "linux-oracle_client-#{new_resource.version}/client/"
  110. user new_resource.user
  111. group new_resource.group
  112. environment('USER' => new_resource.user)
  113. live_stream true
  114. end
  115. execute 'run oracle configuration tool' do
  116. command "source /etc/profile && #{home_path}/cfgtoollogs/configToolAllCommands RESPONSE_FILE=/linux-oracle_client-#{new_resource.version}/client/response/client_install.rsp"
  117. user new_resource.user
  118. group new_resource.group
  119. environment('USER' => new_resource.user)
  120. live_stream true
  121. end
  122. execute 'run oracle client end of installation' do
  123. command "#{home_path}/root.sh"
  124. end
  125. file "#{home_path}/network/admin/tnsnames.ora" do
  126. content new_resource.tnsnames_options
  127. mode '0660'
  128. owner new_resource.user
  129. group new_resource.group
  130. end
  131. template "#{home_path}/network/admin/sqlnet.ora" do
  132. source "oracle-home/#{new_resource.version}/network/admin/sqlnet.ora.erb"
  133. owner new_resource.user
  134. group new_resource.group
  135. mode '0660'
  136. variables(
  137. sqlnet_options: new_resource.sqlnet_options
  138. )
  139. end
  140. directory wallet_path do
  141. not_if { new_resource.tls_certificate_url == '' }
  142. owner new_resource.user
  143. group new_resource.group
  144. mode '0750'
  145. action :create
  146. end
  147. remote_file "#{wallet_path}/root-cert.pem" do
  148. not_if { new_resource.tls_certificate_url == '' }
  149. source new_resource.tls_certificate_url
  150. mode '0640'
  151. owner new_resource.user
  152. group new_resource.group
  153. end
  154. execute 'create wallet' do
  155. not_if { new_resource.tls_certificate_url == '' }
  156. command "source /etc/profile && orapki wallet create -wallet #{wallet_path} -auto_login_only"
  157. user new_resource.user
  158. end
  159. execute 'add wallet' do
  160. not_if { new_resource.tls_certificate_url == '' }
  161. command "source /etc/profile && orapki wallet add -wallet #{wallet_path} -trusted_cert -cert #{wallet_path}/root-cert.pem -auto_login_only "
  162. user new_resource.user
  163. end
  164. end