41 Commits

Author SHA1 Message Date
basti 9f430fa6d2 Bump cookbook version 2020-10-25 11:25:48 +01:00
basti 05a04ac832 Update go-ipfs to 0.7 2020-10-25 11:18:25 +01:00
basti 2dfbc073ed Merge pull request #16 from 67P/bugfix/14-restart_on_update
Restart the service on update
2019-08-14 19:01:33 +02:00
basti e2c00c2afb Merge pull request #15 from 67P/bugfix/specs
Fix the specs
2019-08-14 18:59:32 +02:00
greg b3b03a9744 Remove Ubuntu 16.04 from the Travis matrix 2019-08-14 17:10:14 +02:00
greg d845e3443a Add the CHEF_LICENSE environment variable again 2019-08-14 17:07:30 +02:00
greg ae5a27d100 Fix a linting error 2019-08-14 17:05:39 +02:00
greg 200552d1b7 Restart the service on update
A restart notification on the service was missing on the ark resource
that takes care of downloading and installing/updating go-ipfs

Fixes #14
2019-08-14 17:02:20 +02:00
greg 856b48d015 Fix the specs not being seen on Travis 2019-08-14 16:49:16 +02:00
greg 9fd88a7da3 Accept the Chef license as part of the config files 2019-08-14 16:47:41 +02:00
greg 2552847d7e Remove the deleted cluster specs from the kitchen config files 2019-08-14 16:38:30 +02:00
greg b6028ffff8 Do not run specs on Ubuntu 16.04 2019-08-14 16:38:30 +02:00
greg f25802a6ce Fix the checks for the default config in the integration specs 2019-08-14 16:33:03 +02:00
basti 5c31191ff8 Merge pull request #12 from 67P/feature/go-ipfs_0.4.22
Update go-ipfs to 0.4.22
2019-08-14 11:32:43 +02:00
greg 7dc20eea12 Update go-ipfs to 0.4.22
https://blog.ipfs.io/054-go-ipfs-0.4.22

Closes #11
2019-08-14 11:27:17 +02:00
greg 1d09c15108 Fix Markdown line break 2019-07-05 16:01:24 +02:00
greg 79a12165a2 Update the README 2019-07-05 15:59:53 +02:00
basti 0c6416f9c7 Merge pull request #10 from 67P/feature/better_config
Improve the default config
2019-07-05 15:56:11 +02:00
greg 7b524204c8 Update the README for the changes to the config attribute 2019-07-05 15:50:30 +02:00
greg f118a954fa Another linting fix 2019-07-05 15:46:22 +02:00
greg 468b6d9a9d Fix the linting warnings 2019-07-05 15:42:13 +02:00
greg 679f78d248 Bump the cookbook version
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:29:13 +02:00
greg 9cdbf6d947 Use the new attributes for ulimit and max memory
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:29:08 +02:00
greg 0e6ac38434 Improve the default config
Enable CORS and writeable gateway by default, remove config that only
applies to Kosmos

Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:29:02 +02:00
greg d54e962926 Get rid of the cluster recipes and tests
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:28:54 +02:00
greg 95e92a0703 Bump the ipfs version, remove the ipfs-cluster attributes
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2019-07-05 15:28:12 +02:00
basti 3d4e9cceea Merge pull request #7 from 67P/feature/5-default_config_attributes
Move the default config to a Chef attribute
2019-06-25 15:47:03 +02:00
greg cfa3435c40 Fix the indentation of an EOF in the integration tests 2019-06-20 19:10:29 +02:00
greg 01c2246454 Bump the cookbook version 2019-06-20 18:22:57 +02:00
greg b2c7416087 Merge branch 'master' into feature/5-default_config_attributes 2019-06-20 18:22:44 +02:00
Greg Karékinian 6d31746a87 Merge pull request #8 from 67P/feature/cluster_checksums
Add the checksums for the cluster packages
2019-06-20 18:20:26 +02:00
greg 18d04d68fd Accept the Chef license agreement on Travis
Based on
https://github.com/chef-cookbooks/habitat/blob/c3eaf7eac23d17a82f6eec280f973aecf5243744/.travis.yml
2019-06-20 18:08:24 +02:00
greg ddad121924 Add the checksums for the cluster packages
It prevents Chef from trying to download the packages again if the files
are already present with the correct checksum
2019-06-20 13:00:08 +02:00
greg ae97c0d739 Fix the linting errors 2019-05-09 19:29:38 +02:00
greg 553ec510eb Move the default config to a Chef attribute
This is tested by serverspec integration test

