Update cookbooks

* Replace old nginx cookbook with new chef_nginx cookbooks
* Update application cookbook
This commit is contained in:
Greg Karékinian
2017-04-28 11:59:11 +02:00
parent 5d1d4832df
commit 4fb5390f9b
264 changed files with 3050 additions and 8605 deletions

View File

@@ -1,4 +0,0 @@
~FC007
~FC023
~FC024
~FC048

View File

@@ -2,6 +2,23 @@
This file is used to list changes made in each version of the dmg cookbook.
## 4.0.0 (2017-04-27)
- Converted the existing LWRP to a custom resource which increases the required chef-client release to 12.5+
- Added Test Kitchen config with private atlas boxes for 10.10 and 10.11
- Added a test recipe to installed Tunnelblick
- Added an Inspec test to confirm that Tunnelblick actually installs
- Remove unused attributes and the entire attributes file
- Add a warning if you include the default recipe on your runlist
- Update specs to run on 10.12 and against the test recipe since dmg::default is empty and the existing spec tested nothing
## 3.1.1 (2017-04-11)
- Cookstyle updates
- Test with Local Delivery and not Rake
- Update apache2 license string
- Remove foodcritic exclusions
## 3.1.0 (2017-01-18)
- Fixed pkg,mpkg installation when it was using mounted app name while it was actually mounted under different name for some applications

View File

