diff --git a/site-cookbooks/kosmos-bitcoin/.delivery/project.toml b/site-cookbooks/kosmos-bitcoin/.delivery/project.toml new file mode 100644 index 0000000..2868a95 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/.delivery/project.toml @@ -0,0 +1,34 @@ +# Delivery for Local Phases Execution +# +# This file allows you to execute test phases locally on a workstation or +# in a CI pipeline. The delivery-cli will read this file and execute the +# command(s) that are configured for each phase. You can customize them +# by just modifying the phase key on this file. +# +# By default these phases are configured for Cookbook Workflow only +# + +[local_phases] +unit = "chef exec rspec spec/" +lint = "chef exec cookstyle" +# Foodcritic includes rules only appropriate for community cookbooks +# uploaded to Supermarket. We turn off any rules tagged "supermarket" +# by default. If you plan to share this cookbook you should remove +# '-t ~supermarket' below to enable supermarket rules. +syntax = "chef exec foodcritic . -t ~supermarket" +provision = "chef exec kitchen create" +deploy = "chef exec kitchen converge" +smoke = "chef exec kitchen verify" +# The functional phase is optional, you can define it by uncommenting +# the line below and running the command: `delivery local functional` +# functional = "" +cleanup = "chef exec kitchen destroy" + +# Remote project.toml file +# +# Instead of the local phases above, you may specify a remote URI location for +# the `project.toml` file. This is useful for teams that wish to centrally +# manage the behavior of the `delivery local` command across many different +# projects. +# +# remote_file = "https://url/project.toml" diff --git a/site-cookbooks/kosmos-bitcoin/.gitignore b/site-cookbooks/kosmos-bitcoin/.gitignore new file mode 100644 index 0000000..9abf29f --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/.gitignore @@ -0,0 +1,22 @@ +.vagrant +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ + +# Bundler +Gemfile.lock +gems.locked +bin/* +.bundle/* + +# test kitchen +.kitchen/ +kitchen.local.yml + +# Chef +Berksfile.lock +.zero-knife.rb +Policyfile.lock.json diff --git a/site-cookbooks/kosmos-bitcoin/CHANGELOG.md b/site-cookbooks/kosmos-bitcoin/CHANGELOG.md new file mode 100644 index 0000000..533e3aa --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/CHANGELOG.md @@ -0,0 +1,11 @@ +# kosmos-bitcoin CHANGELOG + +This file is used to list changes made in each version of the kosmos-bitcoin cookbook. + +# 0.1.0 + +Initial release. + +- change 0 +- change 1 + diff --git a/site-cookbooks/kosmos-bitcoin/LICENSE b/site-cookbooks/kosmos-bitcoin/LICENSE new file mode 100644 index 0000000..10b5688 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/LICENSE @@ -0,0 +1,3 @@ +Copyright 2019 The Authors + +All rights reserved, do not redistribute. diff --git a/site-cookbooks/kosmos-bitcoin/Policyfile.rb b/site-cookbooks/kosmos-bitcoin/Policyfile.rb new file mode 100644 index 0000000..333e86e --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/Policyfile.rb @@ -0,0 +1,16 @@ +# Policyfile.rb - Describe how you want Chef Infra Client to build your system. +# +# For more information on the Policyfile feature, visit +# https://docs.chef.io/policyfile.html + +# A name that describes what the system you're building with Chef does. +name 'kosmos-bitcoin' + +# Where to find external cookbooks: +default_source :supermarket + +# run_list: chef-client will run these recipes in the order specified. +run_list 'kosmos-bitcoin::default' + +# Specify a custom source for a single cookbook: +cookbook 'kosmos-bitcoin', path: '.' diff --git a/site-cookbooks/kosmos-bitcoin/README.md b/site-cookbooks/kosmos-bitcoin/README.md new file mode 100644 index 0000000..85db7e1 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/README.md @@ -0,0 +1,3 @@ +# kosmos-bitcoin + +Installs/configures bitcoin core node diff --git a/site-cookbooks/kosmos-bitcoin/attributes/default.rb b/site-cookbooks/kosmos-bitcoin/attributes/default.rb new file mode 100644 index 0000000..c0b0831 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/attributes/default.rb @@ -0,0 +1,2 @@ +node.default['bitcoin']['username'] = 'satoshi' +node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin' diff --git a/site-cookbooks/kosmos-bitcoin/chefignore b/site-cookbooks/kosmos-bitcoin/chefignore new file mode 100644 index 0000000..5039e1c --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/chefignore @@ -0,0 +1,110 @@ +# Put files/directories that should be ignored in this file when uploading +# to a Chef Infra Server or Supermarket. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +ehthumbs.db +Icon? +nohup.out +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +.#* +.project +.settings +*_flymake +*_flymake.* +*.bak +*.sw[a-z] +*.tmproj +*~ +\#* +mkmf.log +REVISION +TAGS* +tmtags + +## COMPILED ## +############## +*.class +*.com +*.dll +*.exe +*.o +*.pyc +*.so +*/rdoc/ +a.out + +# Testing # +########### +.circleci/* +.codeclimate.yml +.foodcritic +.kitchen* +.rspec +.rubocop.yml +.travis.yml +.watchr +azure-pipelines.yml +examples/* +features/* +Guardfile +kitchen.yml* +Procfile +Rakefile +spec/* +spec/* +spec/fixtures/* +test/* + +# SCM # +####### +.git +.gitattributes +.gitconfig +.github/* +.gitignore +.gitmodules +.svn +*/.bzr/* +*/.git +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Bundler # +########### +vendor/* +Gemfile +Gemfile.lock + +# Policyfile # +############## +Policyfile.rb +Policyfile.lock.json + +# Cookbooks # +############# +CHANGELOG* +CONTRIBUTING* +TESTING* +CODE_OF_CONDUCT* + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/site-cookbooks/kosmos-bitcoin/kitchen.yml b/site-cookbooks/kosmos-bitcoin/kitchen.yml new file mode 100644 index 0000000..e5bbf3c --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/kitchen.yml @@ -0,0 +1,32 @@ +--- +driver: + name: vagrant + +## The forwarded_port port feature lets you connect to ports on the VM guest via +## localhost on the host. +## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html + +# network: +# - ["forwarded_port", {guest: 80, host: 8080}] + +provisioner: + name: chef_zero + + ## product_name and product_version specifies a specific Chef product and version to install. + ## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen.html + # product_name: chef + # product_version: 15 + +verifier: + name: inspec + +platforms: + - name: ubuntu-18.04 + - name: centos-7 + +suites: + - name: default + verifier: + inspec_tests: + - test/integration/default + attributes: diff --git a/site-cookbooks/kosmos-bitcoin/metadata.rb b/site-cookbooks/kosmos-bitcoin/metadata.rb new file mode 100644 index 0000000..f2f0bb3 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/metadata.rb @@ -0,0 +1,20 @@ +name 'kosmos-bitcoin' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'All Rights Reserved' +description 'Installs/Configures kosmos-bitcoin' +long_description 'Installs/Configures kosmos-bitcoin' +version '0.1.0' +chef_version '>= 14.0' + +# The `issues_url` points to the location where issues for this cookbook are +# tracked. A `View Issues` link will be displayed on this cookbook's page when +# uploaded to a Supermarket. +# +# issues_url 'https://github.com//kosmos-bitcoin/issues' + +# The `source_url` points to the development repository for this cookbook. A +# `View Source` link will be displayed on this cookbook's page when uploaded to +# a Supermarket. +# +# source_url 'https://github.com//kosmos-bitcoin' diff --git a/site-cookbooks/kosmos-bitcoin/recipes/default.rb b/site-cookbooks/kosmos-bitcoin/recipes/default.rb new file mode 100644 index 0000000..594251e --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/recipes/default.rb @@ -0,0 +1,44 @@ +# +# Cookbook:: kosmos-bitcoin +# Recipe:: default +# +# The MIT License (MIT) +# +# Copyright:: 2019, 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. +# + +package 'snapd' + +snap_package 'bitcoin-core' + +bitcoin_user = node['bitcoin']['username'] + +# TODO create bitcoin datadir +# TODO create bitcoin.conf in datadir + +mount "/home/#{bitcoin_user}/snap/bitcoin-core/common/.bitcoin" do + device node['bitcoin']['data_dir'] + fstype 'none' + options 'bind' + action [:mount] +end + +# TODO create systemd service for bitcoin-core.daemon diff --git a/site-cookbooks/kosmos-bitcoin/spec/spec_helper.rb b/site-cookbooks/kosmos-bitcoin/spec/spec_helper.rb new file mode 100644 index 0000000..6cd61e5 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/policyfile' diff --git a/site-cookbooks/kosmos-bitcoin/spec/unit/recipes/default_spec.rb b/site-cookbooks/kosmos-bitcoin/spec/unit/recipes/default_spec.rb new file mode 100644 index 0000000..f4b411c --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/spec/unit/recipes/default_spec.rb @@ -0,0 +1,29 @@ +# +# Cookbook:: kosmos-bitcoin +# Spec:: default +# +# Copyright:: 2019, The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'kosmos-bitcoin::default' do + context 'When all attributes are default, on Ubuntu 18.04' do + # for a complete list of available platforms and versions see: + # https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md + platform 'ubuntu', '18.04' + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end + + context 'When all attributes are default, on CentOS 7' do + # for a complete list of available platforms and versions see: + # https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md + platform 'centos', '7' + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/site-cookbooks/kosmos-bitcoin/test/integration/default/default_test.rb b/site-cookbooks/kosmos-bitcoin/test/integration/default/default_test.rb new file mode 100644 index 0000000..71aba37 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/test/integration/default/default_test.rb @@ -0,0 +1,16 @@ +# InSpec test for recipe kosmos-bitcoin::default + +# The InSpec reference, with examples and extensive documentation, can be +# found at https://www.inspec.io/docs/reference/resources/ + +unless os.windows? + # This is an example test, replace with your own test. + describe user('root'), :skip do + it { should exist } + end +end + +# This is an example test, replace it with your own test. +describe port(80), :skip do + it { should_not be_listening } +end