Set up an instance of Mastodon for Kosmos

Refs #19

Use new application cookbook, update our cookbooks
This commit is contained in:
Greg Karékinian
2017-04-06 21:20:51 +02:00
parent a3f5c5f646
commit de11c0d691
345 changed files with 22591 additions and 3473 deletions

View File

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

113
cookbooks/dmg/CHANGELOG.md Normal file
View File

@@ -0,0 +1,113 @@
# dmg Cookbook CHANGELOG
This file is used to list changes made in each version of the dmg cookbook.
## 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
- Cookstyle fixes
## 3.0.0 (2016-09-06)
- Add chef_version metadata
- Run the specs against a mock of OS X
- Testing updates
- Require Chef 12+
## v2.4.0 (2016-04-26)
- Added support for local .dmg files with the file property. See the readme for details
- Resolved all rubocop warnings
## v2.3.0 (2015-10-20)
- Add new headers property to the LWRP for custom http headers. See the readme for more information
- Removed pivotal tracker example in the readme
- Added travis and cookbook version badges to the readme
- Added a .foodcritic file to exclude rules
- Updated chefignore and .gitignore files
- Updated platforms in Test Kitchen
- Added standard Rubocop file
- Updated Travis to test using ChefDK for the latest deps
- Added a Berksfile
- Updated contributing and testing docs
- Updated Gemfile with the latest testing deps
- Added maintainers.md and maintainers.toml
- Added rakefile for simplified testing
- Added source_url and issues_url metadata
- Added basic converge chefspec
## v2.2.2 (2014-11-12)
- # 23, add chefspec matchers
## v2.2.0 (2014-02-25)
- [COOK-4285] Accept long EULAs
## v2.1.4 (2014-01-26)
- [COOK-4157] - dmg_package LWRP broken due to "puts" instead of "system"
- [COOK-4065] - dmg cookbook outputs the name of packages when checking if they are installed
## v2.1.2
Cleaning up merge errors
## v2.1.0
### Bug
- **[COOK-3946](https://tickets.chef.io/browse/COOK-3946)** - Syntax error in resources/package.rb
- **[COOK-2672](https://tickets.chef.io/browse/COOK-2672)** - EULA for package is displayed instead accepted
## v2.0.8
Adding a Chef 10 compatibility check in provider
## v2.0.6
# BUG
- [COOK-3302] - Sometimes hdiutil detach fails due to cfprefsd running in background
# IMPROVEMENT
- Adding foodcritic and rubocop to .travis.yml
## v2.0.4
### Bug
- **[COOK-3331](https://tickets.chef.io/browse/COOK-3331)** - Fix an issue where `dmg_package` with no source raises an exception
## v2.0.2
### Bug
- **[COOK-3578](https://tickets.chef.io/browse/COOK-3578)** - Support `package_id`s with spaces
- **[COOK-3302](https://tickets.chef.io/browse/COOK-3302)** - Fix an issue where `hdiutil detach` fails due to `cfprefsd` running in the background
## v2.0.0
### Bug
- **[COOK-3389](https://tickets.chef.io/browse/COOK-3389)** - Use `rsync` instead of `cp` (potentially a breaking change on some systems)
## v1.1.0
- [COOK-1847] - accept owner parameter for installing packages
## v1.0.0
- [COOK-852] - Support "pkg" in addition to "mpkg" package types
## v0.7.0
- [COOK-854] - use `cp -R` instead of `cp -r`
- [COOK-855] - specify a file or directory to check for prior install
## v0.6.0
- option to install software that is an .mpkg inside a .dmg
- ignore failure on chmod in case mode is already set, or is root owned

View File

@@ -0,0 +1,2 @@
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD

View File

@@ -0,0 +1,18 @@
<!-- This is a generated file. Please do not edit directly -->
# Maintainers
This file lists how this cookbook project is maintained. When making changes to the system, this
file tells you who needs to review your patch - you need a review from an existing maintainer
for the cookbook to provide a :+1: on your pull request. Additionally, you need
to not receive a veto from a Lieutenant or the Project Lead.
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)
for details on the process and how to become a maintainer or the project lead.
# Project Maintainer
* [Tim Smith](https://github.com/tas50)
# Maintainers
* [Jennifer Davis](https://github.com/sigje)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)

146
cookbooks/dmg/README.md Normal file
View File

@@ -0,0 +1,146 @@
# dmg Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/dmg.svg?branch=master)](https://travis-ci.org/chef-cookbooks/dmg) [![Cookbook Version](https://img.shields.io/cookbook/v/dmg.svg)](https://supermarket.chef.io/cookbooks/dmg)
Resource to install OS X applications (.app) from dmg files.
## Requirements
### Platforms
- Mac OS X
### Chef
- Chef 12.1+
### Cookbooks
- none
## Resources/Providers
### dmg_package
This resource will install a DMG "Package". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef:
```bash
knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb
```
Optionally, the LWRP can install an "mpkg" or "pkg" package using installer(8).
#### Actions
- :install - Installs the application.
#### Parameter attributes:
- `app` - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications.
- `source` - remote URL for the dmg to download if specified. Default is nil.
- `file` - local dmg full file path. Default is nil.
- `owner` - owner that should own the package installation.
- `destination` - directory to copy the .app into. Default is /Applications.
- `checksum` - sha256 checksum of the dmg to download. Default is nil.
- `type` - type of package, "app", "pkg" or "mpkg". Default is "app". When using "pkg" or "mpkg", the destination must be /Applications.
- `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute.
- `package_id` - Package id registered with pkgutil when a pkg or mpkg is installed
- `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces.
- `dmg_passphrase` - Specify a passphrase to use to unencrypt the dmg while mounting.
- `accept_eula` - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false.
- `headers` - Allows custom HTTP headers (like cookies) to be set on the remote_file resource.
#### Examples
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'
action :install
end
```
Install Google Chrome. Uses the `dmg_name` because the application name has spaces. Installs in `/Applications/Google Chrome.app`.
```ruby
dmg_package 'Google Chrome' do
dmg_name 'googlechrome'
source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'
checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'
action :install
end
```
Install Dropbox. Uses `volumes_dir` because the mounted directory is different than the name of the application directory. Installs in `/Applications/Dropbox.app`.
```ruby
dmg_package 'Dropbox' do
volumes_dir 'Dropbox Installer'
source 'http://www.dropbox.com/download?plat=mac'
checksum 'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13'
action :install
end
```
Install MacIrssi to `~/Applications` from the local file downloaded to the cache path into an Applications directory in the current user's home directory. Chef should run as a non-root user for this.
```ruby
directory "#{ENV['HOME']}/Applications"
dmg_package 'MacIrssi' do
destination "#{ENV['HOME']}/Applications"
action :install
end
```
Install Virtualbox to `/Applications` from the .mpkg:
```ruby
dmg_package 'Virtualbox' do
source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'
type 'mpkg'
end
```
Install pgAdmin to `/Applications` and automatically accept the EULA:
```ruby
dmg_package 'pgAdmin3' do
source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'
checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'
accept_eula true
end
```
Install Silverlight, with idempotence check based on pkgutil:
```ruby
dmg_package 'Silerlight' do
source 'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg'
type 'pkg'
checksum '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc'
package_id 'com.microsoft.installSilverlightPlugin'
end
```
## License & Authors
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
**Copyright:** 2011-2015, 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.
```

View File

@@ -0,0 +1,20 @@
#
# 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

@@ -0,0 +1,24 @@
#
# Cookbook:: dmg
# Library:: matchers
#
# Copyright:: 2014-2016, 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.
# 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.
#
if defined?(ChefSpec)
def install_dmg_package(app)
ChefSpec::Matchers::ResourceMatcher.new(:dmg_package, :install, app)
end
end

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,95 @@
#
# 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

@@ -0,0 +1,18 @@
#
# Cookbook Name:: dmg
# Recipe:: 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.
#

View File

@@ -0,0 +1,39 @@
# Encoding: utf-8
# Cookbook:: dmg
# Resource:: package
#
# Copyright:: 2011-2016, Joshua Timberman
#
# 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.
#
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
def initialize(name, run_context = nil)
super
@action = :install
end