@@ -8,11 +8,11 @@ Resource to install OS X applications (.app) from dmg files.
### Platforms
- Mac OS X
- macOS
### Chef
- Chef 12.1+
- Chef 12.5+
### Cookbooks
@@ -56,8 +56,8 @@ Install `/Applications/Tunnelblick.app` from the primary download site.
```ruby
dmg_package 'Tunnelblick' do
source 'http://tunnelblick.googlecode.com/files/Tunnelblick_3.1.2.dmg'
checksum 'a3fae60b6833175f32df20c90cd3a3603a'
source 'https://tunnelblick.net/release/Tunnelblick_3.7.0_build_4790.dmg'
checksum '5053038aa8caf7dea66dcab11d6d240672216e6546eff4c2622e216c61af85e5'
action :install
end
```
@@ -129,7 +129,7 @@ end
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
**Copyright:** 2011-2015, Chef Software, Inc.
**Copyright:** 2011-2017, Chef Software, Inc.
```
Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -1,20 +0,0 @@
#
# Cookbook:: dmg
# Attributes:: default
#
# Copyright:: 2011-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['dmg']['base_dir'] = '/Applications'
default['dmg']['cache_dir'] = Chef::Config[:file_cache_path]

View File

@@ -2,7 +2,7 @@
# Cookbook:: dmg
# Library:: matchers
#
# Copyright:: 2014-2016, Fletcher Nichol <fnichol@nichol.ca>
# Copyright:: 2014-2017, Fletcher Nichol <fnichol@nichol.ca>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

File diff suppressed because one or more lines are too long

View File

@@ -1,95 +0,0 @@
#
# Cookbook:: dmg
# Provider:: package
#
# Copyright:: 2011-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include Chef::Mixin::ShellOut
use_inline_resources if defined?(use_inline_resources)
def load_current_resource
@dmgpkg = Chef::Resource::DmgPackage.new(new_resource.name)
@dmgpkg.app(new_resource.app)
Chef::Log.debug("Checking for application #{new_resource.app}")
@dmgpkg.installed(installed?)
end
action :install do
unless @dmgpkg.installed
volumes_dir = new_resource.volumes_dir ? new_resource.volumes_dir : new_resource.app
dmg_name = new_resource.dmg_name ? new_resource.dmg_name : new_resource.app
dmg_file = if new_resource.file.nil?
"#{Chef::Config[:file_cache_path]}/#{dmg_name}.dmg"
else
new_resource.file
end
remote_file "#{dmg_file} - #{@dmgpkg.name}" do
path dmg_file
source new_resource.source
headers new_resource.headers if new_resource.headers
checksum new_resource.checksum if new_resource.checksum
end if new_resource.source
passphrase_cmd = new_resource.dmg_passphrase ? "-passphrase #{new_resource.dmg_passphrase}" : ''
ruby_block "attach #{dmg_file}" do
block do
cmd = shell_out("hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}' | grep -q 'Software License Agreement: true'")
software_license_agreement = cmd.exitstatus.zero?
raise "Requires EULA Acceptance; add 'accept_eula true' to package resource" if software_license_agreement && !new_resource.accept_eula
accept_eula_cmd = new_resource.accept_eula ? 'echo Y | PAGER=true' : ''
shell_out!("#{accept_eula_cmd} hdiutil attach #{passphrase_cmd} '#{dmg_file}' -mountpoint '/Volumes/#{volumes_dir}' -quiet")
end
not_if "hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'"
end
case new_resource.type
when 'app'
execute "rsync --force --recursive --links --perms --executability --owner --group --times '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'" do
user new_resource.owner if new_resource.owner
end
file "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}" do
mode '755'
ignore_failure true
end
when 'mpkg', 'pkg'
execute "installation_file=$(ls '/Volumes/#{volumes_dir}' | grep '.#{new_resource.type}$') && sudo installer -pkg \"/Volumes/#{volumes_dir}/$installation_file\" -target /" do
# Prevent cfprefsd from holding up hdiutil detach for certain disk images
environment('__CFPREFERENCES_AVOID_DAEMON' => '1') if Gem::Version.new(node['platform_version']) >= Gem::Version.new('10.8')
end
end
execute "hdiutil detach '/Volumes/#{volumes_dir}' || hdiutil detach '/Volumes/#{volumes_dir}' -force"
end
end
private
def installed?
if ::File.directory?("#{new_resource.destination}/#{new_resource.app}.app")
Chef::Log.info "Already installed; to upgrade, remove \"#{new_resource.destination}/#{new_resource.app}.app\""
true
elsif shell_out("pkgutil --pkgs='#{new_resource.package_id}'").exitstatus.zero?
Chef::Log.info "Already installed; to upgrade, try \"sudo pkgutil --forget '#{new_resource.package_id}'\""
true
else
false
end
end

View File

@@ -1,8 +1,8 @@
#
# Cookbook Name:: dmg
# Cookbook:: dmg
# Recipe:: default
#
# Copyright 2011-2016, Chef Software, Inc.
# Copyright:: 2011-2017, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,3 +16,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
Chef::Log.warn('The dmg::default recipe does not contain any resources and should not be applied to a node')

View File

@@ -1,8 +1,9 @@
# Encoding: utf-8
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Cookbook:: dmg
# Resource:: package
#
# Copyright:: 2011-2016, Joshua Timberman
# Copyright:: 2011-2017, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,24 +17,82 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
actions :install
attribute :app, kind_of: String, name_attribute: true
attribute :source, kind_of: String, default: nil
attribute :file, kind_of: String, default: nil
attribute :owner, kind_of: String, default: nil
attribute :destination, kind_of: String, default: '/Applications'
attribute :checksum, kind_of: String, default: nil
attribute :volumes_dir, kind_of: String, default: nil
attribute :dmg_name, kind_of: String, default: nil
attribute :type, kind_of: String, default: 'app'
attribute :installed, kind_of: [TrueClass, FalseClass], default: false
attribute :package_id, kind_of: String, default: nil
attribute :dmg_passphrase, kind_of: String, default: nil
attribute :accept_eula, kind_of: [TrueClass, FalseClass], default: false
attribute :headers, kind_of: Hash, default: nil
property :app, String, name_property: true
property :source, String
property :file, String
property :owner, String
property :destination, String, default: '/Applications'
property :checksum, String
property :volumes_dir, String
property :dmg_name, String
property :type, String, default: 'app'
property :installed, [true, false], default: false, desired_state: false
property :package_id, String
property :dmg_passphrase, String
property :accept_eula, [true, false], default: false
property :headers, [Hash, nil], default: nil
def initialize(name, run_context = nil)
super
@action = :install
load_current_value do |new_resource|
if ::File.directory?("#{new_resource.destination}/#{new_resource.app}.app")
Chef::Log.info "Already installed; to upgrade, remove \"#{new_resource.destination}/#{new_resource.app}.app\""
installed true
elsif shell_out("pkgutil --pkgs='#{new_resource.package_id}'").exitstatus == 0
Chef::Log.info "Already installed; to upgrade, try \"sudo pkgutil --forget '#{new_resource.package_id}'\""
installed true
else
installed false
end
end
action :install do
unless current_resource.installed
volumes_dir = new_resource.volumes_dir ? new_resource.volumes_dir : new_resource.app
dmg_name = new_resource.dmg_name ? new_resource.dmg_name : new_resource.app
dmg_file = if new_resource.file.nil?
"#{Chef::Config[:file_cache_path]}/#{dmg_name}.dmg"
else
new_resource.file
end
remote_file "#{dmg_file} - #{new_resource.name}" do
path dmg_file
source new_resource.source
headers new_resource.headers if new_resource.headers
checksum new_resource.checksum if new_resource.checksum
end if new_resource.source
passphrase_cmd = new_resource.dmg_passphrase ? "-passphrase #{new_resource.dmg_passphrase}" : ''
ruby_block "attach #{dmg_file}" do
block do
cmd = shell_out("hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}' | grep -q 'Software License Agreement: true'")
software_license_agreement = cmd.exitstatus == 0
raise "Requires EULA Acceptance; add 'accept_eula true' to package resource" if software_license_agreement && !new_resource.accept_eula
accept_eula_cmd = new_resource.accept_eula ? 'echo Y | PAGER=true' : ''
shell_out!("#{accept_eula_cmd} hdiutil attach #{passphrase_cmd} '#{dmg_file}' -mountpoint '/Volumes/#{volumes_dir}' -quiet")
end
not_if "hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'"
end
case new_resource.type
when 'app'
execute "rsync --force --recursive --links --perms --executability --owner --group --times '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'" do
user new_resource.owner if new_resource.owner
end
declare_resource(:file, "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}") do
mode '755'
ignore_failure true
end
when 'mpkg', 'pkg'
execute "installation_file=$(ls '/Volumes/#{volumes_dir}' | grep '.#{new_resource.type}$') && sudo installer -pkg \"/Volumes/#{volumes_dir}/$installation_file\" -target /" do
# Prevent cfprefsd from holding up hdiutil detach for certain disk images
environment('__CFPREFERENCES_AVOID_DAEMON' => '1')
end
end
execute "hdiutil detach '/Volumes/#{volumes_dir}' || hdiutil detach '/Volumes/#{volumes_dir}' -force"
end
end