|
| 1 | +# |
| 2 | +# Author:: Dan Koepke <[email protected]> |
| 3 | +# Cookbook Name:: appdynamics |
| 4 | +# Provider:: php_agent |
| 5 | +# |
| 6 | +# Copyright:: 2015, AppDynamics, Inc and its affiliates |
| 7 | +# |
| 8 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | +# you may not use this file except in compliance with the License. |
| 10 | +# You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, software |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | +# See the License for the specific language governing permissions and |
| 18 | +# limitations under the License. |
| 19 | +# |
| 20 | + |
| 21 | +require_relative '../libraries/helpers' |
| 22 | +include AppDynamicsCookbook::Helpers |
| 23 | + |
| 24 | +def whyrun_supported? |
| 25 | + true |
| 26 | +end |
| 27 | + |
| 28 | +use_inline_resources |
| 29 | + |
| 30 | +action :install do |
| 31 | + version = new_resource.version |
| 32 | + tarball_source = new_resource.source || default_source(version) |
| 33 | + |
| 34 | + appdynamics_extract "#{new_resource.name} :run extract" do |
| 35 | + basename "appdynamics-php-agent-#{version}.tar.bz2" |
| 36 | + type :tar_bz2 |
| 37 | + source tarball_source |
| 38 | + dest new_resource.dest |
| 39 | + owner new_resource.owner unless new_resource.owner.nil? |
| 40 | + group new_resource.group unless new_resource.group.nil? |
| 41 | + notifies :run, "execute[#{new_resource.name} :run install.sh]", :immediately |
| 42 | + end |
| 43 | + |
| 44 | + new_resource.updated_by_last_action(true) |
| 45 | + |
| 46 | + install_command = ["./install.sh"] |
| 47 | + install_command << '-s' if new_resource.controller_ssl |
| 48 | + install_command << "-a=#{new_resource.account}@#{new_resource.accesskey}" |
| 49 | + install_command << "--http-proxy-host=#{new_resoure.http_proxy_host}" if new_resource.http_proxy_host |
| 50 | + install_command << "--http-proxy-port=#{new_resoure.http_proxy_port}" if new_resource.http_proxy_port |
| 51 | + install_command << "--http-proxy-user=#{new_resoure.http_proxy_user}" if new_resource.http_proxy_user |
| 52 | + install_command << "--http-proxy-password-file=#{new_resoure.http_proxy_password_file}" if new_resource.http_proxy_password_file |
| 53 | + install_command << "#{new_resource.controller_host} #{new_resource.controller_port}" |
| 54 | + install_command << "#{new_resource.app_name} #{new_resource.tier_name} #{new_resource.node_name}" |
| 55 | + |
| 56 | + execute "#{new_resource.name} :run install.sh" do |
| 57 | + action :nothing |
| 58 | + command install_command |
| 59 | + cwd "#{new_resource.dest}/appdynamics-php-agent" |
| 60 | + user new_resource.owner unless new_resource.owner.nil? |
| 61 | + group new_resource.group unless new_resource.group.nil? |
| 62 | + end |
| 63 | + |
| 64 | + new_resource.updated_by_last_action(true) |
| 65 | +end |
| 66 | + |
| 67 | +def default_source(version) |
| 68 | + plat = platform(node['kernel']['os'], %w(linux osx)) |
| 69 | + arch = architecture(node['kernel']['machine'], %w(x86 x64)) |
| 70 | + "https://packages.appdynamics.com/#{version}/php/appdynamics-php-agent-#{plat}-#{arch}-#{version}.tar.bz2" |
| 71 | +end |
0 commit comments