Compare commits
No commits in common. "master" and "v0.1.1" have entirely different histories.
@ -13,10 +13,12 @@ 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
|
||||||
@ -31,3 +33,8 @@ 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:
|
||||||
|
@ -6,14 +6,17 @@ 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:
|
||||||
|
@ -20,19 +20,20 @@ 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_LICENSE=accept-no-persist chef --version
|
- chef --version
|
||||||
- cookstyle --version
|
- cookstyle --version
|
||||||
- foodcritic --version
|
- foodcritic --version
|
||||||
|
|
||||||
script: CHEF_LICENSE=accept-no-persist KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen test ${INSTANCE}
|
script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml CHEF_VERSION=13.10.4 kitchen verify ${INSTANCE}
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- script:
|
- script:
|
||||||
- CHEF_LICENSE=accept-no-persist chef exec delivery local all
|
- chef exec delivery local all
|
||||||
env: UNIT_AND_LINT=1
|
env: UNIT_AND_LINT=1
|
||||||
|
@ -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.4.2)
|
ipfs (0.1.0)
|
||||||
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)
|
||||||
|
22
README.md
22
README.md
@ -1,23 +1,23 @@
|
|||||||
# IPFS Cookbook
|
# ipfs Cookbook
|
||||||
|
|
||||||
This cookbook installs go-ipfs and starts it as a daemon
|
This cookbook installs ipfs and starts it as a daemon
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
### Platforms
|
### Platforms
|
||||||
|
|
||||||
This cookbook is tested on Ubuntu 18.06, 16.04 and Debian 9 using Test Kitchen.
|
This cookbook is tested on Ubuntu 16.06, 14.04 and Debian 8 using Test Kitchen.
|
||||||
It currently only supports 64bit platforms
|
It currently only supports 64bit platforms
|
||||||
|
|
||||||
### Chef
|
### Chef
|
||||||
|
|
||||||
- Chef 12.5 or later (the cookbook provides a
|
- Chef 12.5 or later (we are providing a
|
||||||
[Custom Resource](https://docs.chef.io/custom_resources.html) to configure
|
[Custom Resource](https://docs.chef.io/custom_resources.html) to configure
|
||||||
go-ipfs)
|
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,10 +36,12 @@ 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']` - a hash of config options
|
- `node['ipfs']['config']['swarm']['addr_filter']` - the network ranges to not
|
||||||
|
connect to. This will stop platforms like Hetzner to block your server
|
||||||
|
(https://github.com/ipfs/go-ipfs/issues/1226)
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
@ -64,8 +66,8 @@ 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-2019, [Kosmos Developers](https://kredits.kosmos.org/)
|
Copyright: 2018, [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
|
||||||
|
@ -1,31 +1,7 @@
|
|||||||
node.default['ipfs']['version'] = '0.12.2'
|
node.default['ipfs']['version'] = '0.4.17'
|
||||||
node.default['ipfs']['checksum'] = 'd1b376fe1fb081631af773ea05632090dd79ae5a0057f8b8a0202c28b64a966d14bbfde768ce5a993745761ce56ceed6323a6bd1714f9ae71fa4d68fcbeb1dbb'
|
node.default['ipfs']['checksum'] = '1bb1050ebe74f9042ac721eb1b71f92e1b0e78e54c59dadfde13080facb2901c'
|
||||||
|
# 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']['ulimit'] = 64000
|
node.default['ipfs']['cluster']['version'] = '0.4.0'
|
||||||
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,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 go-ipfs'
|
description 'Installs/Configures 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.8.0'
|
version '0.1.1'
|
||||||
|
|
||||||
supports %w(ubuntu debian)
|
supports %w(ubuntu debian)
|
||||||
|
|
||||||
|
@ -2,6 +2,27 @@
|
|||||||
# Cookbook Name:: ipfs
|
# Cookbook Name:: ipfs
|
||||||
# Recipe:: _user
|
# Recipe:: _user
|
||||||
#
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
group 'ipfs' do
|
group 'ipfs' do
|
||||||
gid 4737
|
gid 4737
|
||||||
@ -12,6 +33,5 @@ user 'ipfs' do
|
|||||||
uid 4737
|
uid 4737
|
||||||
gid 4737
|
gid 4737
|
||||||
home '/home/ipfs'
|
home '/home/ipfs'
|
||||||
shell '/bin/bash'
|
|
||||||
manage_home true
|
manage_home true
|
||||||
end
|
end
|
||||||
|
48
recipes/cluster.rb
Normal file
48
recipes/cluster.rb
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#
|
||||||
|
# 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
recipes/cluster_bootstrap.rb
Normal file
33
recipes/cluster_bootstrap.rb
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#
|
||||||
|
# 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
recipes/cluster_service.rb
Normal file
64
recipes/cluster_service.rb
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#
|
||||||
|
# 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
|
@ -2,6 +2,27 @@
|
|||||||
# Cookbook Name:: ipfs
|
# Cookbook Name:: ipfs
|
||||||
# Recipe:: default
|
# Recipe:: 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.
|
||||||
|
|
||||||
include_recipe 'ipfs::_user'
|
include_recipe 'ipfs::_user'
|
||||||
|
|
||||||
@ -11,7 +32,6 @@ 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
|
||||||
@ -59,8 +79,7 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
node['ipfs']['config'].each do |k, v|
|
# Configure ipfs to not contact local network addresses
|
||||||
ipfs_config k do
|
ipfs_config 'Swarm.AddrFilters' do
|
||||||
value v
|
value node['ipfs']['config']['swarm']['addr_filter']
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -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, Integer], required: true
|
property :value, [String, Hash, Array, TrueClass, FalseClass], required: true
|
||||||
|
|
||||||
action :create do
|
action :create do
|
||||||
include_recipe 'ipfs'
|
include_recipe 'ipfs'
|
||||||
|
55
spec/unit/recipes/cluster_service_spec.rb
Normal file
55
spec/unit/recipes/cluster_service_spec.rb
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#
|
||||||
|
# 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
|
102
templates/default/ipfs-cluster.initd.service.erb
Normal file
102
templates/default/ipfs-cluster.initd.service.erb
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
#!/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
|
11
templates/default/ipfs-cluster.systemd.service.erb
Normal file
11
templates/default/ipfs-cluster.systemd.service.erb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[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
|
@ -2,14 +2,10 @@
|
|||||||
Description=Start ipfs
|
Description=Start ipfs
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/local/bin/ipfs daemon --migrate --routing=dhtclient
|
ExecStart=/usr/local/bin/ipfs daemon --migrate
|
||||||
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
|
||||||
|
27
test/integration/cluster/serverspec/ipfs_cluster_spec.rb
Normal file
27
test/integration/cluster/serverspec/ipfs_cluster_spec.rb
Normal file
@ -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
|
4
test/integration/data_bags/credentials/ipfs_cluster.json
Normal file
4
test/integration/data_bags/credentials/ipfs_cluster.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"id": "ipfs_cluster",
|
||||||
|
"secret": "d9de2f31ca7e9989949010fed2e704f42b8e96fa1e8e60a0ad26611f0a01cf07"
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
require 'serverspec'
|
require 'serverspec'
|
||||||
require 'json'
|
|
||||||
|
|
||||||
# Required by serverspec
|
# Required by serverspec
|
||||||
set :backend, :exec
|
set :backend, :exec
|
||||||
@ -22,34 +21,4 @@ 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user