Closes #5
2019-05-09 18:38:56 +02:00
basti c6a0159e82 Merge pull request #4 from 67P/feature/reduce_memory_usage
Reduce the memory usage of go-ipfs
2019-05-07 15:21:08 +02:00
greg 5aa50ecc7e Fix the ipfs_config resource to handle integers too 2019-05-07 14:55:41 +02:00
greg f22b7d9b1f Update the Berksfile.lock file 2019-05-07 14:55:29 +02:00
greg 5303612854 Turn integers into strings for now 2019-05-07 14:41:06 +02:00
greg 76d60b87dd Reduce the memory usage of go-ipfs
Lower the number of connections, change the routing mode to dhtclient,
and disable bandwidth metrics. This is hardcoded for now
2019-05-07 14:30:29 +02:00
greg c6853c4d09 Set the maximum number of open files in the systemd unit
This prevents IPFS reaching the limit (1024 by default), which is
treated like a low disk space threshold by ipfs and ipfs-cluster
2019-04-26 15:54:33 +02:00
19 changed files with 93 additions and 389 deletions
+2 -9
View File
@@ -13,12 +13,10 @@ provisioner:
verifier: verifier:
name: inspec name: inspec
root_path: '/opt/verifier' # Needed for the specs to be detected in Docker
chef_license: accept
platforms: platforms:
- name: ubuntu-16.04
driver:
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
- name: ubuntu-18.04 - name: ubuntu-18.04
driver: driver:
image: dokken/ubuntu-18.04 image: dokken/ubuntu-18.04
@@ -33,8 +31,3 @@ suites:
run_list: run_list:
- recipe[ipfs::default] - recipe[ipfs::default]
attributes: attributes:
- name: cluster
run_list:
- recipe[ipfs::cluster]
- recipe[ipfs::cluster_service]
attributes:
+3 -6
View File
@@ -6,17 +6,14 @@ provisioner:
name: chef_zero name: chef_zero
platforms: platforms:
- name: ubuntu-16.04
- name: ubuntu-18.04 - name: ubuntu-18.04
- name: debian-9 - name: debian-9
verifier:
chef_license: accept
suites: suites:
- name: default - name: default
run_list: run_list:
- recipe[ipfs::default] - recipe[ipfs::default]
attributes: attributes:
- name: cluster
run_list:
- recipe[ipfs::cluster]
- recipe[ipfs::cluster_service]
attributes:
+3 -4
View File
@@ -20,20 +20,19 @@ services: docker
env: env:
matrix: matrix:
- INSTANCE=default-debian-9 - INSTANCE=default-debian-9
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-ubuntu-1804 - INSTANCE=default-ubuntu-1804
before_script: before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(chef shell-init bash)" - eval "$(chef shell-init bash)"
- chef --version - CHEF_LICENSE=accept-no-persist chef --version
- cookstyle --version - cookstyle --version
- foodcritic --version - foodcritic --version
script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml CHEF_VERSION=13.10.4 kitchen verify ${INSTANCE} script: CHEF_LICENSE=accept-no-persist KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen test ${INSTANCE}
matrix: matrix:
include: include:
- script: - script:
- chef exec delivery local all - CHEF_LICENSE=accept-no-persist chef exec delivery local all
env: UNIT_AND_LINT=1 env: UNIT_AND_LINT=1
+1 -1
View File
@@ -10,7 +10,7 @@ GRAPH
build-essential (8.1.1) build-essential (8.1.1)
mingw (>= 1.1) mingw (>= 1.1)
seven_zip (>= 0.0.0) seven_zip (>= 0.0.0)
ipfs (0.1.0) ipfs (0.4.2)
ark (>= 0.0.0) ark (>= 0.0.0)
mingw (2.1.0) mingw (2.1.0)
seven_zip (>= 0.0.0) seven_zip (>= 0.0.0)
+9 -11
View File
@@ -1,23 +1,23 @@
# ipfs Cookbook # IPFS Cookbook
This cookbook installs ipfs and starts it as a daemon This cookbook installs go-ipfs and starts it as a daemon
## Requirements ## Requirements
### Platforms ### Platforms
This cookbook is tested on Ubuntu 16.06, 14.04 and Debian 8 using Test Kitchen. This cookbook is tested on Ubuntu 18.06, 16.04 and Debian 9 using Test Kitchen.
It currently only supports 64bit platforms It currently only supports 64bit platforms
### Chef ### Chef
- Chef 12.5 or later (we are providing a - Chef 12.5 or later (the cookbook provides a
[Custom Resource](https://docs.chef.io/custom_resources.html) to configure [Custom Resource](https://docs.chef.io/custom_resources.html) to configure
IPFS) go-ipfs)
### Cookbook dependencies ### Cookbook dependencies
- `ark` to download and uncompress the Go IPFS package - `ark` to download and uncompress the go-ipfs package
## Usage ## Usage
@@ -36,12 +36,10 @@ Just include `ipfs` in your node's `run_list`:
## Attributes ## Attributes
- `node.['ipfs']['version']` - the Go IPFS version to download from the official - `node['ipfs']['version']` - the go-ipfs version to download from the official
site (64bit) site (64bit)
- `node['ipfs']['checksum']` - the SHA256 checksum for the package - `node['ipfs']['checksum']` - the SHA256 checksum for the package
- `node['ipfs']['config']['swarm']['addr_filter']` - the network ranges to not - `node['ipfs']['config']` - a hash of config options
connect to. This will stop platforms like Hetzner to block your server
(https://github.com/ipfs/go-ipfs/issues/1226)
## Resources ## Resources
@@ -67,7 +65,7 @@ kitchen verify # Run the integration tests for Ubuntu 16.04, 18.06 and Debian 9
## License and Authors ## License and Authors
Authors: Kosmos Developers mail@kosmos.org Authors: Kosmos Developers mail@kosmos.org
Copyright: 2018, [Kosmos Developers](https://kredits.kosmos.org/) Copyright: 2018-2019, [Kosmos Developers](https://kredits.kosmos.org/)
``` ```
Unless otherwise noted, all files are released under the MIT license, possible Unless otherwise noted, all files are released under the MIT license, possible
+30 -6
View File
@@ -1,7 +1,31 @@
node.default['ipfs']['version'] = '0.4.17' node.default['ipfs']['version'] = '0.7.0'
node.default['ipfs']['checksum'] = '1bb1050ebe74f9042ac721eb1b71f92e1b0e78e54c59dadfde13080facb2901c' node.default['ipfs']['checksum'] = 'ef7c3f1bcae94c13c6e1033855ff99bb8e19089e01ea5018437847854c8c811f'
# 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' node.default['ipfs']['ulimit'] = 64000
node.default['ipfs']['memory_max'] = '512M'
node.default['ipfs']['config'] = {
# Do not contact local network addresses. This will stop platforms like Hetzner
# to block your server (https://github.com/ipfs/go-ipfs/issues/1226)
'Swarm.AddrFilters' => ['/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'],
# Set up the Gateway to be writable
'Gateway.Writable' => true,
# Set up CORS headers
'API.HTTPHeaders.Access-Control-Allow-Credentials' => ['true'],
'API.HTTPHeaders.Access-Control-Allow-Methods' => %w(PUT GET POST),
'API.HTTPHeaders.Access-Control-Allow-Origin' => ['*'],
}
+2 -2
View File
@@ -2,9 +2,9 @@ name 'ipfs'
maintainer 'Kosmos Developers' maintainer 'Kosmos Developers'
maintainer_email 'mail@kosmos.org' maintainer_email 'mail@kosmos.org'
license 'MIT' license 'MIT'
description 'Installs/Configures ipfs' description 'Installs/Configures go-ipfs'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.2' version '0.7.0'
supports %w(ubuntu debian) supports %w(ubuntu debian)
-48
View File
@@ -1,48 +0,0 @@
#
# Cookbook Name:: ipfs
# Recipe:: cluster
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
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
-33
View File
@@ -1,33 +0,0 @@
#
# Cookbook Name:: ipfs
# Recipe:: cluster_bootstrap
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
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
-64
View File
@@ -1,64 +0,0 @@
#
# Cookbook Name:: ipfs
# Recipe:: cluster_service
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
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
+5 -3
View File
@@ -32,6 +32,7 @@ ark 'ipfs' do
url "https://dist.ipfs.io/go-ipfs/v#{version}/go-ipfs_v#{version}_linux-amd64.tar.gz" url "https://dist.ipfs.io/go-ipfs/v#{version}/go-ipfs_v#{version}_linux-amd64.tar.gz"
checksum node['ipfs']['checksum'] checksum node['ipfs']['checksum']
has_binaries ['ipfs'] has_binaries ['ipfs']
notifies :restart, 'service[ipfs]', :delayed
end end
execute 'ipfs init --empty-repo' do execute 'ipfs init --empty-repo' do
@@ -79,7 +80,8 @@ else
end end
end end
# Configure ipfs to not contact local network addresses node['ipfs']['config'].each do |k, v|
ipfs_config 'Swarm.AddrFilters' do ipfs_config k do
value node['ipfs']['config']['swarm']['addr_filter'] value v
end
end end
+1 -1
View File
@@ -2,7 +2,7 @@ require 'json'
require 'mixlib/shellout' require 'mixlib/shellout'
property :key, String, name_property: true property :key, String, name_property: true
property :value, [String, Hash, Array, TrueClass, FalseClass], required: true property :value, [String, Hash, Array, TrueClass, FalseClass, Integer], required: true
action :create do action :create do
include_recipe 'ipfs' include_recipe 'ipfs'
-55
View File
@@ -1,55 +0,0 @@
#
# Cookbook:: ipfs
# Spec:: default
#
# The MIT License (MIT)
#
# Copyright:: 2018, Kosmos Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
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
@@ -1,102 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: ipfs-cluster daemon
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the ipfs-cluster daemon
# Description: Starts the ipfs-cluster daemon using the start-stop-daemon
### END INIT INFO
# Author: Dylan Powers <dylan.kyle.powers@gmail.com
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="ipfs-cluster daemon"
NAME=ipfs-cluster
DAEMON=/usr/local/bin/ipfs-cluster-service
DAEMON_ARGS="daemon --upgrade"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
IPFS_PATH=/home/ipfs/.ipfs
IPFS_USER=ipfs
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start() {
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test >/dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \
--background --chuid $IPFS_USER --no-close \
--exec /usr/bin/env IPFS_PATH="$IPFS_PATH" $DAEMON 2>>$IPFS_PATH/daemon.log 1>/dev/null \
-- $DAEMON_ARGS \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop() {
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Delete the pid
rm -f $PIDFILE
return "$RETVAL"
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart)
do_stop
do_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
exit 3
;;
esac
@@ -1,11 +0,0 @@
[Unit]
Description=Start ipfs-cluster
[Service]
ExecStart=/usr/local/bin/ipfs-cluster-service daemon --upgrade
User=ipfs
Group=ipfs
Restart=always
[Install]
WantedBy=multi-user.target
+5 -1
View File
@@ -2,10 +2,14 @@
Description=Start ipfs Description=Start ipfs
[Service] [Service]
ExecStart=/usr/local/bin/ipfs daemon --migrate ExecStart=/usr/local/bin/ipfs daemon --migrate --routing=dhtclient
User=ipfs User=ipfs
Group=ipfs Group=ipfs
Restart=always Restart=always
# Raise the ulimit (max number of open files)
LimitNOFILE=<%= node['ipfs']['ulimit'] %>
# Limit the memory usage
MemoryMax=<%= node['ipfs']['memory_max'] %>
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -1,27 +0,0 @@
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
@@ -1,4 +0,0 @@
{
"id": "ipfs_cluster",
"secret": "d9de2f31ca7e9989949010fed2e704f42b8e96fa1e8e60a0ad26611f0a01cf07"
}
@@ -1,4 +1,5 @@
require 'serverspec' require 'serverspec'
require 'json'
# Required by serverspec # Required by serverspec
set :backend, :exec set :backend, :exec
@@ -21,4 +22,34 @@ describe 'IPFS' do
expect(service('ipfs')).to be_running expect(service('ipfs')).to be_running
expect(service('ipfs')).to be_enabled expect(service('ipfs')).to be_enabled
end end
addr_filters = <<-EOF
[
"/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"
]
EOF
{
'Swarm.AddrFilters' => addr_filters.rstrip,
'Gateway.Writable' => true,
}.each do |k, v|
describe command("IPFS_PATH=/home/ipfs/.ipfs ipfs config '#{k}'") do
let(:sudo_options) { '-u ipfs -i' }
its(:stdout) { should eq "#{v}\n" }
end
end
end end