From 741c4a5192e08cd5aeadc3eb59aece3670fb39d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Mon, 13 Aug 2018 12:05:50 +0200 Subject: [PATCH] Move the ipfs cookbook to its own GitHub repository --- Berksfile | 6 +- Berksfile.lock | 6 + cookbooks/ipfs/.delivery/project.toml | 1 + {site-cookbooks => cookbooks}/ipfs/.gitignore | 0 cookbooks/ipfs/.kitchen.dokken.yml | 40 ++++++ .../ipfs/.kitchen.yml | 9 +- cookbooks/ipfs/.travis.yml | 39 +++++ cookbooks/ipfs/Berksfile | 3 + .../ipfs/Berksfile.lock | 17 +-- .../ipfs/CHANGELOG.md | 0 {site-cookbooks => cookbooks}/ipfs/LICENSE | 0 {site-cookbooks => cookbooks}/ipfs/README.md | 9 ++ {site-cookbooks => cookbooks}/ipfs/Rakefile | 0 cookbooks/ipfs/attributes/default.rb | 7 + {site-cookbooks => cookbooks}/ipfs/chefignore | 0 cookbooks/ipfs/metadata.json | 45 ++++++ cookbooks/ipfs/recipes/_user.rb | 30 ++++ cookbooks/ipfs/recipes/cluster.rb | 41 ++++++ cookbooks/ipfs/recipes/cluster_bootstrap.rb | 26 ++++ cookbooks/ipfs/recipes/cluster_service.rb | 57 ++++++++ cookbooks/ipfs/recipes/default.rb | 78 ++++++++++ cookbooks/ipfs/resources/config.rb | 26 ++++ cookbooks/ipfs/spec/spec_helper.rb | 3 + .../spec/unit/recipes/cluster_service_spec.rb | 48 +++++++ .../ipfs/spec/unit/recipes/default_spec.rb | 48 +++++++ .../default/ipfs-cluster.initd.service.erb | 0 .../default/ipfs-cluster.systemd.service.erb | 0 .../templates/default/ipfs.initd.service.erb | 0 .../default/ipfs.systemd.service.erb | 0 .../cluster/serverspec/ipfs_cluster_spec.rb | 27 ++++ .../data_bags/.kitchen/logs/kitchen.log | 30 ++++ .../data_bags/credentials/ipfs_cluster.json | 4 + .../default/serverspec/ipfs_spec.rb | 24 ++++ site-cookbooks/ipfs/.kitchen.docker.yml | 44 ------ site-cookbooks/ipfs/.travis.yml | 50 ------- site-cookbooks/ipfs/Berksfile | 3 - site-cookbooks/ipfs/Gemfile | 6 - site-cookbooks/ipfs/Gemfile.lock | 134 ------------------ site-cookbooks/ipfs/attributes/default.rb | 7 - site-cookbooks/ipfs/metadata.rb | 11 -- site-cookbooks/ipfs/recipes/cluster.rb | 68 --------- site-cookbooks/ipfs/recipes/default.rb | 78 ---------- site-cookbooks/ipfs/resources/config.rb | 26 ---- .../default/serverspec/ipfs_spec.rb | 24 ---- 44 files changed, 610 insertions(+), 465 deletions(-) create mode 100644 cookbooks/ipfs/.delivery/project.toml rename {site-cookbooks => cookbooks}/ipfs/.gitignore (100%) create mode 100644 cookbooks/ipfs/.kitchen.dokken.yml rename {site-cookbooks => cookbooks}/ipfs/.kitchen.yml (53%) create mode 100644 cookbooks/ipfs/.travis.yml create mode 100644 cookbooks/ipfs/Berksfile rename {site-cookbooks => cookbooks}/ipfs/Berksfile.lock (52%) rename {site-cookbooks => cookbooks}/ipfs/CHANGELOG.md (100%) rename {site-cookbooks => cookbooks}/ipfs/LICENSE (100%) rename {site-cookbooks => cookbooks}/ipfs/README.md (86%) rename {site-cookbooks => cookbooks}/ipfs/Rakefile (100%) create mode 100644 cookbooks/ipfs/attributes/default.rb rename {site-cookbooks => cookbooks}/ipfs/chefignore (100%) create mode 100644 cookbooks/ipfs/metadata.json create mode 100644 cookbooks/ipfs/recipes/_user.rb create mode 100644 cookbooks/ipfs/recipes/cluster.rb create mode 100644 cookbooks/ipfs/recipes/cluster_bootstrap.rb create mode 100644 cookbooks/ipfs/recipes/cluster_service.rb create mode 100644 cookbooks/ipfs/recipes/default.rb create mode 100644 cookbooks/ipfs/resources/config.rb create mode 100644 cookbooks/ipfs/spec/spec_helper.rb create mode 100644 cookbooks/ipfs/spec/unit/recipes/cluster_service_spec.rb create mode 100644 cookbooks/ipfs/spec/unit/recipes/default_spec.rb rename {site-cookbooks => cookbooks}/ipfs/templates/default/ipfs-cluster.initd.service.erb (100%) rename {site-cookbooks => cookbooks}/ipfs/templates/default/ipfs-cluster.systemd.service.erb (100%) rename {site-cookbooks => cookbooks}/ipfs/templates/default/ipfs.initd.service.erb (100%) rename {site-cookbooks => cookbooks}/ipfs/templates/default/ipfs.systemd.service.erb (100%) create mode 100644 cookbooks/ipfs/test/integration/cluster/serverspec/ipfs_cluster_spec.rb create mode 100644 cookbooks/ipfs/test/integration/data_bags/.kitchen/logs/kitchen.log create mode 100644 cookbooks/ipfs/test/integration/data_bags/credentials/ipfs_cluster.json create mode 100644 cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb delete mode 100644 site-cookbooks/ipfs/.kitchen.docker.yml delete mode 100644 site-cookbooks/ipfs/.travis.yml delete mode 100644 site-cookbooks/ipfs/Berksfile delete mode 100644 site-cookbooks/ipfs/Gemfile delete mode 100644 site-cookbooks/ipfs/Gemfile.lock delete mode 100644 site-cookbooks/ipfs/attributes/default.rb delete mode 100644 site-cookbooks/ipfs/metadata.rb delete mode 100644 site-cookbooks/ipfs/recipes/cluster.rb delete mode 100644 site-cookbooks/ipfs/recipes/default.rb delete mode 100644 site-cookbooks/ipfs/resources/config.rb delete mode 100644 site-cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb diff --git a/Berksfile b/Berksfile index 88871ab..f542d9e 100644 --- a/Berksfile +++ b/Berksfile @@ -23,7 +23,8 @@ cookbook 'application_git', '= 1.1.0' # 1.2.0 doesn't work with knife-sol cookbook 'poise', '~> 2.8.1' cookbook 'poise-languages', '~> 2.1.1' cookbook 'poise-ruby', '~> 2.4.0' -cookbook 'poise-javascript', '~> 1.2.0' +cookbook 'poise-javascript', git: 'https://github.com/poise/poise-javascript.git', + ref: 'b349e7b7e04edf495398a5f9415a4f8bb4b1badb' cookbook 'poise-archive', '~> 1.5.0' cookbook 'poise-service', '~> 1.5.2' cookbook 'users', '~> 5.3.1' @@ -61,3 +62,6 @@ cookbook 'windows', '= 3.1.1' cookbook 'iis', '= 6.7.1' cookbook 'mariadb', '= 0.3.1' cookbook 'mingw', '= 2.0.0' +cookbook 'ipfs', + git: 'https://github.com/67P/ipfs-cookbook.git', + ref: 'master' diff --git a/Berksfile.lock b/Berksfile.lock index 26823ae..f2aa4b3 100644 --- a/Berksfile.lock +++ b/Berksfile.lock @@ -20,6 +20,10 @@ DEPENDENCIES hostname (= 0.4.2) hostsfile (= 2.4.5) iis (= 6.7.1) + ipfs + git: https://github.com/67P/ipfs-cookbook.git + revision: 5578cada684fdab36c0b3c1e6e2acdde10f96947 + ref: master logrotate (= 2.2.0) mariadb (= 0.3.1) mediawiki @@ -116,6 +120,8 @@ GRAPH hostsfile (2.4.5) iis (6.7.1) windows (>= 2.0) + ipfs (0.1.0) + ark (>= 0.0.0) logrotate (2.2.0) mariadb (0.3.1) apt (>= 0.0.0) diff --git a/cookbooks/ipfs/.delivery/project.toml b/cookbooks/ipfs/.delivery/project.toml new file mode 100644 index 0000000..6d5e361 --- /dev/null +++ b/cookbooks/ipfs/.delivery/project.toml @@ -0,0 +1 @@ +remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml" diff --git a/site-cookbooks/ipfs/.gitignore b/cookbooks/ipfs/.gitignore similarity index 100% rename from site-cookbooks/ipfs/.gitignore rename to cookbooks/ipfs/.gitignore diff --git a/cookbooks/ipfs/.kitchen.dokken.yml b/cookbooks/ipfs/.kitchen.dokken.yml new file mode 100644 index 0000000..856fa9a --- /dev/null +++ b/cookbooks/ipfs/.kitchen.dokken.yml @@ -0,0 +1,40 @@ +--- +driver: + name: dokken + privileged: true # because Docker and SystemD/Upstart + chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> + +transport: + name: dokken + +provisioner: + name: dokken + deprecations_as_errors: true + +verifier: + name: inspec + +platforms: + - name: ubuntu-16.04 + driver: + image: dokken/ubuntu-16.04 + pid_one_command: /bin/systemd + - name: ubuntu-18.04 + driver: + image: dokken/ubuntu-18.04 + pid_one_command: /bin/systemd + - name: debian-9 + driver: + image: dokken/debian-9 + pid_one_command: /bin/systemd + +suites: + - name: default + run_list: + - recipe[ipfs::default] + attributes: + - name: cluster + run_list: + - recipe[ipfs::cluster] + - recipe[ipfs::cluster_service] + attributes: diff --git a/site-cookbooks/ipfs/.kitchen.yml b/cookbooks/ipfs/.kitchen.yml similarity index 53% rename from site-cookbooks/ipfs/.kitchen.yml rename to cookbooks/ipfs/.kitchen.yml index 493932a..5c9425c 100644 --- a/site-cookbooks/ipfs/.kitchen.yml +++ b/cookbooks/ipfs/.kitchen.yml @@ -6,12 +6,17 @@ provisioner: name: chef_zero platforms: - - name: ubuntu-14.04 - name: ubuntu-16.04 - - name: debian-8.7 + - name: ubuntu-18.04 + - name: debian-9 suites: - name: default run_list: - recipe[ipfs::default] attributes: + - name: cluster + run_list: + - recipe[ipfs::cluster] + - recipe[ipfs::cluster_service] + attributes: diff --git a/cookbooks/ipfs/.travis.yml b/cookbooks/ipfs/.travis.yml new file mode 100644 index 0000000..c323b91 --- /dev/null +++ b/cookbooks/ipfs/.travis.yml @@ -0,0 +1,39 @@ +sudo: required +dist: trusty + +addons: + apt: + sources: + - chef-current-trusty + packages: + - chefdk + +# Don't `bundle install` which takes about 1.5 mins +install: echo "skip bundle install" + +branches: + only: + - master + +services: docker + +env: + matrix: + - INSTANCE=default-debian-9 + - INSTANCE=default-ubuntu-1604 + - INSTANCE=default-ubuntu-1804 + +before_script: + - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) + - eval "$(chef shell-init bash)" + - chef --version + - cookstyle --version + - foodcritic --version + +script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml CHEF_VERSION=13.10.4 kitchen verify ${INSTANCE} + +matrix: + include: + - script: + - chef exec delivery local all + env: UNIT_AND_LINT=1 diff --git a/cookbooks/ipfs/Berksfile b/cookbooks/ipfs/Berksfile new file mode 100644 index 0000000..44bc4fc --- /dev/null +++ b/cookbooks/ipfs/Berksfile @@ -0,0 +1,3 @@ +source 'https://api.berkshelf.com' + +metadata diff --git a/site-cookbooks/ipfs/Berksfile.lock b/cookbooks/ipfs/Berksfile.lock similarity index 52% rename from site-cookbooks/ipfs/Berksfile.lock rename to cookbooks/ipfs/Berksfile.lock index b57f089..6bea0a7 100644 --- a/site-cookbooks/ipfs/Berksfile.lock +++ b/cookbooks/ipfs/Berksfile.lock @@ -4,21 +4,16 @@ DEPENDENCIES metadata: true GRAPH - ark (2.2.1) + ark (4.0.0) build-essential (>= 0.0.0) seven_zip (>= 0.0.0) - windows (>= 0.0.0) - build-essential (8.0.0) + build-essential (8.1.1) mingw (>= 1.1) seven_zip (>= 0.0.0) - compat_resource (12.16.3) ipfs (0.1.0) ark (>= 0.0.0) - mingw (1.2.5) - compat_resource (>= 12.16.3) + mingw (2.1.0) seven_zip (>= 0.0.0) - ohai (5.0.0) - seven_zip (2.0.2) - windows (>= 1.2.2) - windows (2.1.1) - ohai (>= 4.0.0) + seven_zip (3.0.0) + windows (>= 0.0.0) + windows (5.0.0) diff --git a/site-cookbooks/ipfs/CHANGELOG.md b/cookbooks/ipfs/CHANGELOG.md similarity index 100% rename from site-cookbooks/ipfs/CHANGELOG.md rename to cookbooks/ipfs/CHANGELOG.md diff --git a/site-cookbooks/ipfs/LICENSE b/cookbooks/ipfs/LICENSE similarity index 100% rename from site-cookbooks/ipfs/LICENSE rename to cookbooks/ipfs/LICENSE diff --git a/site-cookbooks/ipfs/README.md b/cookbooks/ipfs/README.md similarity index 86% rename from site-cookbooks/ipfs/README.md rename to cookbooks/ipfs/README.md index ed9024b..9c48257 100644 --- a/site-cookbooks/ipfs/README.md +++ b/cookbooks/ipfs/README.md @@ -55,6 +55,15 @@ ipfs_config "Gateway.Writable" do end ``` +## Running the specs and integrations tests + +Install the latest [Chef DK](https://downloads.chef.io/chefdk). + +``` +chef exec delivery local all # Run the linting check, syntax check and unit tests +kitchen verify # Run the integration tests for Ubuntu 16.04, 18.06 and Debian 9 +``` + ## License and Authors Authors: Kosmos diff --git a/site-cookbooks/ipfs/Rakefile b/cookbooks/ipfs/Rakefile similarity index 100% rename from site-cookbooks/ipfs/Rakefile rename to cookbooks/ipfs/Rakefile diff --git a/cookbooks/ipfs/attributes/default.rb b/cookbooks/ipfs/attributes/default.rb new file mode 100644 index 0000000..f6e82fb --- /dev/null +++ b/cookbooks/ipfs/attributes/default.rb @@ -0,0 +1,7 @@ +node.default['ipfs']['version'] = '0.4.9' +node.default['ipfs']['checksum'] = 'ae50c760f58548adc7c6dade4cf549059b6bc73ebc25ff4ea9fece06a15ac0a6' +# Do not contact local network addresses. This will stop platforms like Hetzner +# to block your server (https://github.com/ipfs/go-ipfs/issues/1226) +node.default['ipfs']['config']['swarm']['addr_filter'] = ['/ip4/10.0.0.0/ipcidr/8', '/ip4/100.64.0.0/ipcidr/10', '/ip4/169.254.0.0/ipcidr/16', '/ip4/172.16.0.0/ipcidr/12', '/ip4/192.0.0.0/ipcidr/24', '/ip4/192.0.0.0/ipcidr/29', '/ip4/192.0.0.8/ipcidr/32', '/ip4/192.0.0.170/ipcidr/32', '/ip4/192.0.0.171/ipcidr/32', '/ip4/192.0.2.0/ipcidr/24', '/ip4/192.168.0.0/ipcidr/16', '/ip4/198.18.0.0/ipcidr/15', '/ip4/198.51.100.0/ipcidr/24', '/ip4/203.0.113.0/ipcidr/24', '/ip4/240.0.0.0/ipcidr/4'] + +node.default['ipfs']['cluster']['version'] = '0.4.0' diff --git a/site-cookbooks/ipfs/chefignore b/cookbooks/ipfs/chefignore similarity index 100% rename from site-cookbooks/ipfs/chefignore rename to cookbooks/ipfs/chefignore diff --git a/cookbooks/ipfs/metadata.json b/cookbooks/ipfs/metadata.json new file mode 100644 index 0000000..356d4f1 --- /dev/null +++ b/cookbooks/ipfs/metadata.json @@ -0,0 +1,45 @@ +{ + "name": "ipfs", + "description": "Installs/Configures ipfs", + "long_description": "# ipfs Cookbook\n\nThis cookbook installs ipfs and starts it as a daemon\n\n## Requirements\n\n### Platforms\n\nThis cookbook is tested on Ubuntu 16.06, 14.04 and Debian 8 using Test Kitchen.\nIt currently only supports 64bit platforms\n\n### Chef\n\n- Chef 12.5 or later (we are providing a\n [https://docs.chef.io/custom_resources.html](Custom Resource) to configure\n IPFS\n\n### Cookbook dependencies\n\n- `ark` to download and uncompress the Go IPFS package\n\n## Usage\n\n### ipfs::default\n\nJust include `ipfs` in your node's `run_list`:\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[ipfs]\"\n ]\n}\n```\n\n## Attributes\n\n- `node.['ipfs']['version']` - the Go IPFS version to download from the official\nsite (64bit)\n- `node['ipfs']['checksum']` - the SHA256 checksum for the package\n- `node['ipfs']['config']['swarm']['addr_filter']` - the network ranges to not\nconnect to. This will stop platforms like Hetzner to block your server\n(https://github.com/ipfs/go-ipfs/issues/1226)\n\n## Resources\n\n`ipfs_config` sets the config. Supports hashes, arrays, booleans and strings.\nDoes not change anything if the config already has that value, and restarts\nthe server automatically\n\n```ruby\nipfs_config \"Gateway.Writable\" do\n value \"true\"\n end\n```\n\n## Running the specs and integrations tests\n\nInstall the latest [Chef DK](https://downloads.chef.io/chefdk).\n\n```\nchef exec delivery local all # Run the linting check, syntax check and unit tests\nkitchen verify # Run the integration tests for Ubuntu 16.04, 18.06 and Debian 9\n```\n\n## License and Authors\n\nAuthors: Kosmos\n\n```\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n", + "maintainer": "Kosmos", + "maintainer_email": "mail@kosmos.org", + "license": "Apache-2.0", + "platforms": { + "[\"ubuntu\", \"debian\"]": ">= 0.0.0" + }, + "dependencies": { + "ark": ">= 0.0.0" + }, + "recommendations": { + }, + "suggestions": { + }, + "conflicting": { + }, + "providing": { + }, + "replacing": { + }, + "attributes": { + }, + "groupings": { + }, + "recipes": { + }, + "version": "0.1.0", + "source_url": "https://github.com/67P/ipfs-cookbook", + "issues_url": "https://github.com/67P/ipfs-cookbook/issues", + "privacy": false, + "chef_versions": [ + [ + ">= 12.14" + ] + ], + "ohai_versions": [ + + ], + "gems": [ + + ] +} \ No newline at end of file diff --git a/cookbooks/ipfs/recipes/_user.rb b/cookbooks/ipfs/recipes/_user.rb new file mode 100644 index 0000000..d4da731 --- /dev/null +++ b/cookbooks/ipfs/recipes/_user.rb @@ -0,0 +1,30 @@ +# +# Cookbook Name:: ipfs +# Recipe:: _user +# +# Copyright 2018, Kosmos +# +# 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. +# + +group 'ipfs' do + gid 4737 +end + +user 'ipfs' do + comment 'ipfs' + uid 4737 + gid 4737 + home '/home/ipfs' + manage_home true +end diff --git a/cookbooks/ipfs/recipes/cluster.rb b/cookbooks/ipfs/recipes/cluster.rb new file mode 100644 index 0000000..fde4cae --- /dev/null +++ b/cookbooks/ipfs/recipes/cluster.rb @@ -0,0 +1,41 @@ +# +# Cookbook Name:: ipfs +# Recipe:: cluster +# +# Copyright 2018, Kosmos +# +# 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_recipe 'ipfs::_user' + +version = node['ipfs']['cluster']['version'] + +ark 'ipfs-cluster-service' do + url "https://dist.ipfs.io/ipfs-cluster-service/v#{version}/ipfs-cluster-service_v#{version}_linux-amd64.tar.gz" + has_binaries ['ipfs-cluster-service'] +end + +ark 'ipfs-cluster-ctl' do + url "https://dist.ipfs.io/ipfs-cluster-ctl/v#{version}/ipfs-cluster-ctl_v#{version}_linux-amd64.tar.gz" + has_binaries ['ipfs-cluster-ctl'] +end + +credentials = data_bag_item('credentials', 'ipfs_cluster') + +execute 'ipfs-cluster-service init' do + user 'ipfs' + environment 'CLUSTER_SECRET' => credentials['secret'], + 'IPFS_CLUSTER_PATH' => '/home/ipfs/.ipfs-cluster' + not_if { File.exist? '/home/ipfs/.ipfs-cluster/service.json' } +end diff --git a/cookbooks/ipfs/recipes/cluster_bootstrap.rb b/cookbooks/ipfs/recipes/cluster_bootstrap.rb new file mode 100644 index 0000000..1d784a0 --- /dev/null +++ b/cookbooks/ipfs/recipes/cluster_bootstrap.rb @@ -0,0 +1,26 @@ +# +# Cookbook Name:: ipfs +# Recipe:: cluster_bootstrap +# +# Copyright 2018, Kosmos +# +# 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_recipe 'ipfs::_user' + +execute "ipfs-cluster-service daemon --bootstrap #{peer}" do + user 'ipfs' + environment 'IPFS_CLUSTER_PATH' => '/home/ipfs/.ipfs-cluster' + not_if { File.exist? '/home/ipfs/.ipfs-cluster/service.json' } +end diff --git a/cookbooks/ipfs/recipes/cluster_service.rb b/cookbooks/ipfs/recipes/cluster_service.rb new file mode 100644 index 0000000..c2a73f0 --- /dev/null +++ b/cookbooks/ipfs/recipes/cluster_service.rb @@ -0,0 +1,57 @@ +# +# Cookbook Name:: ipfs +# Recipe:: cluster_service +# +# Copyright 2018, Kosmos +# +# 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 platform?('ubuntu') && node['platform_version'].to_f < 15.04 || + platform?('debian') && node['platform_version'].to_f < 8 + template 'ipfs.initd-cluster.service.erb' do + path '/etc/init.d/ipfs-cluster' + source 'ipfs-cluster.initd.service.erb' + owner 'root' + group 'root' + mode '0750' + notifies :restart, 'service[ipfs-cluster]', :delayed + end + + service 'ipfs-cluster' do + provider Chef::Provider::Service::Init::Debian + action [:enable] + supports start: true, stop: true, restart: true, reload: false, status: true + end + +else + execute 'systemctl daemon-reload' do + command 'systemctl daemon-reload' + action :nothing + end + + template 'ipfs-cluster.systemd.service.erb' do + path '/lib/systemd/system/ipfs-cluster.service' + source 'ipfs-cluster.systemd.service.erb' + owner 'root' + group 'root' + mode '0644' + notifies :run, 'execute[systemctl daemon-reload]', :delayed + notifies :restart, 'service[ipfs-cluster]', :delayed + end + + service 'ipfs-cluster' do + provider Chef::Provider::Service::Systemd + action [:enable] + end +end diff --git a/cookbooks/ipfs/recipes/default.rb b/cookbooks/ipfs/recipes/default.rb new file mode 100644 index 0000000..97be32b --- /dev/null +++ b/cookbooks/ipfs/recipes/default.rb @@ -0,0 +1,78 @@ +# +# Cookbook Name:: ipfs +# Recipe:: default +# +# Copyright 2017-2018, Kosmos +# +# 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_recipe 'ipfs::_user' + +version = node['ipfs']['version'] + +ark 'ipfs' do + url "https://dist.ipfs.io/go-ipfs/v#{version}/go-ipfs_v#{version}_linux-amd64.tar.gz" + checksum node['ipfs']['checksum'] + has_binaries ['ipfs'] +end + +execute 'ipfs init --empty-repo' do + environment 'IPFS_PATH' => '/home/ipfs/.ipfs' + user 'ipfs' + not_if { File.directory? '/home/ipfs/.ipfs' } +end + +if platform?('ubuntu') && node['platform_version'].to_f < 15.04 || + platform?('debian') && node['platform_version'].to_f < 8 + template 'ipfs.initd.service.erb' do + path '/etc/init.d/ipfs' + source 'ipfs.initd.service.erb' + owner 'root' + group 'root' + mode '0750' + notifies :restart, 'service[ipfs]', :delayed + end + + service 'ipfs' do + provider Chef::Provider::Service::Init::Debian + action [:enable] + supports start: true, stop: true, restart: true, reload: false, status: true + end + +else + execute 'systemctl daemon-reload' do + command 'systemctl daemon-reload' + action :nothing + end + + template 'ipfs.systemd.service.erb' do + path '/lib/systemd/system/ipfs.service' + source 'ipfs.systemd.service.erb' + owner 'root' + group 'root' + mode '0644' + notifies :run, 'execute[systemctl daemon-reload]', :delayed + notifies :restart, 'service[ipfs]', :delayed + end + + service 'ipfs' do + provider Chef::Provider::Service::Systemd + action [:enable] + end +end + +# Configure ipfs to not contact local network addresses +ipfs_config 'Swarm.AddrFilters' do + value node['ipfs']['config']['swarm']['addr_filter'] +end diff --git a/cookbooks/ipfs/resources/config.rb b/cookbooks/ipfs/resources/config.rb new file mode 100644 index 0000000..67d4756 --- /dev/null +++ b/cookbooks/ipfs/resources/config.rb @@ -0,0 +1,26 @@ +require 'json' +require 'mixlib/shellout' + +property :key, String, name_property: true +property :value, [String, Hash, Array, TrueClass, FalseClass], required: true + +action :create do + include_recipe 'ipfs' + + execute "ipfs config --json #{new_resource.key} '#{JSON.generate(new_resource.value)}'" do + environment 'IPFS_PATH' => '/home/ipfs/.ipfs' + user 'ipfs' + not_if do + cmd = Mixlib::ShellOut.new('ipfs', 'config', new_resource.key, + user: 'ipfs', + env: { 'IPFS_PATH' => '/home/ipfs/.ipfs' }) + cmd.run_command + begin + JSON.parse(cmd.stdout) == JSON.parse(JSON.generate(new_resource.value)) + rescue JSON::ParserError + cmd.stdout.include?(new_resource.value.to_s) + end + end + notifies :restart, 'service[ipfs]', :delayed + end +end diff --git a/cookbooks/ipfs/spec/spec_helper.rb b/cookbooks/ipfs/spec/spec_helper.rb new file mode 100644 index 0000000..052d78a --- /dev/null +++ b/cookbooks/ipfs/spec/spec_helper.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/cookbooks/ipfs/spec/unit/recipes/cluster_service_spec.rb b/cookbooks/ipfs/spec/unit/recipes/cluster_service_spec.rb new file mode 100644 index 0000000..f4f7047 --- /dev/null +++ b/cookbooks/ipfs/spec/unit/recipes/cluster_service_spec.rb @@ -0,0 +1,48 @@ +# +# Cookbook:: ipfs +# Spec:: default +# +# Copyright 2018, Kosmos +# +# 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. +# + +require 'spec_helper' + +describe 'ipfs::cluster_service' do + context 'When all attributes are default, on Ubuntu 16.04' do + let(:chef_run) do + # for a complete list of available platforms and versions see: + # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md + runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04') + runner.converge(described_recipe) + end + + it 'enables the service' do + expect(chef_run).to enable_service('ipfs-cluster') + end + end + + context 'When all attributes are default, on Ubuntu 18.04' do + let(:chef_run) do + # for a complete list of available platforms and versions see: + # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md + runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04') + runner.converge(described_recipe) + end + + it 'enables the service' do + expect(chef_run).to enable_service('ipfs-cluster') + end + end +end diff --git a/cookbooks/ipfs/spec/unit/recipes/default_spec.rb b/cookbooks/ipfs/spec/unit/recipes/default_spec.rb new file mode 100644 index 0000000..4c9264b --- /dev/null +++ b/cookbooks/ipfs/spec/unit/recipes/default_spec.rb @@ -0,0 +1,48 @@ +# +# Cookbook:: ipfs +# Spec:: default +# +# Copyright 2018, Kosmos +# +# 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. +# + +require 'spec_helper' + +describe 'ipfs::default' do + context 'When all attributes are default, on Ubuntu 16.04' do + let(:chef_run) do + # for a complete list of available platforms and versions see: + # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md + runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end + + context 'When all attributes are default, on Ubuntu 18.04' do + let(:chef_run) do + # for a complete list of available platforms and versions see: + # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md + runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/site-cookbooks/ipfs/templates/default/ipfs-cluster.initd.service.erb b/cookbooks/ipfs/templates/default/ipfs-cluster.initd.service.erb similarity index 100% rename from site-cookbooks/ipfs/templates/default/ipfs-cluster.initd.service.erb rename to cookbooks/ipfs/templates/default/ipfs-cluster.initd.service.erb diff --git a/site-cookbooks/ipfs/templates/default/ipfs-cluster.systemd.service.erb b/cookbooks/ipfs/templates/default/ipfs-cluster.systemd.service.erb similarity index 100% rename from site-cookbooks/ipfs/templates/default/ipfs-cluster.systemd.service.erb rename to cookbooks/ipfs/templates/default/ipfs-cluster.systemd.service.erb diff --git a/site-cookbooks/ipfs/templates/default/ipfs.initd.service.erb b/cookbooks/ipfs/templates/default/ipfs.initd.service.erb similarity index 100% rename from site-cookbooks/ipfs/templates/default/ipfs.initd.service.erb rename to cookbooks/ipfs/templates/default/ipfs.initd.service.erb diff --git a/site-cookbooks/ipfs/templates/default/ipfs.systemd.service.erb b/cookbooks/ipfs/templates/default/ipfs.systemd.service.erb similarity index 100% rename from site-cookbooks/ipfs/templates/default/ipfs.systemd.service.erb rename to cookbooks/ipfs/templates/default/ipfs.systemd.service.erb diff --git a/cookbooks/ipfs/test/integration/cluster/serverspec/ipfs_cluster_spec.rb b/cookbooks/ipfs/test/integration/cluster/serverspec/ipfs_cluster_spec.rb new file mode 100644 index 0000000..23ba688 --- /dev/null +++ b/cookbooks/ipfs/test/integration/cluster/serverspec/ipfs_cluster_spec.rb @@ -0,0 +1,27 @@ +require 'serverspec' + +# Required by serverspec +set :backend, :exec + +describe 'ipfs-cluster-ctl' do + # It is in the PATH + describe command('which ipfs-cluster-ctl') do + its(:exit_status) { should eq 0 } + end +end + +describe 'ipfs-cluster-service' do + # It is in the PATH + describe command('which ipfs-cluster-service') do + its(:exit_status) { should eq 0 } + end + + it 'is listening on port 9096' do + expect(port(9096)).to be_listening + end + + it 'runs the ipfs-cluster-service' do + expect(service('ipfs-cluster')).to be_running + expect(service('ipfs-cluster')).to be_enabled + end +end diff --git a/cookbooks/ipfs/test/integration/data_bags/.kitchen/logs/kitchen.log b/cookbooks/ipfs/test/integration/data_bags/.kitchen/logs/kitchen.log new file mode 100644 index 0000000..3f6cf59 --- /dev/null +++ b/cookbooks/ipfs/test/integration/data_bags/.kitchen/logs/kitchen.log @@ -0,0 +1,30 @@ +I, [2018-08-10T16:28:48.996619 #26331] INFO -- Kitchen: -----> Starting Kitchen (v1.15.0) +E, [2018-08-10T16:28:48.997042 #26331] ERROR -- Kitchen: ------Exception------- +E, [2018-08-10T16:28:48.997089 #26331] ERROR -- Kitchen: Class: Kitchen::UserError +E, [2018-08-10T16:28:48.997122 #26331] ERROR -- Kitchen: Message: Kitchen YAML file /Users/kare/code/kosmos/cookbooks/ipfs/test/integration/data_bags/.kitchen.yml does not exist. +E, [2018-08-10T16:28:48.997151 #26331] ERROR -- Kitchen: ---------------------- +E, [2018-08-10T16:28:48.997178 #26331] ERROR -- Kitchen: ------Backtrace------- +E, [2018-08-10T16:28:48.997205 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/loader/yaml.rb:71:in `read' +E, [2018-08-10T16:28:48.997239 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:152:in `data' +E, [2018-08-10T16:28:48.997266 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:131:in `suites' +E, [2018-08-10T16:28:48.997294 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:182:in `filter_instances' +E, [2018-08-10T16:28:48.997321 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:141:in `build_instances' +E, [2018-08-10T16:28:48.997347 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/config.rb:117:in `instances' +E, [2018-08-10T16:28:48.997374 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:112:in `filtered_instances' +E, [2018-08-10T16:28:48.997402 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:142:in `parse_subcommand' +E, [2018-08-10T16:28:48.997431 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command/action.rb:35:in `block in call' +E, [2018-08-10T16:28:48.997459 #26331] ERROR -- Kitchen: /Users/kare/.rubies/ruby-2.4.2/lib/ruby/2.4.0/benchmark.rb:293:in `measure' +E, [2018-08-10T16:28:48.997515 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/command/action.rb:34:in `call' +E, [2018-08-10T16:28:48.997566 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:53:in `perform' +E, [2018-08-10T16:28:48.997600 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:187:in `block (2 levels) in ' +E, [2018-08-10T16:28:48.997631 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor/command.rb:27:in `run' +E, [2018-08-10T16:28:48.997666 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command' +E, [2018-08-10T16:28:48.997696 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:334:in `invoke_task' +E, [2018-08-10T16:28:48.997726 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch' +E, [2018-08-10T16:28:48.997766 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/thor-0.20.0/lib/thor/base.rb:466:in `start' +E, [2018-08-10T16:28:48.997796 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/bin/kitchen:13:in `block in ' +E, [2018-08-10T16:28:48.997826 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/lib/kitchen/errors.rb:171:in `with_friendly_errors' +E, [2018-08-10T16:28:48.997855 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/gems/test-kitchen-1.15.0/bin/kitchen:13:in `' +E, [2018-08-10T16:28:48.997882 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/bin/kitchen:23:in `load' +E, [2018-08-10T16:28:48.997918 #26331] ERROR -- Kitchen: /Users/kare/.gem/ruby/2.4.2/bin/kitchen:23:in `
' +E, [2018-08-10T16:28:48.997949 #26331] ERROR -- Kitchen: ----End Backtrace----- diff --git a/cookbooks/ipfs/test/integration/data_bags/credentials/ipfs_cluster.json b/cookbooks/ipfs/test/integration/data_bags/credentials/ipfs_cluster.json new file mode 100644 index 0000000..d2458b2 --- /dev/null +++ b/cookbooks/ipfs/test/integration/data_bags/credentials/ipfs_cluster.json @@ -0,0 +1,4 @@ +{ + "id": "ipfs_cluster", + "secret": "d9de2f31ca7e9989949010fed2e704f42b8e96fa1e8e60a0ad26611f0a01cf07" +} diff --git a/cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb b/cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb new file mode 100644 index 0000000..7db110d --- /dev/null +++ b/cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb @@ -0,0 +1,24 @@ +require 'serverspec' + +# Required by serverspec +set :backend, :exec + +describe 'IPFS' do + # It is in the PATH + describe command('which ipfs') do + its(:exit_status) { should eq 0 } + end + + it 'is listening on port 4001' do + expect(port(4001)).to be_listening + end + + it 'is listening on port 8080 (gateway)' do + expect(port(8080)).to be_listening + end + + it 'has a running service of ipfs' do + expect(service('ipfs')).to be_running + expect(service('ipfs')).to be_enabled + end +end diff --git a/site-cookbooks/ipfs/.kitchen.docker.yml b/site-cookbooks/ipfs/.kitchen.docker.yml deleted file mode 100644 index 2eacee8..0000000 --- a/site-cookbooks/ipfs/.kitchen.docker.yml +++ /dev/null @@ -1,44 +0,0 @@ -me: dokken - privileged: true # because Docker and SystemD/Upstart - chef_image: chef/chef - chef_version: current - -transport: - name: dokken - -provisioner: - name: dokken - -platforms: -- name: debian-7 - driver: - image: debian:7 - pid_one_command: /sbin/init - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: debian-8 - driver: - image: debian:8 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: ubuntu-14.04 - driver: - image: ubuntu-upstart:14.04 - pid_one_command: /sbin/init - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: ubuntu-16.04 - driver: - image: ubuntu:16.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - -suites: -- name: default - run_list: - - recipe[ipfs] diff --git a/site-cookbooks/ipfs/.travis.yml b/site-cookbooks/ipfs/.travis.yml deleted file mode 100644 index 4ec0c53..0000000 --- a/site-cookbooks/ipfs/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -sudo: required -dist: trusty - -# install the pre-release chef-dk. Use chef-stable-trusty to install the stable release -addons: - apt: - sources: - - chef-stable-trusty - packages: - - chefdk - -# Don't `bundle install` which takes about 1.5 mins -install: echo "skip bundle install" - -branches: - only: - - master - -services: docker - -env: - matrix: - # - INSTANCE=default-centos-5 times out for no reason - - INSTANCE=default-centos-6 - - INSTANCE=default-centos-7 - - INSTANCE=default-debian-7 - - INSTANCE=default-debian-8 - - INSTANCE=default-fedora-latest - - INSTANCE=default-opensuse-132 - - INSTANCE=default-opensuse-421 - - INSTANCE=default-ubuntu-1204 - - INSTANCE=default-ubuntu-1404 - - INSTANCE=default-ubuntu-1604 - -before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - eval "$(/opt/chefdk/bin/chef shell-init bash)" - -script: KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} - -matrix: - include: - - before_script: - - eval "$(/opt/chefdk/bin/chef shell-init bash)" - - /opt/chefdk/embedded/bin/chef --version - - /opt/chefdk/embedded/bin/cookstyle --version - - /opt/chefdk/embedded/bin/foodcritic --version - - script: - - /opt/chefdk/bin/chef exec rake -env: UNIT_AND_LINT=1 diff --git a/site-cookbooks/ipfs/Berksfile b/site-cookbooks/ipfs/Berksfile deleted file mode 100644 index 2e1a070..0000000 --- a/site-cookbooks/ipfs/Berksfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://api.berkshelf.com" - -metadata diff --git a/site-cookbooks/ipfs/Gemfile b/site-cookbooks/ipfs/Gemfile deleted file mode 100644 index 01382a5..0000000 --- a/site-cookbooks/ipfs/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -gem "rake" -gem "test-kitchen" -gem "kitchen-vagrant" -gem "berkshelf" diff --git a/site-cookbooks/ipfs/Gemfile.lock b/site-cookbooks/ipfs/Gemfile.lock deleted file mode 100644 index e760d2b..0000000 --- a/site-cookbooks/ipfs/Gemfile.lock +++ /dev/null @@ -1,134 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - addressable (2.5.0) - public_suffix (~> 2.0, >= 2.0.2) - artifactory (2.7.0) - berkshelf (5.2.0) - addressable (~> 2.3, >= 2.3.4) - berkshelf-api-client (>= 2.0.2, < 4.0) - buff-config (~> 2.0) - buff-extensions (~> 2.0) - buff-shell_out (~> 1.0) - cleanroom (~> 1.0) - faraday (~> 0.9) - httpclient (~> 2.7) - minitar (~> 0.5, >= 0.5.4) - mixlib-archive (~> 0.1) - octokit (~> 4.0) - retryable (~> 2.0) - ridley (~> 5.0) - solve (> 2.0, < 4.0) - thor (~> 0.19) - berkshelf-api-client (3.0.0) - faraday (~> 0.9) - httpclient (~> 2.7) - ridley (>= 4.5, < 6.0) - buff-config (2.0.0) - buff-extensions (~> 2.0) - varia_model (~> 0.6) - buff-extensions (2.0.0) - buff-ignore (1.2.0) - buff-ruby_engine (1.0.0) - buff-shell_out (1.1.0) - buff-ruby_engine (~> 1.0) - celluloid (0.16.0) - timers (~> 4.0.0) - celluloid-io (0.16.2) - celluloid (>= 0.16.0) - nio4r (>= 1.1.0) - chef-config (12.19.36) - addressable - fuzzyurl - mixlib-config (~> 2.0) - mixlib-shellout (~> 2.0) - cleanroom (1.0.0) - erubis (2.7.0) - faraday (0.9.2) - multipart-post (>= 1.2, < 3) - fuzzyurl (0.9.0) - hashie (3.5.5) - hitimes (1.2.4) - httpclient (2.8.3) - json (2.0.3) - kitchen-vagrant (1.0.2) - test-kitchen (~> 1.4) - minitar (0.6.1) - mixlib-archive (0.4.1) - mixlib-log - mixlib-authentication (1.4.1) - mixlib-log - mixlib-config (2.2.4) - mixlib-install (2.1.12) - artifactory - mixlib-shellout - mixlib-versioning - thor - mixlib-log (1.7.1) - mixlib-shellout (2.2.7) - mixlib-versioning (1.1.0) - molinillo (0.5.6) - multipart-post (2.0.0) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (4.1.0) - net-ssh-gateway (1.3.0) - net-ssh (>= 2.6.5) - nio4r (2.0.0) - octokit (4.6.2) - sawyer (~> 0.8.0, >= 0.5.3) - public_suffix (2.0.5) - rake (11.3.0) - retryable (2.0.4) - ridley (5.1.0) - addressable - buff-config (~> 2.0) - buff-extensions (~> 2.0) - buff-ignore (~> 1.2) - buff-shell_out (~> 1.0) - celluloid (~> 0.16.0) - celluloid-io (~> 0.16.1) - chef-config (>= 12.5.0) - erubis - faraday (~> 0.9.0) - hashie (>= 2.0.2, < 4.0.0) - httpclient (~> 2.7) - json (>= 1.7.7) - mixlib-authentication (>= 1.3.0) - retryable (~> 2.0) - semverse (~> 2.0) - varia_model (~> 0.6) - safe_yaml (1.0.4) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) - semverse (2.0.0) - solve (3.1.0) - molinillo (>= 0.5) - semverse (>= 1.1, < 3.0) - test-kitchen (1.15.0) - mixlib-install (>= 1.2, < 3.0) - mixlib-shellout (>= 1.2, < 3.0) - net-scp (~> 1.1) - net-ssh (>= 2.9, < 5.0) - net-ssh-gateway (~> 1.2) - safe_yaml (~> 1.0) - thor (~> 0.18) - thor (0.19.4) - timers (4.0.4) - hitimes - varia_model (0.6.0) - buff-extensions (~> 2.0) - hashie (>= 2.0.2, < 4.0.0) - -PLATFORMS - ruby - -DEPENDENCIES - berkshelf - kitchen-vagrant - rake - test-kitchen - -BUNDLED WITH - 1.14.3 diff --git a/site-cookbooks/ipfs/attributes/default.rb b/site-cookbooks/ipfs/attributes/default.rb deleted file mode 100644 index 0186fe5..0000000 --- a/site-cookbooks/ipfs/attributes/default.rb +++ /dev/null @@ -1,7 +0,0 @@ -node.default['ipfs']['version'] = "0.4.9" -node.default['ipfs']['checksum'] = "ae50c760f58548adc7c6dade4cf549059b6bc73ebc25ff4ea9fece06a15ac0a6" -# Do not contact local network addresses. This will stop platforms like Hetzner -# to block your server (https://github.com/ipfs/go-ipfs/issues/1226) -node.default['ipfs']['config']['swarm']['addr_filter'] = ["/ip4/10.0.0.0/ipcidr/8", "/ip4/100.64.0.0/ipcidr/10", "/ip4/169.254.0.0/ipcidr/16", "/ip4/172.16.0.0/ipcidr/12", "/ip4/192.0.0.0/ipcidr/24", "/ip4/192.0.0.0/ipcidr/29", "/ip4/192.0.0.8/ipcidr/32", "/ip4/192.0.0.170/ipcidr/32", "/ip4/192.0.0.171/ipcidr/32", "/ip4/192.0.2.0/ipcidr/24", "/ip4/192.168.0.0/ipcidr/16", "/ip4/198.18.0.0/ipcidr/15", "/ip4/198.51.100.0/ipcidr/24", "/ip4/203.0.113.0/ipcidr/24", "/ip4/240.0.0.0/ipcidr/4"] - -node.default['ipfs']['cluster']['version'] = "0.4.0" diff --git a/site-cookbooks/ipfs/metadata.rb b/site-cookbooks/ipfs/metadata.rb deleted file mode 100644 index 92e7b3e..0000000 --- a/site-cookbooks/ipfs/metadata.rb +++ /dev/null @@ -1,11 +0,0 @@ -name 'ipfs' -maintainer 'Kosmos' -maintainer_email 'mail@kosmos.org' -license 'Apache 2.0' -description 'Installs/Configures ipfs' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.1.0' - -supports %w(ubuntu debian) - -depends 'ark' diff --git a/site-cookbooks/ipfs/recipes/cluster.rb b/site-cookbooks/ipfs/recipes/cluster.rb deleted file mode 100644 index 8b68a13..0000000 --- a/site-cookbooks/ipfs/recipes/cluster.rb +++ /dev/null @@ -1,68 +0,0 @@ -# -# Cookbook Name:: ipfs -# Recipe:: cluster -# -# Copyright 2018, Kosmos -# -# All rights reserved - Do Not Redistribute -# - -version = node["ipfs"]["cluster"]["version"] - -ark "ipfs-cluster-service" do - url "https://dist.ipfs.io/ipfs-cluster-service/v#{version}/ipfs-cluster-service_v#{version}_linux-amd64.tar.gz" - has_binaries ["ipfs-cluster-service"] -end - -ark "ipfs-cluster-ctl" do - url "https://dist.ipfs.io/ipfs-cluster-ctl/v#{version}/ipfs-cluster-ctl_v#{version}_linux-amd64.tar.gz" - has_binaries ["ipfs-cluster-ctl"] -end - -credentials = data_bag_item("credentials", "ipfs_cluster") - -execute "ipfs-cluster-service init" do - user "ipfs" - environment "CLUSTER_SECRET" => credentials["secret"], - "IPFS_CLUSTER_PATH" => "/home/ipfs/.ipfs-cluster" - not_if { File.exist? "/home/ipfs/.ipfs-cluster/service.json" } -end - -if platform?('ubuntu') && node[:platform_version].to_f < 15.04 || - platform?('debian') && node['platform_version'].to_f < 8 - template "ipfs.initd-cluster.service.erb" do - path "/etc/init.d/ipfs-cluster" - source 'ipfs-cluster.initd.service.erb' - owner 'root' - group 'root' - mode '0750' - notifies :restart, "service[ipfs-cluster]", :delayed - end - - service "ipfs-cluster" do - provider Chef::Provider::Service::Init::Debian - action [:enable] - supports start: true, stop: true, restart: true, reload: false, status: true - end - -else - execute "systemctl daemon-reload" do - command "systemctl daemon-reload" - action :nothing - end - - template "ipfs-cluster.systemd.service.erb" do - path "/lib/systemd/system/ipfs-cluster.service" - source 'ipfs-cluster.systemd.service.erb' - owner 'root' - group 'root' - mode '0644' - notifies :run, "execute[systemctl daemon-reload]", :delayed - notifies :restart, "service[ipfs-cluster]", :delayed - end - - service "ipfs-cluster" do - provider Chef::Provider::Service::Systemd - action [:enable] - end -end diff --git a/site-cookbooks/ipfs/recipes/default.rb b/site-cookbooks/ipfs/recipes/default.rb deleted file mode 100644 index ed48382..0000000 --- a/site-cookbooks/ipfs/recipes/default.rb +++ /dev/null @@ -1,78 +0,0 @@ -# -# Cookbook Name:: ipfs -# Recipe:: default -# -# Copyright 2017, Kosmos -# -# All rights reserved - Do Not Redistribute -# - -version = node["ipfs"]["version"] - -ark "ipfs" do - url "https://dist.ipfs.io/go-ipfs/v#{version}/go-ipfs_v#{version}_linux-amd64.tar.gz" - checksum node["ipfs"]["checksum"] - has_binaries ["ipfs"] -end - -group "ipfs" do - gid 4737 -end - -user "ipfs" do - comment "ipfs" - uid 4737 - gid 4737 - home "/home/ipfs" - manage_home true -end - -execute "ipfs init --empty-repo" do - environment "IPFS_PATH" => "/home/ipfs/.ipfs" - user "ipfs" - not_if { File.directory? "/home/ipfs/.ipfs" } -end - -if platform?('ubuntu') && node[:platform_version].to_f < 15.04 || - platform?('debian') && node['platform_version'].to_f < 8 - template "ipfs.initd.service.erb" do - path "/etc/init.d/ipfs" - source 'ipfs.initd.service.erb' - owner 'root' - group 'root' - mode '0750' - notifies :restart, "service[ipfs]", :delayed - end - - service "ipfs" do - provider Chef::Provider::Service::Init::Debian - action [:enable] - supports start: true, stop: true, restart: true, reload: false, status: true - end - -else - execute "systemctl daemon-reload" do - command "systemctl daemon-reload" - action :nothing - end - - template "ipfs.systemd.service.erb" do - path "/lib/systemd/system/ipfs.service" - source 'ipfs.systemd.service.erb' - owner 'root' - group 'root' - mode '0644' - notifies :run, "execute[systemctl daemon-reload]", :delayed - notifies :restart, "service[ipfs]", :delayed - end - - service "ipfs" do - provider Chef::Provider::Service::Systemd - action [:enable] - end -end - -# Configure ipfs to not contact local network addresses -ipfs_config "Swarm.AddrFilters" do - value node['ipfs']['config']['swarm']['addr_filter'] -end diff --git a/site-cookbooks/ipfs/resources/config.rb b/site-cookbooks/ipfs/resources/config.rb deleted file mode 100644 index 1bdc74c..0000000 --- a/site-cookbooks/ipfs/resources/config.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'json' -require 'mixlib/shellout' - -property :key, String, name_property: true -property :value, [String, Hash, Array, TrueClass, FalseClass], required: true - -action :create do - include_recipe "ipfs" - - execute "ipfs config --json #{key} '#{JSON.generate(value)}'" do - environment "IPFS_PATH" => "/home/ipfs/.ipfs" - user "ipfs" - not_if do - cmd = Mixlib::ShellOut.new("ipfs", "config", key, - user: 'ipfs', - env: { "IPFS_PATH" => "/home/ipfs/.ipfs" }) - cmd.run_command - begin - JSON.parse(cmd.stdout) == JSON.parse(JSON.generate(value)) - rescue JSON::ParserError - cmd.stdout.include?("#{value}") - end - end - notifies :restart, "service[ipfs]", :delayed - end -end diff --git a/site-cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb b/site-cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb deleted file mode 100644 index ab11365..0000000 --- a/site-cookbooks/ipfs/test/integration/default/serverspec/ipfs_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'serverspec' - -# Required by serverspec -set :backend, :exec - -describe "IPFS" do - # It is in the PATH - describe command("which ipfs") do - its(:exit_status) { should eq 0 } - end - - it "is listening on port 4001" do - expect(port(4001)).to be_listening - end - - it "is listening on port 8080 (gateway)" do - expect(port(8080)).to be_listening - end - - it "has a running service of ipfs" do - expect(service("ipfs")).to be_running - expect(service("ipfs")).to be_enabled - end -end