diff --git a/.chef/config.rb b/.chef/config.rb deleted file mode 100644 index 9269f533..00000000 --- a/.chef/config.rb +++ /dev/null @@ -1,29 +0,0 @@ -# Configurable Variables (Change these to not depend on environment variables!) -my_orgname = ENV['OPSCODE_ORGNAME'] -my_chef_server_url = ENV['KNIFE_CHEF_SERVER'] -my_cookbook_copyright = ENV['KNIFE_COOKBOOK_COPYRIGHT'] -my_cookbook_license = ENV['KNIFE_COOKBOOK_LICENSE'] -my_cookbook_email = ENV['KNIFE_COOKBOOK_EMAIL'] - - -# Configuration -current_dir = File.dirname(__FILE__) -node_name ENV['OPSCODE_USER'] -client_key "#{ENV['KNIFE_CLIENT_KEY_FOLDER']}/#{ENV['OPSCODE_USER']}.pem" -validation_client_name "#{my_orgname}-validator" -validation_key "#{ENV['KNIFE_VALIDATION_KEY_FOLDER']}/#{my_orgname}-validator.pem" -chef_server_url my_chef_server_url - -# Caching -cache_type 'BasicFile' -cache_options( :path => ENV['KNIFE_CACHE_PATH'] ) - -# Logging -log_level :info -log_location STDOUT - -# Cookbooks -cookbook_path ["#{current_dir}/../main-cookbooks"] -cookbook_copyright my_cookbook_copyright -cookbook_license my_cookbook_license -cookbook_email my_cookbook_email diff --git a/.gitignore b/.gitignore index 21814a9c..ba30fdab 100644 --- a/.gitignore +++ b/.gitignore @@ -150,18 +150,9 @@ docs/_build/** .vagrant +extensions/* +!extensions/.gitkeep + # Ignore workspace sub directories workspace/* !workspace/.gitkeep - -home/.virtualenvs/* -!home/.virtualenvs/.gitkeep - -home/.docker/* -!home/.docker/.gitkeep - -nodes/*.json - -# https://github.com/teracyhq/dev/issues/246 -vagrant_config_override.json -Vagrantfile-ext.rb diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ed867447..00000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "test/foodcritic/customink"] - path = test/foodcritic/customink - url = git://github.com/customink-webops/foodcritic-rules.git -[submodule "test/foodcritic/etsy"] - path = test/foodcritic/etsy - url = git://github.com/etsy/foodcritic-rules.git diff --git a/.travis.yml b/.travis.yml index 8ae5b26d..ff7ddda0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,45 +1,7 @@ -group: deprecated-2017Q2 # see: https://blog.travis-ci.com/2017-06-21-trusty-updates-2017-Q2-launch +sudo: required + services: -- docker -env: - matrix: - - BUILD_TYPE=dev CI_REGISTRY_IMAGE=$DEV_DOCKER_IMAGE IMAGE_TAG_PREFIX=dev_ - - BUILD_TYPE=docs CI_REGISTRY_IMAGE=$DOCS_DOCKER_IMAGE IMAGE_TAG_PREFIX="" - global: - - DOCKER_FILE=Dockerfile-dev - - CI_BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + - docker -before_install: -- git submodule update --init --recursive -# install the latest docker and docker-compose versions -- sudo apt-get remove docker docker-engine -- sudo curl -sSL https://get.docker.com/ | sh -- sudo rm /usr/local/bin/docker-compose -# the latest docker-compose version -- export DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4) -- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose -- chmod +x docker-compose -- sudo mv docker-compose /usr/local/bin -- docker version -- docker-compose version -# install -install: true -before_script: -- chmod ugo+x ./.travis/build.sh -- chmod ugo+x ./.travis/deploy.sh -- git config --global user.name "Teracy Bot" -- git config --global user.email "teracy.com@gmail.com" -- export REPO_URL="https://$GH_TOKEN@github.com/$GH_REPO.git" -- . ./.travis/setup.sh -- echo $DEPLOY_HTML_DIR -- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH | sed -e 's/[\/]/-/g' | sed -e 's/[\#]//g'; fi` -- export CONTAINER_IMAGE=$CI_REGISTRY_IMAGE:$IMAGE_TAG_PREFIX$TAG script: -- ./.travis/build.sh -after_success: -- ./.travis/deploy.sh -notifications: - slack: - rooms: - secure: 7rOCiLQZBvSATaFhw/6AgLRo/dGtoume8t0Bmaao5Tp7RKe99qLdN672OzY8aQzxWvP6pexcTvgcVaIIIEk808F7l6tTsz4HRp1TNwxeb0q6kiW0ZgTGS7KvRe17sSpcLUv26T1/flaLbmOaRoqNm/e77onenuuEgM5LTIkc11s= - on_success: change +- echo "OK" diff --git a/.travis/build.sh b/.travis/build.sh deleted file mode 100644 index 54e1e1bd..00000000 --- a/.travis/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -e - -. ./.travis/common.sh - -if [[ $BUILD_TYPE == "dev" ]]; then - docker_build - docker run --rm -v $(pwd):/opt/app $CONTAINER_IMAGE rake build - docker run --rm -v $(pwd):/opt/app $CONTAINER_IMAGE bundle exec rspec -elif [[ $BUILD_TYPE == "docs" ]]; then - cd docs - export DOCKER_FILE=Dockerfile.build - export BUILD_TAG="_build" - export CONTAINER_IMAGE=$CI_REGISTRY_IMAGE:$IMAGE_TAG_PREFIX$TAG$BUILD_TAG - docker_build - docker run -v $(pwd):/opt/app $CONTAINER_IMAGE make generate - cd .. -else - echo 'Wrong build type: $BUILD_TYPE'; - exit 1; -fi diff --git a/.travis/common.sh b/.travis/common.sh deleted file mode 100644 index a685242e..00000000 --- a/.travis/common.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -function docker_build { - docker build -f $DOCKER_FILE \ - --build-arg CI_BUILD_ID=$TRAVIS_BUILD_ID \ - --build-arg CI_BUILD_REF=$TRAVIS_COMMIT \ - --build-arg CI_BUILD_REF_NAME=$TRAVIS_BRANCH \ - --build-arg CI_BUILD_TIME=$CI_BUILD_TIME \ - --build-arg CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \ - --build-arg CI_PROJECT_NAME=$TRAVIS_REPO_SLUG \ - --pull -t $CONTAINER_IMAGE . -} diff --git a/.travis/deploy.sh b/.travis/deploy.sh deleted file mode 100644 index 61249f4c..00000000 --- a/.travis/deploy.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -. ./.travis/common.sh - -docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD - -function deploy_docs { - cd docs - make setup_gh_pages - make deploy - cd .. -} - -function deploy_docker_img { - docker push $CONTAINER_IMAGE -} - -if [[ $BUILD_TYPE == "dev" ]]; then - deploy_docker_img -fi - -if [[ $BUILD_TYPE == "docs" ]]; then - # build teracy-dev-docs distributed Docker image - cd docs - export DOCKER_FILE=Dockerfile - export CONTAINER_IMAGE=$CI_REGISTRY_IMAGE:$IMAGE_TAG_PREFIX$TAG - docker_build - deploy_docker_img - cd .. - # allow this to be failed - deploy_docs -fi diff --git a/.travis/setup.sh b/.travis/setup.sh deleted file mode 100755 index 6b564556..00000000 --- a/.travis/setup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -#setup travis-ci configuration basing one the being-built branch - -if [[ $TRAVIS_BRANCH == 'master' ]] ; then - export DEPLOY_HTML_DIR=docs -else - export DEPLOY_HTML_DIR=docs/$TRAVIS_BRANCH -fi diff --git a/AUTHORS_CHEF.md b/AUTHORS_CHEF.md deleted file mode 100644 index 3c3c368e..00000000 --- a/AUTHORS_CHEF.md +++ /dev/null @@ -1,4 +0,0 @@ -Authors -======= - -Hoat Le - hoatle@teracy.com diff --git a/Berksfile b/Berksfile deleted file mode 100644 index d9afa784..00000000 --- a/Berksfile +++ /dev/null @@ -1,7 +0,0 @@ -source "https://supermarket.chef.io" - -cookbook 'vim', '~> 2.0' -cookbook 'magic_shell', '~> 1.0' -cookbook 'docker', '~> 2.15' -cookbook 'docker_compose', '~> 0.1' -cookbook 'compat_resource', '~> 12.19.0' diff --git a/Berksfile.lock b/Berksfile.lock deleted file mode 100644 index f400e2e2..00000000 --- a/Berksfile.lock +++ /dev/null @@ -1,13 +0,0 @@ -DEPENDENCIES - compat_resource (~> 12.19.0) - docker (~> 2.15) - docker_compose (~> 0.1) - magic_shell (~> 1.0) - vim (~> 2.0) - -GRAPH - compat_resource (12.19.0) - docker (2.15.6) - docker_compose (0.1.1) - magic_shell (1.0.0) - vim (2.0.2) diff --git a/CHANGELOG_CHEF.md b/CHANGELOG_CHEF.md deleted file mode 100644 index 01d74b5c..00000000 --- a/CHANGELOG_CHEF.md +++ /dev/null @@ -1,11 +0,0 @@ -Change Log -========== - -[0.1.0][] ---------- - -Initial release with TDD workflow thanks to -http://neverstopbuilding.net/chef-best-practices-a-series/ - - -[0.1.0]: https://issues.teracy.org/secure/ReleaseNote.jspa?projectId=10412&version=10001 diff --git a/CONTRIBUTORS_CHEF.md b/CONTRIBUTORS_CHEF.md deleted file mode 100644 index c302d3fc..00000000 --- a/CONTRIBUTORS_CHEF.md +++ /dev/null @@ -1,2 +0,0 @@ -Contributors -============ diff --git a/Dockerfile-dev b/Dockerfile-dev deleted file mode 100644 index cf90b888..00000000 --- a/Dockerfile-dev +++ /dev/null @@ -1,29 +0,0 @@ -FROM ruby:2.4.0 - -LABEL authors="hoatle " - -RUN useradd --user-group --create-home --shell /bin/false app && mkdir -p /opt/app - -ENV HOME=/home/app TERM=xterm-256color APP=/opt/app - -# add more arguments from CI to the image so that `$ env` should reveal more info -ARG CI_BUILD_ID -ARG CI_BUILD_REF -ARG CI_REGISTRY_IMAGE -ARG CI_PROJECT_NAME -ARG CI_BUILD_REF_NAME -ARG CI_BUILD_TIME - -ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \ - CI_PROJECT_NAME=$CI_PROJECT_NAME CI_BUILD_REF_NAME=$CI_BUILD_REF_NAME CI_BUILD_TIME=$CI_BUILD_TIME - -ADD Gemfile Gemfile.lock $APP/ - -RUN chown -R app $APP && chgrp -R app $APP \ - && chown -R app /usr/local - -WORKDIR $APP - -USER app - -RUN bundle install diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 6f127b3e..00000000 --- a/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -source 'http://rubygems.org' - -ruby '2.4.0' - -gem 'rake', '~> 11.3' - -group:development do - gem 'chef', '~> 13.1' - gem 'chefspec', '~> 7.1' - gem 'foodcritic', '~> 8.1' - gem 'knife-spork', '~> 1.6' - gem 'berkshelf', '~> 5.2' - gem "rspec" -end diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index e0c8d3af..00000000 --- a/Gemfile.lock +++ /dev/null @@ -1,260 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - addressable (2.5.1) - public_suffix (~> 2.0, >= 2.0.2) - app_conf (0.4.2) - backports (3.8.0) - berkshelf (5.6.5) - 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.4) - octokit (~> 4.0) - retryable (~> 2.0) - ridley (~> 5.0) - solve (> 2.0, < 4.0) - thor (~> 0.19, < 0.19.2) - 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) - builder (3.2.3) - celluloid (0.16.0) - timers (~> 4.0.0) - celluloid-io (0.16.2) - celluloid (>= 0.16.0) - nio4r (>= 1.1.0) - chef (13.1.31) - addressable - bundler (>= 1.10) - chef-config (= 13.1.31) - chef-zero (>= 13.0) - diff-lcs (~> 1.2, >= 1.2.4) - erubis (~> 2.7) - ffi-yajl (~> 2.2) - highline (~> 1.6, >= 1.6.9) - iniparse (~> 1.4) - iso8601 (~> 0.9.1) - mixlib-archive (~> 0.4) - mixlib-authentication (~> 1.4) - mixlib-cli (~> 1.7) - mixlib-log (~> 1.3) - mixlib-shellout (~> 2.0) - net-sftp (~> 2.1, >= 2.1.2) - net-ssh (>= 2.9, < 5.0) - net-ssh-multi (~> 1.2, >= 1.2.1) - ohai (~> 13.0) - plist (~> 3.2) - proxifier (~> 1.0) - rspec-core (~> 3.5) - rspec-expectations (~> 3.5) - rspec-mocks (~> 3.5) - rspec_junit_formatter (~> 0.2.0) - serverspec (~> 2.7) - specinfra (~> 2.10) - syslog-logger (~> 1.6) - uuidtools (~> 2.1.5) - chef-config (13.1.31) - addressable - fuzzyurl - mixlib-config (~> 2.0) - mixlib-shellout (~> 2.0) - chef-zero (13.0.0) - ffi-yajl (~> 2.2) - hashie (>= 2.0, < 4.0) - mixlib-log (~> 1.3) - rack (~> 2.0) - uuidtools (~> 2.1) - chefspec (7.1.0) - chef (>= 12.14.89) - fauxhai (>= 4, < 6) - rspec (~> 3.0) - cleanroom (1.0.0) - cucumber-core (2.0.0) - backports (~> 3.6) - gherkin (~> 4.0) - diff-lcs (1.3) - diffy (3.2.0) - erubis (2.7.0) - faraday (0.12.1) - multipart-post (>= 1.2, < 3) - fauxhai (4.1.0) - net-ssh - ffi (1.9.18) - ffi-yajl (2.3.0) - libyajl2 (~> 1.2) - foodcritic (8.2.0) - cucumber-core (>= 1.3) - erubis - nokogiri (>= 1.5, < 2.0) - rake - rufus-lru (~> 1.0) - treetop (~> 1.4) - yajl-ruby (~> 1.1) - fuzzyurl (0.9.0) - gherkin (4.1.3) - git (1.3.0) - hashie (3.5.5) - highline (1.7.8) - hitimes (1.2.5) - httpclient (2.8.3) - iniparse (1.4.3) - ipaddress (0.8.3) - iso8601 (0.9.1) - json (2.1.0) - knife-spork (1.6.3) - app_conf (>= 0.4.0) - chef (>= 11.0.0) - diffy (>= 3.0.1) - git (>= 1.2.5) - libyajl2 (1.2.0) - mini_portile2 (2.1.0) - minitar (0.6.1) - mixlib-archive (0.4.1) - mixlib-log - mixlib-authentication (1.4.1) - mixlib-log - mixlib-cli (1.7.0) - mixlib-config (2.2.4) - mixlib-log (1.7.1) - mixlib-shellout (2.2.7) - molinillo (0.5.7) - multi_json (1.12.1) - multipart-post (2.0.0) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-ssh (4.1.0) - net-ssh-gateway (2.0.0) - net-ssh (>= 4.0.0) - net-ssh-multi (1.2.1) - net-ssh (>= 2.6.5) - net-ssh-gateway (>= 1.2.0) - net-telnet (0.1.1) - nio4r (2.1.0) - nokogiri (1.7.2) - mini_portile2 (~> 2.1.0) - octokit (4.7.0) - sawyer (~> 0.8.0, >= 0.5.3) - ohai (13.1.0) - chef-config (>= 12.5.0.alpha.1, < 14) - ffi (~> 1.9) - ffi-yajl (~> 2.2) - ipaddress - mixlib-cli - mixlib-config (~> 2.0) - mixlib-log (>= 1.7.1, < 2.0) - mixlib-shellout (~> 2.0) - plist (~> 3.1) - systemu (~> 2.6.4) - wmi-lite (~> 1.0) - plist (3.3.0) - polyglot (0.3.5) - proxifier (1.0.3) - public_suffix (2.0.5) - rack (2.0.3) - rake (11.3.0) - retryable (2.0.4) - ridley (5.1.1) - 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) - 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) - rspec (3.6.0) - rspec-core (~> 3.6.0) - rspec-expectations (~> 3.6.0) - rspec-mocks (~> 3.6.0) - rspec-core (3.6.0) - rspec-support (~> 3.6.0) - rspec-expectations (3.6.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-its (1.2.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.6.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-support (3.6.0) - rspec_junit_formatter (0.2.3) - builder (< 4) - rspec-core (>= 2, < 4, != 2.12.0) - rufus-lru (1.1.0) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) - semverse (2.0.0) - serverspec (2.39.1) - multi_json - rspec (~> 3.0) - rspec-its - specinfra (~> 2.68) - sfl (2.3) - solve (3.1.0) - molinillo (>= 0.5) - semverse (>= 1.1, < 3.0) - specinfra (2.68.0) - net-scp - net-ssh (>= 2.7, < 5.0) - net-telnet - sfl - syslog-logger (1.6.8) - systemu (2.6.5) - thor (0.19.1) - timers (4.0.4) - hitimes - treetop (1.6.8) - polyglot (~> 0.3) - uuidtools (2.1.5) - varia_model (0.6.0) - buff-extensions (~> 2.0) - hashie (>= 2.0.2, < 4.0.0) - wmi-lite (1.0.0) - yajl-ruby (1.3.0) - -PLATFORMS - ruby - -DEPENDENCIES - berkshelf (~> 5.2) - chef (~> 13.1) - chefspec (~> 7.1) - foodcritic (~> 8.1) - knife-spork (~> 1.6) - rake (~> 11.3) - rspec - -RUBY VERSION - ruby 2.4.0p0 - -BUNDLED WITH - 1.15.1 diff --git a/README.rst b/README.rst index 1c2818da..f2a2e60b 100644 --- a/README.rst +++ b/README.rst @@ -13,29 +13,27 @@ The only truly universal productive software development platform for all! ``teracy-dev`` is created to set up a universal development platform which has the same development workflow on Mac, Linux and Windows with good developer experience and productivity in mind. -We leverage Docker workflow for our software development and we use ``vagrant``, ``virtualbox``, and -``chef`` to install and configure any necessary packages. -By using this approach, we can work in a consistent development environment and workflow. -We do not have to install tons of development stuff on the host machine **manually** to get started. - -.. note:: We are using the https://github.com/acme101 project to show the best practices from ``teracy-dev`` applied for organizations. +`teracy-dev` is super minimal kernel with extension mechanism so that we can use/ develop many +different extensions by our needs. Features -------- - -- fully automated managed servers on your local machine (by leveraging ``vagrant`` + ``chef`` - provisioner). This saves you a lot of time and money to work on many virtual private servers (VPS) - on your local machine before deploying applications on the production servers. +- super minimal kernel with extension support to extend without any limitation - the universally same workflow on Windows, Linux and Mac -- higher performance and productivity gain than default vagrant settings -- support different configuration management tools (provisioners) -- default set up with easy personalized configuration settings without any limitation -- seamless upgrading to the next updated versions of teracy-dev -- best practices to develop and deploy applications -- a full-stack developer workstation -- many more features that you will discover yourselves when using this +- higher performance and productivity gain than the default vagrant settings by yaml configuration mechanism +- best practices to develop and deploy any types of stacks and architectures + + +Useful Extensions +----------------- + +- teracy-dev-core: https://github.com/teracyhq-incubator/teracy-dev-core +- teracy-dev-essential: https://github.com/teracyhq-incubator/teracy-dev-essential +- teracy-dev-k8s: https://github.com/teracyhq-incubator/teracy-dev-k8s +- teracy-dev-v05-compat: https://github.com/teracyhq-incubator/teracy-dev-v05-compat + Installation and Usage ---------------------- diff --git a/README_CHEF.md b/README_CHEF.md deleted file mode 100644 index a4b291bc..00000000 --- a/README_CHEF.md +++ /dev/null @@ -1,123 +0,0 @@ -chef -==== - -chef based common project that other chef-specific projects should extend. - - -Continuous Integration ----------------------- - - -Usage ------ - -** 1. Create a new cookbook ** - -``` -$ rake new_cookbook -``` - -For example: - -``` -$ rake new_cookbook[test] -``` -This will create a `test` cookbook into `main-cookbooks` path. - -``` -$ rake new_cookbook[test, main-cookbooks] -``` -This will create a `test` cookbook into `main-cookbooks` path. - -** 2. Build cookbooks ** - -``` -$ rake build -``` -This will check all cookbooks under `main-cookbooks` path with: `knife_test`, `foodcritic` and -`chefspec` - -For more tasks, refer to `Rakefile`. - - -Installation ------------- - -- Ruby 1.9.3 -- `$ git submodule update --init --recursive` -- `$ gem install bundle` -- `$ bundle install` - - -Configuration -------------- - -- To work as a chef workstation, configure environment on `environment.sh` and then -`$ . ./environment.sh`, after that `$ rake check` to make sure all required environment variables -are set. - - -Contributing ------------- - -- File issues at https://issues.teracy.org/browse/CHEF - -- Follow Teracy's workflow at http://dev.teracy.org/docs/develop/workflow.html - - -Discussions ------------ - -Join us: - -- https://groups.google.com/forum/#!forum/teracy - -- https://www.facebook.com/groups/teracy - -Get our news: - -- https://www.facebook.com/teracy.official - -- https://twitter.com/teracy_official - - -Author and contributors ------------------------ - -See more details at `AUTHORS.md` and `CONTRIBUTORS.md` files. - - -License -------- - -BSD License - -``` -Copyright (c) Teracy, Inc. and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -``` diff --git a/Rakefile b/Rakefile deleted file mode 100644 index ae90f8e8..00000000 --- a/Rakefile +++ /dev/null @@ -1,139 +0,0 @@ -require "bundler/setup" - -task :default => [:list] - -desc "List all the tasks." -task :list do - puts "Tasks: \n- #{(Rake::Task.tasks).join("\n- ")}" -end - -desc "Checks for required dependencies." -task :check do - environemnt_vars = [ - 'OPSCODE_USER', - 'OPSCODE_ORGNAME', - 'KNIFE_CLIENT_KEY_FOLDER', - 'KNIFE_VALIDATION_KEY_FOLDER', - 'KNIFE_CHEF_SERVER', - 'KNIFE_COOKBOOK_COPYRIGHT', - 'KNIFE_COOKBOOK_LICENSE', - 'KNIFE_COOKBOOK_EMAIL', - 'KNIFE_CACHE_PATH' - ] - errors = [] - environemnt_vars.each do |var| - if ENV[var].nil? - errors.push(" - \e\[31m#Variable: #{var} not set!\e\[0m\n") - else - puts " - \e\[32mVariable: #{var} set to \"#{ENV[var]}\"\e\[0m\n" - end - end - - # client_key "#{ENV['HOME']}/.chef/#{user}.pem" - # validation_client_name "#{ENV['ORGNAME']}-validator" - # validation_key "#{ENV['HOME']}/.chef/#{ENV['ORGNAME']}-validator.pem" - # chef_server_url "https://api.opscode.com/organizations/#{ENV['ORGNAME']}" - - - file_list = [ - "#{ENV['KNIFE_CLIENT_KEY_FOLDER']}/#{ENV['OPSCODE_USER']}.pem", - "#{ENV['KNIFE_VALIDATION_KEY_FOLDER']}/#{ENV['OPSCODE_ORGNAME']}-validator.pem", - ] - - file_list.each do |file| - if File.exist?(file) - puts " - \e\[32mFile: \"#{file}\" found.\e\[0m\n" - else - errors.push(" - \e\[31mRequired file: \"#{file}\" not found!\e\[0m\n") - end - end - - if system("command -v virtualbox >/dev/null 2>&1") - puts " - \e\[32mProgram: \"virtualbox\" found.\e\[0m\n" - else - errors.push(" - \e\[31mProgram: \"virtualbox\" not found!\e\[0m\n") - end - - if system("command -v vagrant >/dev/null 2>&1") - puts " - \e\[32mProgram: \"vagrant\" found.\e\[0m\n" - %x{vagrant --version}.match(/\d+\.\d+\.\d+/) { |m| - if Gem::Version.new(m.to_s) < Gem::Version.new('1.1.0') - errors.push(" -- \e\[31mVagrant version \"#{m.to_s}\" is too old!\e\[0m\n") - else - puts " - \e\[32mVagrant \"#{m.to_s}\" works!\e\[0m\n" - end - } - else - errors.push(" - \e\[31mProgram: \"vagrant\" not found!\e\[0m\n") - end - - unless errors.empty? - puts "The following errors occured:\n#{errors.join()}" - end -end - -desc "Builds the package." -task :build do - Rake::Task[:knife_test].execute - Rake::Task[:foodcritic].execute - Rake::Task[:chefspec].execute -end - - -desc "Creates a new cookbook." -task :new_cookbook, :name, :cookbook_path do |t, args| - if args.name - name = args.name - else - name = get_stdin("Enter a name for your new cookbook: ") - end - - if args.cookbook_path - cookbook_path = args.cookbook_path - else - cookbook_path = "main-cookbooks" - end - - sh "bundle exec knife cookbook create #{name} -o #{cookbook_path}" - sh "bundle exec knife cookbook create_specs #{name} -o #{cookbook_path}" - minitest_path = "#{cookbook_path}/#{name}/files/default/tests/minitest" - mkdir_p minitest_path - File.open("#{minitest_path}/default_test.rb", 'w') do |test| - test.puts "require 'minitest/spec'" - test.puts "" - test.puts "describle_recipe '#{name}::default' do" - test.puts "" - test.puts "end" - end -end - -desc "Runs chefspec on all the cookbooks." -task :chefspec do - sh "bundle exec rspec main-cookbooks" -end - -desc "Runs foodcritic against all the cookbooks." -task :foodcritic do - sh "bundle exec foodcritic -I test/foodcritic/* -f any main-cookbooks" -end - -desc "Runs knife cookbook test against all the cookbooks." -task :knife_test do - sh "bundle exec knife cookbook test -a -c test/knife.rb" -end - -desc "Installs Berkshelf cookbooks to vendor-cookbooks directory" -task :berks_install do - sh "bundle exec berks vendor vendor-cookbooks" -end - -desc "Uploads Berkshelf cookbooks to our chef server." -task :berks_upload do - sh "bundle exec berks upload -c config/berks-config.json" -end - - -def get_stdin(message) - print message - STDIN.gets.chomp -end diff --git a/Vagrantfile b/Vagrantfile index 9e0c22ea..27bd919d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,492 +1,22 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : -require 'json' -load File.dirname(__FILE__) + '/lib/utility.rb' -load File.dirname(__FILE__) + '/lib/provisioner.rb' +# some vagrant sub commands cause teracy-dev's malfunction and it's safe to not load tearcy-dev +unloadable_sub_commands = ['box', 'plugin'] +if ARGV[0] && !unloadable_sub_commands.include?(ARGV[0]) + # add ./lib to ruby load path + lib_dir = File.expand_path('./lib', __dir__) + $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) -# Load default setting -file = File.read(File.dirname(__FILE__) + '/vagrant_config.json') -extension_list = [File.dirname(__FILE__) + '/Vagrantfile-ext.rb'] -data_hash = JSON.parse(file) -override_hash = nil - -# Check and override if exist any match JSON object from vagrant_config_override.json - -begin - if File.exist?(File.dirname(__FILE__) + '/vagrant_config_override.json') - parsing_file = File.dirname(__FILE__) + '/vagrant_config_override.json' - override_file = File.read(parsing_file) - override_hash = JSON.parse(override_file) - - data_hash = overrides(data_hash, override_hash) - end - - if File.exist?(File.dirname(__FILE__) + '/workspace/dev-setup/vagrant_config_default.json') - parsing_file = File.dirname(__FILE__) + '/workspace/dev-setup/vagrant_config_default.json' - - extension_list.push(File.dirname(__FILE__) + '/workspace/dev-setup/Vagrantfile-ext.rb') - - org_config_file = File.read(parsing_file) - org_config_hash = JSON.parse(org_config_file) - - override_config_file_path = parsing_file.gsub(/default\.json$/, "override.json") - if File.exist?(override_config_file_path) - override_config_file = File.read(override_config_file_path) - parsing_file = override_config_file_path - override_config_hash = JSON.parse(override_config_file) - org_config_hash = overrides(org_config_hash, override_config_hash) - end - - if !org_config_hash.nil? - overrides(data_hash, org_config_hash) - end - end - - if data_hash['vagrant'] && data_hash['vagrant']['config_paths'] - data_hash['vagrant']['config_paths'].map do |default_config_file_path| - override_config_file_path = default_config_file_path.gsub(/default\.json$/, "override.json") - - if File.exist?(File.dirname(__FILE__) + '/' + default_config_file_path) - default_config_file = File.read(File.dirname(__FILE__) + '/' + default_config_file_path) - extension_list.push(File.dirname(File.dirname(__FILE__) + '/' + default_config_file_path) + '/Vagrantfile-ext.rb') - parsing_file = default_config_file_path - project_config_hash = JSON.parse(default_config_file) - else - puts "[teracy-dev][INFO]: #{default_config_file_path} not found, make sure this is intended." - end - - if File.exist?(File.dirname(__FILE__) + '/' + override_config_file_path) - override_config_file = File.read(File.dirname(__FILE__) + '/' + override_config_file_path) - parsing_file = override_config_file_path - override_config_hash = JSON.parse(override_config_file) - project_config_hash = overrides(project_config_hash, override_config_hash) - end - if !project_config_hash.nil? - overrides(data_hash, project_config_hash) - end - end - end -rescue Exception => msg - puts red(msg) - puts red('from ' + parsing_file) - ans = prompt yellow("some errors have occured and '" + parsing_file + "' file will not be used, do you want to continue? [y/N]: ") - if ans.downcase != 'y' - exit! - end -end - -Vagrant.configure("2") do |config| - - vm_hash = data_hash["vm"] - - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. - - # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = vm_hash["box"] - - # The url from where the 'config.vm.box' box will be fetched if it - # doesn't already exist on the user's system. - config.vm.box_url = vm_hash['box_url'] - - # Other configs: https://docs.vagrantup.com/v2/vagrantfile/machine_settings.html - - if !vm_hash["box_version"].nil? and !vm_hash["box_version"].strip().empty? - config.vm.box_version = vm_hash['box_version'] - end - - if !vm_hash["boot_timeout"].nil? - config.vm.boot_timeout = vm_hash['boot_timeout'] - end - - if !vm_hash["box_check_update"].nil? - config.vm.box_check_update = vm_hash['box_check_update'] - end - - if !vm_hash["box_download_checksum"].nil? and !vm_hash["box_download_checksum"].strip().empty? - config.vm.box_download_checksum = vm_hash['box_download_checksum'] - - # box_download_checksum_type must be specified if box_download_checksum is specified - config.vm.box_download_checksum_type = vm_hash['box_download_checksum_type'] - end - - if !vm_hash["box_download_client_cert"].nil? and !vm_hash["box_download_client_cert"].strip().empty? - config.vm.box_download_client_cert = vm_hash['box_download_client_cert'] - end - - if !vm_hash["box_download_ca_cert"].nil? and !vm_hash["box_download_ca_cert"].strip().empty? - config.vm.box_download_ca_cert = vm_hash['box_download_ca_cert'] - end - - if !vm_hash["box_download_ca_path"].nil? and !vm_hash["box_download_ca_path"].strip().empty? - config.vm.box_download_ca_path = vm_hash['box_download_ca_path'] - end - - if !vm_hash["box_download_insecure"].nil? - config.vm.box_download_insecure = vm_hash['box_download_insecure'] - end - - if !vm_hash["communicator"].nil? and !vm_hash["communicator"].strip().empty? - config.vm.communicator = vm_hash['communicator'] - end - - if !vm_hash["graceful_halt_timeout"].nil? - config.vm.graceful_halt_timeout = vm_hash['graceful_halt_timeout'] - end - - if !vm_hash["guest"].nil? and !vm_hash["guest"].strip().empty? - config.vm.guest = vm_hash['guest'] - end - - if !vm_hash["hostname"].nil? and !vm_hash["hostname"].strip().empty? - config.vm.hostname = vm_hash['hostname'] - end - - if !vm_hash["post_up_message"].nil? and !vm_hash["post_up_message"].strip().empty? - config.vm.post_up_message = vm_hash['post_up_message'] - end - - if !vm_hash["usable_port_range"].nil? and !vm_hash["usable_port_range"].strip().empty? - ranges = vm_hash['usable_port_range'].split('..').map{|d| Integer(d)} - config.vm.usable_port_range = ranges[0]..ranges[1] - end - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - vm_networks = vm_hash['networks'] - vm_networks.each do |vm_network| - if vm_network['mode'] == 'forwarded_port' - vm_network['forwarded_ports'].each do |item| - config.vm.network :forwarded_port, guest: item['guest'], host: item['host'] - end - else - options = {} - case vm_network['mode'] - when 'private_network' - options[:ip] = vm_network['ip'] unless vm_network['ip'].nil? or vm_network['ip'].strip().empty? - if options[:ip].nil? or options[:ip].empty? - # make `type: 'dhcp'` default when `ip` is not defined (nil or empty) - options[:type] = 'dhcp' - else - options[:auto_config] = !(vm_network['auto_config'] == false) - end - when 'public_network' - options[:ip] = vm_network['ip'] unless vm_network['ip'].nil? or vm_network['ip'].strip().empty? - - bridge_interface = "" - bridge_interface = vm_network['bridge'] unless vm_network['bridge'].nil? or vm_network['bridge'].empty? - bridge_interface = get_default_nic() if bridge_interface.empty? and vm_network['auto_bridge_default_network'] - options[:bridge] = bridge_interface unless bridge_interface.empty? - - if vm_network['reuse_mac_address'] - if File.exist?(File.dirname(__FILE__) + '/.vagrant/.public_mac_address') - options[:mac] = File.read(File.dirname(__FILE__) + '/.vagrant/.public_mac_address').gsub(/[\s:\n]/,'') - else - FileUtils::touch File.dirname(__FILE__) + '/.vagrant/.public_mac_address' - end - else - if File.exist?(File.dirname(__FILE__) + '/.vagrant/.public_mac_address') - FileUtils.rm File.dirname(__FILE__) + '/.vagrant/.public_mac_address' - end - end - end - - config.vm.network vm_network['mode'], options - - end - end - - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network :private_network, ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network :public_network - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - vm_hash['synced_folders'].each do |item| - options = {} - host_os = Vagrant::Util::Platform.platform - host_os_type = '' - - case host_os - when /^(mswin|mingw).*/ - host_os_type = 'windows' - when /^(linux|cygwin).*/ - host_os_type = 'linux' - when /^(mac|darwin).*/ - host_os_type = 'mac' - end - - # options from http://docs.vagrantup.com/v2/synced-folders/basic_usage.html - options[:create] = item['create'] unless item['create'].nil? - options[:disabled] = item['disabled'] unless item['disabled'].nil? - options[:owner] = item['owner'] unless item['owner'].nil? - options[:group] = item['group'] unless item['group'].nil? - options[:mount_options] = item['mount_options'] unless item['mount_options'].nil? - options[:type] = item['type'] unless item['type'].nil? or item['type'] == 'virtual_box' - - case item['type'] - when 'nfs' - options[:nfs_export] = item['nfs_export'] if !!item['nfs_export'] == item['nfs_export'] - options[:nfs_udp] = item['nfs_udp'] if !!item['nfs_udp'] == item['nfs_udp'] - options[:nfs_version] = item['nfs_version'] unless item['nfs_version'].nil? - when 'rsync' - options[:rsync__args] = item['rsync__args'] unless item['rsync__args'].nil? or item['rsync__args'].empty? - options[:rsync__auto] = item['rsync__auto'] if !!item['rsync__auto'] == item['rsync__auto'] - options[:rsync__chown] = item['rsync__chown'] if !!item['rsync__chown'] == item['rsync__chown'] - options[:rsync__exclude] = item['rsync__exclude'] unless item['rsync__exclude'].nil? or item['rsync__exclude'].empty? - when 'smb' - options[:smb_host] = item['smb_host'] unless item['smb_host'].nil? or item['smb_host'].empty? - options[:smb_password] = item['smb_password'] unless item['smb_password'].nil? or item['smb_password'].empty? - options[:smb_username] = item['smb_username'] unless item['smb_password'].nil? or item['smb_password'].empty? - end - - if item['supports'].nil? or item['supports'].include?(host_os_type) - config.vm.synced_folder item['host'], item['guest'], options - end - end - - # plugins config - plugins_hash = data_hash['plugins'] - - plugins_hash.each do |plugin| - plugin_name = plugin['name'] - if plugin['required'] == true - # thanks to http://matthewcooper.net/2015/01/15/automatically-installing-vagrant-plugin-dependencies/ - exec "vagrant plugin install #{plugin_name} && vagrant #{ARGV.join(" ")}" unless Vagrant.has_plugin?(plugin_name) || ARGV[0] == 'plugin' - - unless Vagrant.has_plugin?(plugin_name) - puts red("required: '$ vagrant plugin install #{plugin_name}'") - exit! - end - end - - # this is current fixed config, not dynamic plugins config - # FIXME(hoatle): #186 should fix this - if Vagrant.has_plugin?(plugin_name) and plugin['enabled'] == true and plugin.key?('config_key') - config_key = plugin['config_key'] - options = plugin['options'] - if 'gatling' == config_key - - unless options['latency'].nil? - config.gatling.latency = options['latency'] - end - - unless options['time_format'].nil? or options['time_format'].empty? - config.gatling.time_format = options['time_format'] - end - - unless options['rsync_on_startup'].nil? - config.gatling.rsync_on_startup = options['rsync_on_startup'] - end - - elsif 'hostmanager' == config_key - if Vagrant.has_plugin?('vagrant-hostsupdater') - puts red('recommended: $ vagrant plugin uninstall vagrant-hostsupdater') - end - - unless options['enabled'].nil? - config.hostmanager.enabled = options['enabled'] - end - - unless options['manage_host'].nil? - config.hostmanager.manage_host = options['manage_host'] - end - - unless options['manage_guest'].nil? - config.hostmanager.manage_guest = options['manage_guest'] - end - - unless options['ignore_private_ip'].nil? - config.hostmanager.ignore_private_ip = options['ignore_private_ip'] - end - - unless options['include_offline'].nil? - config.hostmanager.include_offline = options['include_offline'] - end - - unless options['aliases'].nil? - config.hostmanager.aliases = options['aliases'] - end - - # workaround for :public_network - # maybe this will not work with :private_network - config.hostmanager.ip_resolver = proc do |vm, resolving_vm| - read_ip_address(vm) - end - end - end - - # if plugin.key?('config_key') - # config_key = plugin['config_key'] - # if Vagrant.has_plugin?(plugin_name) and !config_key.nil? and !config_key.empty? - # puts red(config[config_key.to_sym]) - # # TODO(hoatle): remove config_key and required keys? - # #config.instance_variable_set("@#{config_key}", plugin) - # # new_config = Vagrant::Config::V2::Root.new({ - # # config_key => plugin - # # }) - # # config.merge(config, new_config) - # end - # end - end - - # ssh configuration - config.ssh.forward_agent = vm_hash['forward_agent'] - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # View the documentation for the provider you're using for more - # information on available options. - config.vm.provider :virtualbox do |vb| - - vb_hash = data_hash['vb'] - - # Don't boot with headless mode - if vb_hash['gui'] == true - vb.gui = true - end - - # general settings for modifyvm: https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm - # TODO(hoatle): add support for key<1-N> type - # TODO(hoatle): add support for other settings - - # FIXME(hoatle): there were 3 loops here, why? - # puts vb_hash - - general_settings_keys = ['name', 'groups', 'description', 'ostype', 'memory', 'vram', 'acpi', - 'ioapic', 'hardwareuuid', 'cpus', 'rtcuseutc', 'cpuhotplug', 'plugcpu', 'unplugcpu', - 'cpuexecutioncap', 'pae', 'longmode', 'synthcpu', 'hpet', 'hwvirtex', 'triplefaultreset', - 'nestedpaging', 'largepages', 'vtxvpid', 'vtxux', 'accelerate3d', 'bioslogofadein', - 'bioslogodisplaytime', 'bioslogoimagepath', 'biosbootmenu', 'snapshotfolder', 'firmware', - 'guestmemoryballoon', 'defaultfrontend' - ] - - vb_hash.each do |key, val| - if general_settings_keys.include?(key) and !vb_hash[key].nil? - val = val.to_s.strip() - if !val.empty? - vb.customize ["modifyvm", :id, "--" + key, val] - end - end - end + require 'teracy-dev/plugin' + def init_system + system_settings = YAML.load_file(File.join(File.dirname(__FILE__), 'system.yaml')) + # versions requirements + Vagrant.require_version system_settings['vagrant']['require_version'] + TeracyDev::Plugin.sync(system_settings['vagrant']['plugins']) end - # provisoners settings - provisioners = data_hash['provisioners'] - chef_hash = data_hash['chef'] - - if !chef_hash.nil? - puts red("You're using deprecated setting for chef, will be removed by v0.5.0-b2, please update it now, see more: https://github.com/teracyhq/dev/issues/166") - - # chef_hash should override the default provisioner chef_solo - provisioners.each do |provisioner| - if provisioner['type'] == 'chef_solo' - chef_hash = overrides(provisioner, chef_hash) - end - end - - if chef_hash['enabled'].nil? or chef_hash['enabled'] == true - config.vm.provision "chef_solo" do |chef| - chef.log_level = chef_hash['log_level'] - chef.cookbooks_path = chef_hash['cookbooks_path'] - chef.data_bags_path = chef_hash['data_bags_path'] - chef.environments_path = chef_hash['environments_path'] - chef.environment = chef_hash['environment'] - chef.nodes_path = chef_hash['nodes_path'] - chef.recipe_url = chef_hash['recipe_url'] - chef.roles_path = chef_hash['roles_path'] - chef.synced_folder_type = chef_hash['synced_folder_type'] + init_system - unless chef_hash['roles'].nil? - chef_hash['roles'].each do |role| - chef.add_role role - end - end + require 'teracy-dev' - unless chef_hash['recipes'].nil? - chef_hash['recipes'].each do |recipe| - chef.add_recipe recipe - end - end - - chef.json = chef_hash['json'] - end - # empty provisioners to work as backward compatible - provisioners = [] - end - end - - # fix hosts file on the guest machine - # see: https://github.com/devopsgroup-io/vagrant-hostmanager/issues/203 - fix_hosts_command = "sed -i \"s/\\(127.0.0.1\\)\\(.*\\)#{config.vm.hostname}\\(.*\\)/\\1\\3/\" /etc/hosts" - - provisioners.unshift({ - "type" => "shell", - "name" => "fix-hosts", - "inline" => fix_hosts_command - }) - - # save the MAC address if the file /vagrant/.vagrant/.public_mac_address exists - provisioners << { - "type" => "shell", - "name" => "save_mac_address", - "path" => "provisioners/shells/save_mac_address.sh", - "run" => "always" - } - - # append ip shell as the last item to always display the ip address - provisioners << { - "type" => "shell", - "name" => "ip", - "path" => "provisioners/shells/ip.sh", - "run" => "always" - } - - provisioners.each do |provisioner| - type = provisioner['type'] - run = 'once' - preserve_order = false - if !provisioner['run'].nil? - run = provisioner['run'] # one of: once, always, or never - end - if provisioner['preserve_order'] == true - preserve_order = true - end - - if provisioner['name'].nil? - config.vm.provision "#{type}", run: run, preserve_order: preserve_order do |provision| - provision_settings(type, provision, provisioner) - end - else - config.vm.provision provisioner['name'], type: type, run: run, preserve_order: preserve_order do |provision| - provision_settings(type, provision, provisioner) - end - end - end -end - - -begin - extension_list.each do |path| - if File.file?(path) - load path - end - end -rescue Exception => msg - puts red(msg) end diff --git a/certificates/README.md b/certificates/README.md deleted file mode 100644 index c6856e69..00000000 --- a/certificates/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Creating SSL certificates is a common task done in web application infrastructures, so a rake task is provided to generate certificates. These certificates are stored here by the ssl_cert task. - -Configure the values used in the SSL certificate by modifying `config/rake.rb`. - -To generate a certificate set for a new monitoring server, for example: - - rake ssl_cert FQDN=monitoring.example.com - -Once the certificates are generated, copy them into the cookbook(s) where you want to use them. - - cp certificates/monitoring.example.com.* cookbooks/COOKBOOK/files/default - -In the recipe for that cookbook, create a `cookbook_file` resource to configure a resource that puts them in place on the destination server. - - cookbook_file '/etc/apache2/ssl/monitoring.example.com.pem' - owner 'root' - group 'root' - mode 0600 - end diff --git a/chefignore b/chefignore deleted file mode 100644 index ba30af6c..00000000 --- a/chefignore +++ /dev/null @@ -1,11 +0,0 @@ -# Put files/directories that should be ignored in this file. -# Lines that start with '# ' are comments. - -# emacs -*~ - -# vim -*.sw[a-z] - -# subversion -*/.svn/* diff --git a/config.yaml b/config.yaml new file mode 100644 index 00000000..4a68dbc1 --- /dev/null +++ b/config.yaml @@ -0,0 +1,27 @@ + +# teracy-dev related settings +teracy-dev: + require_version: ">= 0.6.0-a1-SNAPSHOT" + extensions: + - _id: "0" + path: + lookup: extensions # we can configure where to lookup for the extension, "extensions" by default if no configured + extension: teracy-dev-core # extension_path, we'll lookup the extension by its lookup_path + extension_path + location: # auto download the extension into the lookup_path + git: https://github.com/hoatle/teracy-dev-core.git + # ref: + # tag: + branch: develop + require_version: ">= 0.1.0-SNAPSHOT" + enabled: true # when true, extension will be auto-downloaded if not available yet and will load this extension to be used + # extension must have manifest.yaml file to describe its name, version and optional description + # optional: config_default.yaml, teracy-dev-ext.rb will be auto loaded if available + +# vagrant related settings +vagrant: {} + +# default settings for all nodes +default: {} + +# specific nodes, each node will override the default +nodes: [] diff --git a/config/berks-config.json b/config/berks-config.json deleted file mode 100644 index 6f9399cc..00000000 --- a/config/berks-config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "ssl": { - "verify": false - } -} \ No newline at end of file diff --git a/config/rake.rb b/config/rake.rb deleted file mode 100644 index 40bb837d..00000000 --- a/config/rake.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Configure the Rakefile's tasks. - -### -# Company and SSL Details -# Used with the ssl_cert task. -### - -# The company name - used for SSL certificates, and in srvious other places -COMPANY_NAME = "Teracy, Inc." - -# The Country Name to use for SSL Certificates -SSL_COUNTRY_NAME = "VN" - -# The State Name to use for SSL Certificates -SSL_STATE_NAME = "Several" - -# The Locality Name for SSL - typically, the city -SSL_LOCALITY_NAME = "Locality" - -# What department? -SSL_ORGANIZATIONAL_UNIT_NAME = "Operations" - -# The SSL contact email address -SSL_EMAIL_ADDRESS = "devops@teracy.com" - -# License for new Cookbooks -# Can be :apachev2 or :none -NEW_COOKBOOK_LICENSE = :none - -### -# Useful Extras (which you probably don't need to change) -### - -# The top of the repository checkout -TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), "..")) - -# Where to store certificates generated with ssl_cert -CADIR = File.expand_path(File.join(TOPDIR, "certificates")) diff --git a/config/spork-config.yml b/config/spork-config.yml deleted file mode 100644 index b058c3ef..00000000 --- a/config/spork-config.yml +++ /dev/null @@ -1,6 +0,0 @@ -default_environments: - - dev - - stag - - prod -version_changed_threshold: 2 -environment_path: "environments" \ No newline at end of file diff --git a/data_bags/README.md b/data_bags/README.md deleted file mode 100644 index 0c15a391..00000000 --- a/data_bags/README.md +++ /dev/null @@ -1,63 +0,0 @@ -Data Bags ---------- - -This directory contains directories of the various data bags you create for your infrastructure. Each subdirectory corresponds to a data bag on the Chef Server, and contains JSON files of the items that go in the bag. - -First, create a directory for the data bag. - - mkdir data_bags/BAG - -Then create the JSON files for items that will go into that bag. - - $EDITOR data_bags/BAG/ITEM.json - -The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM". For example, - - { - "id": "foo" - } - -Next, create the data bag on the Chef Server. - - knife data bag create BAG - -Then upload the items in the data bag's directory to the Chef Server. - - knife data bag from file BAG ITEM.json - - -Encrypted Data Bags -------------------- - -Added in Chef 0.10, encrypted data bags allow you to encrypt the contents of your data bags. The content of attributes will no longer be searchable. To use encrypted data bags, first you must have or create a secret key. - - openssl rand -base64 512 > secret_key - -You may use this secret_key to add items to a data bag during a create. - - knife data bag create --secret-file secret_key passwords mysql - -You may also use it when adding ITEMs from files, - - knife data bag create passwords - knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key - -The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM" and the contents will be encrypted when uploaded. For example, - - { - "id": "mysql", - "password": "abc123" - } - -Without the secret_key, the contents are encrypted. - - knife data bag show passwords mysql - id: mysql - password: 2I0XUUve1TXEojEyeGsjhw== - -Use the secret_key to view the contents. - - knife data bag show passwords mysql --secret-file secret_key - id: mysql - password: abc123 - diff --git a/dev-setup/.gitignore b/dev-setup/.gitignore deleted file mode 100644 index c441ecac..00000000 --- a/dev-setup/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.DS_Store -.delivery/* -!.delivery/project.toml -.kitchen -vagrant_config_override.json diff --git a/dev-setup/README.md b/dev-setup/README.md deleted file mode 100644 index 3358477a..00000000 --- a/dev-setup/README.md +++ /dev/null @@ -1,221 +0,0 @@ -# Teracy-dev-setup - -Please follow this getting started guide to set up the development environment. - -Please take a cup of coffee with you, you mostly don't have to do anything but wait for the result, enjoy! - - -## Getting Started - -- Please follow the document at https://github.com/teracyhq/dev-setup/blob/develop/README.md to set up teracy-dev and dev-setup. - - -## Setting up the teracy-dev app - -Stop the watching files by using `Ctrl + c`. - -- We use `teracy-dev` to develop `teracy-dev`. Because of that, you need to fork this repo into your github account, and rename it to `dev`. - -- Clone the forked repo into the `~/teracy-dev/workspace` directory. - - ```bash - $ cd ~/teracy-dev/workspace/ - $ git clone dev - $ cd dev - $ git remote add upstream git@github.com:teracyhq/dev.git - ``` - -- Add the configuration path below to the `teracyhq/dev-setup/vagrant_config_default.json`, if it does not exist yet. It should look like similar to this: - - ```bash - "config_paths": [ // add paths of json config files to be loaded - // the path must be relative to the Vagrantfile - "workspace/dev/dev-setup/vagrant_config_default.json" - ] - ``` - -- Note that you should always sync the `dev-setup` repository along with `teracy-dev`. After changed, `$ vagrant reload --provision` should get the new configuration updated into the VM. Or `$ vagrant destroy` and `$ vagrant up` should set up the new VM from scratch for you. - - -- Reload the Vagrant box to make sure it's updated: - - ```bash - $ cd ~/teracy-dev - $ vagrant reload --provision - ``` - -- After finishing running (take a long time to set everything up for the first time), you should - see the following similar output: - - ```bash - ==> default: Chef Client finished, 10/41 resources updated in 55 seconds - ==> default: Running provisioner: ip (shell)... - default: Running: /var/folders/qt/y8zzc9wx3q55lw0b5dlh1j0m0000gn/T/vagrant-shell20170923-2377- 1miulou.sh - ==> default: ip address: 192.168.0.696 - ==> default: vagrant-gatling-rsync is starting the sync engine because you have at least one rsync folder. To disable this behavior, set `config.gatling.rsync_on_startup = false` in your Vagrantfile. - ==> default: Doing an initial rsync... - ==> default: Rsyncing folder: /Users/god_of_destruction/teracy-dev/workspace/ => /home/vagrant/workspace - ==> default: - Exclude: [".vagrant/", ".git", ".idea/", "node_modules/", "bower_components/", ".npm/", ".#*", "docs/_build"] - ==> default: Watching: /Users/god_of_destruction/teracy-dev/workspace - ``` - - -## How to work with docs - -- Make sure the ``/etc/hosts`` file get updated automatically with the following commands: - - ```bash - $ cd ~/teracy-dev - $ vagrant hostmanager - ``` - -- `$ ping dev.dev-docs.teracy.dev` to make sure it pings to the right IP address of the VM: - http://dev.teracy.org/docs/basic_usage.html#ip-address. - -- `$ cat /etc/hosts` file from the host machine to make sure there are no duplicated entries for - `teracy-dev` or the VM IP address. - -- SSH into the VM to make sure the docs app is ready by checking the docker logs output: - - ```bash - $ vagrant ssh - $ ws - $ cd dev/docs - $ docker-compose logs -f - ``` - -- Or you can use this shorthand command: - - ```bash - $ vagrant ssh -c "cd workspace/dev/docs && docker-compose logs -f" - ``` - -- Wait for the logs running until you see the following similar output: - - ```bash - app-dev_1 | Successfully built tornado port-for pathtools PyYAML watchdog MarkupSafe - app-dev_1 | Installing collected packages: sphinxcontrib-websupport, pytz, babel, imagesize, typing, Pygments, idna, urllib3, certifi, chardet, requests, six, docutils, alabaster, MarkupSafe, Jinja2, snowballstemmer, Sphinx, port-for, singledispatch, backports-abc, tornado, pathtools, livereload, PyYAML, argh, watchdog, sphinx-autobuild - app-dev_1 | Running setup.py install for livereload: started - app-dev_1 | Running setup.py install for livereload: finished with status 'done' - app-dev_1 | Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 PyYAML-3.12 Pygments-2.2.0 Sphinx-1.6.3 alabaster-0.7.10 argh-0.26.2 babel-2.5.1 backports-abc-0.5 certifi-2017.7.27.1 chardet-3.0.4 docutils-0.14 idna-2.6 imagesize-0.7.1 livereload-2.5.1 pathtools-0.1.2 port-for-0.3.1 pytz-2017.2 requests-2.18.4 singledispatch-3.4.0.3 six-1.11.0 snowballstemmer-1.2.1 sphinx-autobuild-0.7.1 sphinxcontrib-websupport-1.0.1 tornado-4.5.2 typing-3.6.2 urllib3-1.22 watchdog-0.8.3 - app-dev_1 | sphinx-autobuild -b html -d _build/doctrees . _build/html -H 0.0.0.0 - ``` - - -Then open: - -- http://dev.dev-docs.teracy.dev or https://dev.dev-docs.teracy.dev to check out - the docs within your host machine. - -- http://dev.dev-docs..xip.io to check out the docs within your LAN network. - -- http://ngrok-dev.dev-docs.teracy.dev to check out the docs on the Internet. - - -### Local dev mode docs - -```bash -$ vagrant ssh -$ ws -$ cd dev/docs -$ docker-compose up -d && docker-compose logs -f -``` - -Open http://dev.dev-docs.teracy.dev and edit docs files, it should auto reload when new -changes are detected. - - -### Local prod mode docs - -```bash -$ vagrant ssh -$ ws -$ cd dev/docs -$ docker-compose -f docker-compose.prod.yml build -$ docker-compose -f docker-compose.prod.yml up -``` - - -Then open: - -- http://dev-docs.teracy.dev or https://dev-docs.teracy.dev to check out - the docs within your host machine. - -- http://dev-docs..xip.io to check out the docs within your LAN network. - -- http://ngrok-prod.dev-docs.teracy.dev to check out the docs on the Internet. - - -### Local review mode docs - -To review work and PRs submitted by others, for example, with -`hoatle/teracy-dev-docs:improvements-176-teracy-dev-docs-guide` Docker image, run the commands below: - - -```bash -$ vagrant ssh -$ ws -$ cd flask-classful/docs -$ APP_REVIEW_IMAGE=hoatle/teracy-dev-docs:improvements-176-teracy-dev-docs-guide docker-compose -f docker-compose.review.yml up -``` - - -Then open: - -- http://review.dev-docs.teracy.dev or https://review.dev-docs.teracy.dev to - check out the docs within your host machine. - -- http://review.dev-docs..xip.io to check out the docs within your LAN network. - -- http://ngrok-review.dev-docs.teracy.dev to check out the docs on the Internet. - - -## travis-ci configuration - -You just need to configure travis-ci only one time. After each travis-ci build, new Docker images -are pushed, we can review your work (PR) by running the Docker images instead of fetching git code -and build it on local ourselves. - -Here are things you need to do: - -- Register your account at https://hub.docker.com. -- Register your account at travis-ci.org. -- Enable the teracy-dev repository on travis-ci (for example: https://travis-ci.org/hoatle/teracy-dev). -- Fill in the following environment variables settings for the teracy-dev travis-ci project by - following: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings. - In the *Name* and *Value* fields, please add the info below correlatively: - - + Fill in "DOCKER_USERNAME" into the *Name* field, and your Docker username into the *Value* field. - + Fill in "DOCKER_PASSWORD" into the *Name* field, and your Docker password into the *Value* field. - + Fill in "DEV_DOCKER_IMAGE" into the *Name* field, and your repo name for https://hub.docker.com - into the *Value*, for example, "hoatle/teracy-dev" (so that to create https://hub.docker.com/r/hoatle/teracy-dev/). - + Fill in "DOCS_DOCKER_IMAGE" into the *Name* field, and your repo name for https://hub.docker.com - into the *Value*, for example, "hoatle/teracy-dev-docs" (so that to create https://hub.docker.com/r/hoatle/teracy-dev-docs/). - + Fill in "GH_REPO" into the *Name* field, and your github username, for example, fill with /dev> to git push on your repo. - + Fill in "GH_TOKEN" into the *Name* field, and your github token, for example, fill with to git push on your repo. - -And you're done! - -## How to start working - -- Learn how to work with teracy-dev: - - + http://dev.teracy.org/docs/basic_usage.html - + http://dev.teracy.org/docs/advanced_usage.html - -- Learn how to work with docker and docker-compose: - - + https://www.docker.com/ - + https://github.com/veggiemonk/awesome-docker - -- You can use any text editor or IDE to edit the project files at `~/teracy-dev/workspace/flask-classful`. - -## Tips - - -- How to access into the container ssh session: - - ```bash - $ docker exec -it /bin/bash - root@a76ec196be06:/opt/app# - ``` diff --git a/dev-setup/chef/README.md b/dev-setup/chef/README.md deleted file mode 100644 index e7b0831e..00000000 --- a/dev-setup/chef/README.md +++ /dev/null @@ -1,99 +0,0 @@ -# teracy-dev-setup cookbook - -Chef cookbooks are used to manage teracy-dev VM for the project. - -You can use other software provisioning tools other than Chef, see: https://www.vagrantup.com/docs/provisioning/ -`teracy-dev` supports all the configuration of vagrant supported provisioners into the -`vagrant_config_override.json` file, you can combine them for the dev-setup. - - -## dev-setup/chef/main-cookbooks/teracy-dev-setup cookbook - -- This Chef project is used to manage the VM for the `teracy-dev` project. - -- The `teracy-dev-setup` Chef project was initially generated by the following commands: - -``` -$ vagrant ssh -$ ws -$ cd dev/dev-setup/chef/ -$ docker run --rm -it -v $(pwd):/opt/app -w /opt/app chef/chefdk bash -# mkdir main-cookbooks -# cd main-cookbooks -# chef generate cookbook teracy-dev-setup -``` - -You should see the similar following output: - -``` -Generating cookbook teracy-dev-setup -- Ensuring correct cookbook file content -- Ensuring delivery configuration -- Ensuring correct delivery build cookbook content - -Your cookbook is ready. Type `cd teracy-dev-setup` to enter it. - -There are several commands you can run to get started locally developing and testing your cookbook. -Type `delivery local --help` to see a full list. - -Why not start by writing a test? Tests for the default recipe are stored at: - -test/smoke/default/default_test.rb - -If you'd prefer to dive right in, the default recipe can be found at: - -recipes/default.rb - -``` - -- After that, sync the generated files from the guest VM to the host machine: - -``` -$ # open a new terminal window -$ cd ~/teracy-dev -$ vagrant rsync-back -``` - -And you should see the generated files to the `dev/dev-setup/chef/main-cookbooks` directory. - -See more: https://github.com/chef/chef-dk - - -## dev-setup/chef/berks-cookbooks - - -This is the auto genereated cookbooks with dependencies from -the `dev/dev-setup/chef/main-cookbooks/teracy-dev-setup` cookbook. - - -`dev/dev-setup/chef/berks-cookbooks` is generated with: - -``` -$ vagrant ssh -$ ws -$ cd dev/dev-setup/chef -$ docker-compose up -``` - -and then `$ vagrant rsync-back` from the host terminal to sync generated files back to the host. - - -## Configuring the teracy cookbook to be used with `teracy-dev` - -The following sample configuration is used to configure the Chef provisioner of Vagrant -for the `vagrant_config_default.json` file: - -``` -{ - "provisioners": [{ - "_id": "0", - "_ua_cookbooks_path": [ - // "workspace/dev/dev-setup/chef/berks-cookbookss", - "workspace/dev/dev-setup/chef/main-cookbooks" - ], - "_ua_run_list": [ - "teracy-dev-setup" - ] - }] -} -``` diff --git a/dev-setup/chef/docker-compose.yml b/dev-setup/chef/docker-compose.yml deleted file mode 100644 index eed91da3..00000000 --- a/dev-setup/chef/docker-compose.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3' - -services: - - dev: - image: teracy/chefdk - working_dir: /opt/app - command: sh run-dev.sh - volumes: - - .:/opt/app diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/.gitignore b/dev-setup/chef/main-cookbooks/teracy-dev-setup/.gitignore deleted file mode 100644 index 13e41c40..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -.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/dev-setup/chef/main-cookbooks/teracy-dev-setup/Berksfile b/dev-setup/chef/main-cookbooks/teracy-dev-setup/Berksfile deleted file mode 100644 index 0656a996..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/Berksfile +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true -source 'https://supermarket.chef.io' - -metadata diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/LICENSE b/dev-setup/chef/main-cookbooks/teracy-dev-setup/LICENSE deleted file mode 100644 index d31c097c..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -Copyright 2017 The Authors - -All rights reserved, do not redistribute. diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/README.md b/dev-setup/chef/main-cookbooks/teracy-dev-setup/README.md deleted file mode 100644 index 6a1285c5..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# teracy-dev-setup - -TODO: Enter the cookbook description here. - diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/chefignore b/dev-setup/chef/main-cookbooks/teracy-dev-setup/chefignore deleted file mode 100644 index 38e7379b..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/chefignore +++ /dev/null @@ -1,107 +0,0 @@ -# Put files/directories that should be ignored in this file when uploading -# to a chef-server or supermarket. -# Lines that start with '# ' are comments. - -# OS generated files # -###################### -.DS_Store -Icon? -nohup.out -ehthumbs.db -Thumbs.db - -# SASS # -######## -.sass-cache - -# EDITORS # -########### -\#* -.#* -*~ -*.sw[a-z] -*.bak -REVISION -TAGS* -tmtags -*_flymake.* -*_flymake -*.tmproj -.project -.settings -mkmf.log - -## COMPILED ## -############## -a.out -*.o -*.pyc -*.so -*.com -*.class -*.dll -*.exe -*/rdoc/ - -# Testing # -########### -.watchr -.rspec -spec/* -spec/fixtures/* -test/* -features/* -examples/* -Guardfile -Procfile -.kitchen* -.rubocop.yml -spec/* -Rakefile -.travis.yml -.foodcritic -.codeclimate.yml - -# SCM # -####### -.git -*/.git -.gitignore -.gitmodules -.gitconfig -.gitattributes -.svn -*/.bzr/* -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Policyfile # -############## -Policyfile.rb -Policyfile.lock.json - -# Cookbooks # -############# -CONTRIBUTING* -CHANGELOG* -TESTING* -MAINTAINERS.toml - -# Strainer # -############ -Colanderfile -Strainerfile -.colander -.strainer - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/metadata.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/metadata.rb deleted file mode 100644 index 0a309168..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/metadata.rb +++ /dev/null @@ -1,20 +0,0 @@ -name 'teracy-dev-setup' -maintainer 'The Authors' -maintainer_email 'you@example.com' -license 'All Rights Reserved' -description 'Installs/Configures teracy-dev-setup' -long_description 'Installs/Configures teracy-dev-setup' -version '0.1.0' -chef_version '>= 12.1' if respond_to?(:chef_version) - -# 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//teracy-dev-setup/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//teracy-dev-setup' diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/default.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/default.rb deleted file mode 100644 index 3912f265..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/default.rb +++ /dev/null @@ -1,8 +0,0 @@ -# -# Cookbook:: teracy-dev-setup -# Recipe:: default -# -# Copyright:: 2017, The Authors, All Rights Reserved. - -include_recipe 'teracy-dev-setup::setup' -include_recipe 'teracy-dev-setup::docs' diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/docs.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/docs.rb deleted file mode 100644 index 00c88e0d..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/docs.rb +++ /dev/null @@ -1,23 +0,0 @@ -# -# Cookbook:: teracy-dev-setup -# Recipe:: docs -# -# Copyright:: 2017, The Authors, All Rights Reserved. - -# teracy-dev-docs project setup - -# we need this because the guest path could change in the future -# instead of ~/workspace, it's likely that we'll use /mnt/workspace - -cwd_path = node['teracy']['teracy-dev-docs']['project_guest_path'] - -execute 'docker-compose pull --ignore-pull-failures --parallel' do - cwd cwd_path - command 'docker-compose pull --ignore-pull-failures --parallel' -end - - -execute 'docker-compose up -d' do - cwd cwd_path - command 'docker-compose up -d' -end diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/setup.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/setup.rb deleted file mode 100644 index b6761764..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/recipes/setup.rb +++ /dev/null @@ -1,17 +0,0 @@ -# -# Cookbook:: teracy-dev-setup -# Recipe:: setup -# -# Copyright:: 2017, The Authors, All Rights Reserved. - -# teracy-dev-setup project setup - -# we need this because the guest path could change in the future -# instead of ~/workspace, it's likely that we'll use /mnt/workspace - -cwd_path = node['teracy']['teracy-dev-setup']['project_guest_path'] - -execute 'docker-compose pull --ignore-pull-failures --parallel' do - cwd cwd_path - command 'docker-compose pull --ignore-pull-failures --parallel' -end diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/spec/spec_helper.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/spec/spec_helper.rb deleted file mode 100644 index 052d78af..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/spec/spec_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true -require 'chefspec' -require 'chefspec/berkshelf' diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/spec/unit/recipes/default_spec.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/spec/unit/recipes/default_spec.rb deleted file mode 100644 index 2c71cd2d..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/spec/unit/recipes/default_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -# -# Cookbook:: teracy-dev-setup -# Spec:: default -# -# Copyright:: 2017, The Authors, All Rights Reserved. - -require 'spec_helper' - -describe 'teracy-dev-setup::default' do - context 'When all attributes are default, on an 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::ServerRunner.new(platform: 'ubuntu', version: '16.04') - runner.converge(described_recipe) - end - - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - end -end diff --git a/dev-setup/chef/main-cookbooks/teracy-dev-setup/test/smoke/default/default_test.rb b/dev-setup/chef/main-cookbooks/teracy-dev-setup/test/smoke/default/default_test.rb deleted file mode 100644 index 98df6449..00000000 --- a/dev-setup/chef/main-cookbooks/teracy-dev-setup/test/smoke/default/default_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -# # encoding: utf-8 - -# Inspec test for recipe teracy-dev-setup::default - -# The Inspec reference, with examples and extensive documentation, can be -# found at http://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 diff --git a/dev-setup/chef/run-dev.sh b/dev-setup/chef/run-dev.sh deleted file mode 100644 index 01373c13..00000000 --- a/dev-setup/chef/run-dev.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# install git first if not exist yet -# see: https://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script -#if hash git 2>/dev/null; then -# echo "git was installed"; -#else -# echo "installing git..."; -# apt-get update; -# apt-get install -qy git; -#fi - - -# rm -rm is just hacking, find a better way -rm -rf main-cookbooks/teracy-dev-setup/Berksfile.lock # always install the latest - -berks vendor -b main-cookbooks/teracy-dev-setup/Berksfile --delete && rm -rf berks-cookbooks/teracy-dev-setup - -chown 1000:1000 main-cookbooks/teracy-dev-setup/Berksfile.lock diff --git a/dev-setup/vagrant_config_default.json b/dev-setup/vagrant_config_default.json deleted file mode 100644 index ee8474b7..00000000 --- a/dev-setup/vagrant_config_default.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "vm": { - "synced_folders":[{ - "_id": "1", - "_ua_rsync__exclude": [ - "docs/_build" - ] - }, { // Enable this for .git two-way sync - "_id": "teracy-dev-setup-0", - "type": "virtual_box", - "host": "./workspace/dev/.git", - "guest": "/home/vagrant/workspace/dev/.git", - "mount_options": [ - "dmode=775", - "fmode=755" - ] - }, { // Enable this for docs/_build two-way sync to work - "_id": "teracy-dev-setup-1", - "type": "virtual_box", - "host": "./workspace/dev/docs/_build", - "guest": "/home/vagrant/workspace/dev/docs/_build", - "mount_options": [ - "dmode=775", - "fmode=755" - ], - "auto_create": true // this will auto create the host path if it does not exists - } - ] - }, - "provisioners": [{ - "_id": "0", - "_ua_cookbooks_path": [ - "workspace/dev/dev-setup/chef/main-cookbooks" - ], - "_ua_run_list": [ - "teracy-dev-setup" - ], - "json": { - "teracy": { - "teracy-dev-setup": { - "project_guest_path": "/home/vagrant/workspace/dev" - }, - "teracy-dev-docs": { - "project_guest_path": "/home/vagrant/workspace/dev/docs" - } - } - } - }], - "plugins": [{ - "_id": "2", - "options": { - "_ua_aliases": [ - "dev.dev-docs.teracy.dev", "ngrok-dev.dev-docs.teracy.dev", - "dev-docs.teracy.dev", "ngrok-prod.dev-docs.teracy.dev", - "review.dev-docs.teracy.dev", "ngrok-review.dev-docs.teracy.dev" - ] - } - }] -} diff --git a/docker-compose-mac.yml b/docker-compose-mac.yml deleted file mode 100644 index 1ff3b034..00000000 --- a/docker-compose-mac.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "2" - -services: - dev: - volumes: - - teracy-dev-sync:/opt/app:rw -volumes: - teracy-dev-sync: - external: true diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index faa02a07..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: "2" - -services: - dev: - build: - context: . - dockerfile: Dockerfile-dev - image: teracy/dev:dev_develop - command: bash -c "rake build && rake berks_install" - volumes: - - .:/opt/app - - /opt/app/.chef - - /opt/app/.vagrant - - /opt/app/.idea - - /opt/app/workspace diff --git a/docker-sync.yml b/docker-sync.yml deleted file mode 100644 index b356a349..00000000 --- a/docker-sync.yml +++ /dev/null @@ -1,10 +0,0 @@ -options: - compose-dev-file-path: 'docker-compose-mac.yml' - -syncs: - teracy-dev-sync: - src: '.' - dest: '/opt/app' - sync_strategy: 'unison' - sync_excludes: ['.chef', '.idea', '.vagrant', 'workspace'] - sync_host_port: 10873 diff --git a/docs/CHANGELOG_sphinx_deployment.md b/docs/CHANGELOG_sphinx_deployment.md deleted file mode 100644 index 5154f1b9..00000000 --- a/docs/CHANGELOG_sphinx_deployment.md +++ /dev/null @@ -1,27 +0,0 @@ -Change Log -========== - -[0.2.0][] ---------- - -- Improvement - + [SPXD-6] - remove duplication of git init when setup_gh_pages - -- New Feature - + [SPXD-5] - Rsync support - - -[0.1.0][] ---------- - -- Improvement - + [SPXD-2] - remove "make init_gh_pages" step - -- New Feature - + [SPXD-1] - make gen_deploy - + [SPXD-3] - installation bash script - - -[0.1.0]: https://issues.teracy.org/secure/ReleaseNote.jspa?version=10003&styleName=Text&projectId=10405&Create=Create&atl_token=BD5N-YNBS-EHHQ-478Z%7C87dd31199258f9de5ade180582481463461ded32%7Clin - -[0.2.0]: https://issues.teracy.org/secure/ReleaseNote.jspa?projectId=10405&version=10004 diff --git a/docs/Dockerfile.build b/docs/Dockerfile.build deleted file mode 100644 index 2a998bac..00000000 --- a/docs/Dockerfile.build +++ /dev/null @@ -1,27 +0,0 @@ -ARG PYTHON_VERSION=3.6 -FROM python:$PYTHON_VERSION - -LABEL authors="hoatle " - -RUN mkdir -p /opt/app - -ENV TERM=xterm-256color APP=/opt/app - -# add more arguments from CI to the image so that `$ env` should reveal more info -ARG CI_BUILD_ID -ARG CI_BUILD_REF -ARG CI_REGISTRY_IMAGE -ARG CI_BUILD_TIME - -ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \ - CI_BUILD_TIME=$CI_BUILD_TIME - -WORKDIR $APP - -ADD requirements.txt $APP/ - -RUN pip install -r requirements.txt - -ADD . $APP - -RUN make html diff --git a/docs/advanced_usage.rst b/docs/advanced_usage.rst index 431084a0..89026d80 100644 --- a/docs/advanced_usage.rst +++ b/docs/advanced_usage.rst @@ -3,56 +3,3 @@ Advanced Usage This is for advanced usage, make sure to master the :doc:`basic_usage` guide first. -Configuration -------------- - -Sometimes, we need some customized configuration other than default configuration. - -So for easier upgrade and customized configuration, we use a json file named `vagrant_config_override.json` -to override the default configuration on `vagrant_config.json` file. - -By using this, we can easily upgrade teracy-dev with ease, no conflicts introduced. - - -For example, to use more memory for the VM, looking into the `vagrant_config.json` file we could find: - -.. code-block:: javascript - - "vb":{ //virtualbox settings from https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm - //"gui":true, - //"name":"teracy-dev", - "memory":2048, - //"cpus":1, - "description":"teracy-dev #{Time.now.getutc.to_i}" - } - -Now create the `vagrant_config_override.json` file with the following content: - -.. code-block:: json - - { - "vb":{ - "memory":3072 - } - } - -After that, ``$ vagrant reload``, then this overridden configuration will update the VM with *3072* MB memory instead of default *2048* MB memory. - -This applied the same for other configuration that you want to override. Under the hood, we merge -the `vagrant_config_override.json` with `vagrant_config.json` to create the configuration settings. -The configuration settings are then applied to the `Vagrantfile` file. - - -Upgrading ---------- - -To upgrade teracy-dev, just pull the latest changes from the git repo and you're set: - -.. code-block:: bash - - $ cd ~/teracy-dev - $ git fetch origin && git reset --hard origin/master - -``$ vagrant reload --provision`` is used for improvements and bug fixes change upgrading. - -``$ vagrant destroy && vagrant up`` is used for next major version change upgrading. diff --git a/docs/android_training.rst b/docs/android_training.rst deleted file mode 100644 index a7fe25e4..00000000 --- a/docs/android_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -Android Training -================ \ No newline at end of file diff --git a/docs/basic_usage.rst b/docs/basic_usage.rst index 780101d4..2330226d 100644 --- a/docs/basic_usage.rst +++ b/docs/basic_usage.rst @@ -31,75 +31,32 @@ Vagrant For more, please check out: https://www.vagrantup.com/docs/getting-started/ -.. _basic_usage-ip_address: -IP Address ----------- - -By default, the VM uses a public dynamic IP address, so we need to know its IP address to access. - -When provisioning, we could see it on the console output like: - -.. code-block:: bash - - ==> default: Running provisioner: shell... - default: Running: inline script - ==> default: mesg: - ==> default: ttyname failed - ==> default: : - ==> default: Inappropriate ioctl for device - ==> default: ip address: 192.168.0.116 - - -When we want to display the IP address of the VM anytime, follow the commands below: - -.. code-block:: bash - - $ cd ~/teracy-dev - $ vagrant up - -Or: - -.. code-block:: bash - - $ cd ~/teracy-dev - $ vagrant provision --provision-with ip - - -And it should display the IP address output of the VM. - - -File Sync +Extension --------- -We use ``rsync`` for syncing files between the host machine and the VM (the guest machine) under -the `~/teracy-dev/workspace` directory by default. So put your project files there, it will be -synced back and forth with with `/home/vagrant/workspace` directory on the VM guest machine. -This is default setting and you can configure the sync directories and mechanism whatever you want. - -For easier and high-performance sync, we use additional vagrant plugins: -- `vagrant-gatling-rsync `_ +Supported Config +---------------- -- `vagrant-rsync-back `_ +Config Overriding +----------------- -1. Sync from the host machine to the guest VM - By default, we run ``$ vagrant gatling-rsync-auto`` automatically when ``$ vagrant up`` to watch - and sync files from the host machine to the guest VM automatically. - - We could stop and enable it anytime by running: ``$ vagrant gatling-rsync-auto``. +Upgrading +--------- +To upgrade teracy-dev, just checkout the desired git tag and you're set: -2. Sync from the guest VM to the host machine +.. code-block:: bash - This is used only when you want the file changes on the VM to be synced back to the host machine, - use this command: + $ cd ~/teracy-dev + $ git fetch origin && git checkout v0.6.0 - .. code-block:: bash +``$ vagrant reload --provision`` could be used for improvements and bug fixes change when upgrading. - $ vagrant rsync-back +``$ vagrant destroy && vagrant up`` could used for next major version change when upgrading. References diff --git a/docs/best_practices.rst b/docs/best_practices.rst deleted file mode 100644 index cbfb6c29..00000000 --- a/docs/best_practices.rst +++ /dev/null @@ -1,41 +0,0 @@ -Best Practices -============== - -This guide will list all the important best practices when using `teracy-dev`. - - -New User On-boarding Flow -------------------------- - -Consistent user experience for on-boarding is really important. When using ``teracy-dev`` to set up any -projects, we should always stick to the following rules: - -- Each project must have a ``README.md`` file. - -- The ``/README.md`` file should refer to the ``/dev-setup/README.md`` file which - must refer to the ``/dev-setup/README.md`` file to set up the organization level - development environment. - -- Then users need to continue with the ``/dev-setup/README.md`` file to set up the project - level development environment. - -That's all the steps that users must follow to set up any new project development environment, we -must automate as much as possible. - - -The rules above can be illustrated as follows: - -.. image:: _static/best-practices/new_user_on-boarding_flow.png - - - -Upgrading User Flow -------------------- - -When there are any upgrading steps required, the upgrading section must be introduced: - -- The ``/dev-setup/README.md#upgrading`` section for the organization level dev-setup - upgrading. - -- The ``/dev-setup/README.md#upgrading`` section for the project level dev-setup upgrading. - diff --git a/docs/built_in_ide.rst b/docs/built_in_ide.rst deleted file mode 100644 index 48ce1cc5..00000000 --- a/docs/built_in_ide.rst +++ /dev/null @@ -1,10 +0,0 @@ -Built-in IDE (codebox) -====================== - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/built_in_ide.html diff --git a/docs/c_c++_training.rst b/docs/c_c++_training.rst deleted file mode 100644 index 72ed55d8..00000000 --- a/docs/c_c++_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -C/C++ Training -============== \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index a18da5d4..370c0949 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -54,9 +54,9 @@ # built documents. # # The short X.Y version. -version = 'v0.5' +version = 'v0.6' # The full version, including alpha/beta/rc tags. -release = 'v0.5.0-c3-@' +release = 'v0.6.0-a1-SNAPSHOT' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/databases_guide.rst b/docs/databases_guide.rst deleted file mode 100644 index 80e84506..00000000 --- a/docs/databases_guide.rst +++ /dev/null @@ -1,10 +0,0 @@ -Databases Guide -=============== - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/databases_guide.html diff --git a/docs/django_training.rst b/docs/django_training.rst deleted file mode 100644 index 9438437d..00000000 --- a/docs/django_training.rst +++ /dev/null @@ -1,10 +0,0 @@ -Django Training -=============== - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/django_training.html diff --git a/docs/docker-compose-mac.yml b/docs/docker-compose-mac.yml deleted file mode 100644 index f5f322e3..00000000 --- a/docs/docker-compose-mac.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "2" - -services: - dev: - volumes: - - teracy-dev-docs-sync:/opt/app:rw -volumes: - teracy-dev-docs-sync: - external: true diff --git a/docs/docker-compose.prod.yml b/docs/docker-compose.prod.yml deleted file mode 100644 index 4ef57e8b..00000000 --- a/docs/docker-compose.prod.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: '3' - -services: - - ngrok-prod: - image: ${NGROK_PROD_IMAGE:-wernight/ngrok} - command: ngrok http -host-header=dev-docs.teracy.dev nginx-proxy:80 - environment: - - VIRTUAL_HOST=ngrok-prod.dev-docs.teracy.dev - - HTTPS_METHOD=noredirect - ports: - - 4040 - depends_on: - - app-prod - external_links: - - nginx-proxy - network_mode: bridge - - app-prod: - build: - context: . - dockerfile: Dockerfile - args: - CI_BUILD_ID: ${CI_BUILD_ID} - CI_BUILD_REF: ${CI_BUILD_REF} - CI_BUILD_TIME: ${CI_BUILD_TIME} - CI_REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE} - image: ${APP_PROD_IMAGE:-teracy/dev-docs:develop} - environment: - VIRTUAL_HOST: ${APP_PROD_VIRTUAL_HOST:-dev-docs.teracy.dev, ~^dev-docs\..*\.xip\.io} - HTTPS_METHOD: noredirect # support both http and https - network_mode: bridge diff --git a/docs/docker-compose.review.yml b/docs/docker-compose.review.yml deleted file mode 100644 index f6cda400..00000000 --- a/docs/docker-compose.review.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3' - -services: - - ngrok-review: - image: ${NGROK_REVIEW_IMAGE:-wernight/ngrok} - command: ngrok http -host-header=review.dev-docs.teracy.dev nginx-proxy:80 - environment: - - VIRTUAL_HOST=ngrok-review.dev-docs.teracy.dev - - HTTPS_METHOD=noredirect - ports: - - 4040 - depends_on: - - app-review - external_links: - - nginx-proxy - network_mode: bridge - - app-review: - image: ${APP_REVIEW_IMAGE} - environment: - VIRTUAL_HOST: ${APP_REVIEW_VIRTUAL_HOST:-review.dev-docs.teracy.dev, ~^review\.dev-docs\..*\.xip\.io} - HTTPS_METHOD: noredirect # support both http and https - network_mode: bridge diff --git a/docs/docker-compose.yml b/docs/docker-compose.yml deleted file mode 100644 index f59d4d59..00000000 --- a/docs/docker-compose.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "3" - -services: - - ngrok-dev: - image: ${NGROK_DEV_IMAGE:-wernight/ngrok} - command: ngrok http -host-header=dev.dev-docs.teracy.dev nginx-proxy:80 - environment: - - VIRTUAL_HOST=ngrok-dev.dev-docs.teracy.dev - - HTTPS_METHOD=noredirect - ports: - - 4040 - depends_on: - - app-dev - external_links: - - nginx-proxy - restart: unless-stopped - network_mode: bridge - - app-dev: - image: ${APP_DEV_IMAGE:-python:3.6} - working_dir: /opt/app - command: sh run-dev.sh - volumes: - - .:/opt/app - environment: - VIRTUAL_HOST: ${APP_DEV_VIRTUAL_HOST:-dev.dev-docs.teracy.dev, ~^dev.dev-docs\..*\.xip\.io} - HTTPS_METHOD: noredirect # support both http and https - ports: - - 80 - restart: unless-stopped - network_mode: bridge diff --git a/docs/docker-sync.yml b/docs/docker-sync.yml deleted file mode 100644 index 29c19693..00000000 --- a/docs/docker-sync.yml +++ /dev/null @@ -1,9 +0,0 @@ -options: - compose-dev-file-path: 'docker-compose-mac.yml' - -syncs: - teracy-dev-docs-sync: - src: '.' - dest: '/opt/app' - sync_strategy: 'unison' - sync_host_port: 10875 diff --git a/docs/docker.rst b/docs/docker.rst deleted file mode 100644 index d1936e00..00000000 --- a/docs/docker.rst +++ /dev/null @@ -1,90 +0,0 @@ -Docker -====== - -We leverage Docker for our software development. - -When ``$ vagrant up``, it's expected that ``docker`` and ``docker-compose`` should be installed within -the VM and ready to be used: - -.. code-block:: bash - - $ vagrant ssh - vagrant@vagrant:~$ docker version - Client: - Version: 1.12.3 - API version: 1.24 - Go version: go1.6.3 - Git commit: 6b644ec - Built: Wed Oct 26 22:01:48 2016 - OS/Arch: linux/amd64 - - Server: - Version: 1.12.3 - API version: 1.24 - Go version: go1.6.3 - Git commit: 6b644ec - Built: Wed Oct 26 22:01:48 2016 - OS/Arch: linux/amd64 - - -docker-machine --------------- - -Sometimes, we want to control the Docker VM with `docker-machine` from our host machine. Then do this: - -.. code-block:: bash - - $ cd ~/teracy-dev - $ docker-machine create -d generic \ - --generic-ssh-user vagrant \ - --generic-ssh-key .vagrant/machines/default/virtualbox/private_key \ - --generic-ip-address teracy-dev - -And then you should see something like: - -.. code-block:: bash - - Running pre-create checks... - Creating machine... - (teracy-dev) Importing SSH key... - Waiting for machine to be running, this may take a few minutes... - Detecting operating system of created instance... - Waiting for SSH to be available... - Detecting the provisioner... - Provisioning with ubuntu(upstart)... - Installing Docker... - Copying certs to the local machine directory... - Copying certs to the remote machine... - Setting Docker configuration on the remote daemon... - Checking connection to Docker... - Docker is up and running! - To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env teracy-dev - hoatle-mbp:teracy-dev hoatle$ docker-machine env teracy-dev - export DOCKER_TLS_VERIFY="1" - export DOCKER_HOST="tcp://192.168.99.101:2376" - export DOCKER_CERT_PATH="/Users/hoatle/.docker/machine/machines/teracy-dev" - export DOCKER_MACHINE_NAME="teracy-dev" - # Run this command to configure your shell: - # eval $(docker-machine env teracy-dev) - - -Debugging ---------- - -#. Node.js - -- node-inspector at: http://:8080/?port=5858 -- remote js debug with IntelliJ: http://stackoverflow.com/a/23947664/1122198 - - .. code-block:: bash - - vagrant ssh -- -L 5858:127.0.0.1:5858 - - -Related Resources ------------------ -- https://github.com/smerrill/vagrant-gatling-rsync -- https://github.com/veggiemonk/awesome-docker -- https://github.com/wsargent/docker-cheat-sheet -- https://github.com/chef-cookbooks/docker -- https://docs.docker.com/ diff --git a/docs/extending_teracy_dev.rst b/docs/extending_teracy_dev.rst deleted file mode 100644 index 4b7c199c..00000000 --- a/docs/extending_teracy_dev.rst +++ /dev/null @@ -1,306 +0,0 @@ -Extending teracy-dev -==================== - -``teracy-dev`` is developed with the goal to keep it as minimal and extensible as possible. The -extension feature is so powerful that you can customize the VM in anyway you want. - -You can extend ``teracy-dev``’s VM by your own choice of operating system and automate the -provisioning process by your own choice of configuration software. “The only limit is your -imagination” :–). - -To extend ``teracy-dev``, you can use any kind of provisioners that are supported by ``vagrant`` -(as ``teracy-dev`` is built on top of ``vagrant``), you can see more info here: -https://www.vagrantup.com/docs/provisioning/ - -We choose ``Chef`` as it’s our default provisioner because we have more years of usage experience. -We also intend to use ``Ansible`` for some future projects, too. - -Let me show you how to extend it to work with ``Kubernetes``. - -Make sure that you have ``teracy-dev`` running, if not, follow the :doc:`getting_started` guide first. - -Make sure that you master the :doc:`basic_usage` and :doc:`advanced_usage` guides, too. - - -Installing ``ChefDK`` ---------------------- - -To work with Chef cookbooks, we need to install ``ChefDK``. Fortunately, there is already an -available cookbook for us to use to install ``ChefDK`` automatically on our VM: -https://supermarket.chef.io/cookbooks/chef-dk - - -Usually, we have a ``dev-setup`` directory to extend ``teracy-dev``. The initial ``dev-setup`` content -should be like this: https://github.com/acme101/kubernetes-dev-setup/tree/0-initial - -To install ``ChefDK``, we must install the ``chef-dk`` cookbook and use it as follows: - -- Add ``depends 'chef-dk'`` to ``dev-setup/chef/main-cookbooks/acme/metadata.rb`` - -- Install vendor cookbooks with the following commands within the VM: - - .. code-block:: bash - - $ vagrant ssh - $ ws - $ cd dev-setup/chef - $ docker-compose up - - -- Sync back the changes from the VM to the host machine: - - .. code-block:: bash - - $ vagrant rsync-back - - -The updated content should be like this: https://github.com/acme101/kubernetes-dev-setup/tree/1-dependency - - -Now, to install ``chef-dk``, just add the following Ruby code to ``default.rb`` recipe, it's never -so easy: - -.. code-block:: bash - - chef_dk 'my_chef_dk' do - global_shell_init true - action :install - end - -Make sure you have ``berks-cookbooks`` paths that ``vagrant`` can look up. The configuration step -should be like this: https://github.com/acme101/kubernetes-dev-setup/tree/2-configuration - -- After that, ``$ vagrant reload --provision`` and voila, you should have ``ChefDk`` installed. - - .. code-block:: bash - - $ vagrant ssh - $ chef --version - Chef Development Kit Version: 1.4.3 - chef-client version: 12.19.36 - delivery version: master (41b94ffb5efd33723cf72a89bf4d273c8151c9dc) - berks version: 5.6.4 - kitchen version: 1.16.0 - inspec version: 1.25.1 - -That's how we use Chef cookbooks to manage the VM's software automatically. You can do the same with -all other types of Chef cookbooks shared and opensourced from the public Chef Supermarket: -https://supermarket.chef.io/ -You can use all the public shared cookbooks to do almost anything you want for your VM. - -However, sometimes, there is not available cookbook that we want, then it's time we should -build new cookbooks from scratch. - - -Creating new ``Chef`` cookbooks -------------------------------- - -From the steps above, we have ``ChefDK`` available to work with Chef cookbooks. To learn how to use it, -you can follow: https://github.com/chef/chef-dk - -I already created the initial ``kubernetes-stack-cookbook`` that we can work with. You need to clone -the repo into the ``workspace`` directory: - -.. code-block:: bash - - $ cd ~/teracy-dev/workspace - $ git clone git@github.com:teracyhq-incubator/kubernetes-stack-cookbook.git - -You can test the cookbook within the VM (``$ vagrant ssh``) with ``rspec``, ``kitchen`` easily: - -.. code-block:: bash - - $ ws - $ cd kubernetes-stack-cookbook/ - $ rspec - -you should see the following similar content: - -.. code-block:: bash - - kubernetes-stack::default - When all attributes are default, on ubuntu 16.04 - converges successfully - - kubernetes-stack-test::gcloud_install_default - When all attributes are default, on ubuntu 16.04 - converges successfully - install gcloud - - kubernetes-stack-test::kubectl_install_default - When all attributes are default, on ubuntu 16.04 - converges successfully - install kubectl - - Finished in 1.35 seconds (files took 1.78 seconds to load) - 5 examples, 0 failures - - - ChefSpec Coverage report generated... - - Total Resources: 7 - Touched Resources: 2 - Touch Coverage: 28.57% - - Untouched Resources: - - gcloud[install default gcloud] kubernetes-stack-test/recipes/gcloud_install_default.rb:1 - execute[import google-cloud-sdk public key] kubernetes-stack/resources/gcloud.rb:13 - apt_repository[google-cloud-sdk] kubernetes-stack/resources/gcloud.rb:17 - bash[clean up the mismatched kubectl version] kubernetes-stack/resources/kubectl.rb:20 - remote_file[/usr/local/bin/kubectl] kubernetes-stack/resources/kubectl.rb:33 - - -and to test with ``kitchen``: - -.. code-block:: bash - - $ ws - $ cd kubernetes-stack-cookbook/ - $ export KITCHEN_LOCAL_YAML=.kitchen.dokken.yml - $ kitchen test - - -then you should see the following similar content: - -.. code-block:: bash - - ... - Starting Chef Client, version 13.2.7 - [2017-06-14T17:53:24+00:00] WARN: Plugin Network: unable to detect ipaddress - resolving cookbooks for run list: ["kubernetes-stack-test::gcloud_install_default"] - Synchronizing Cookbooks: - - kubernetes-stack-test (0.1.0) - - kubernetes-stack (0.1.0) - Installing Cookbook Gems: - Compiling Cookbooks... - Converging 1 resources - Recipe: kubernetes-stack-test::gcloud_install_default - * gcloud[install default gcloud] action install - * execute[import google-cloud-sdk public key] action run - - execute curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - - * apt_repository[google-cloud-sdk] action add - * execute[apt-cache gencaches] action nothing (skipped due to action :nothing) - * apt_update[google-cloud-sdk] action nothing (skipped due to action :nothing) - * file[/etc/apt/sources.list.d/google-cloud-sdk.list] action create - - create new file /etc/apt/sources.list.d/google-cloud-sdk.list - - update content in file /etc/apt/sources.list.d/google-cloud-sdk.list from none to 24ee22 - --- /etc/apt/sources.list.d/google-cloud-sdk.list 2017-06-14 17:53:25.296105380 +0000 - +++ /etc/apt/sources.list.d/.chef-google-cloud-sdk20170614-20-7wqkmu.list 2017-06-14 17:53:25.296105380 +0000 - @@ -1 +1,2 @@ - +deb "http://packages.cloud.google.com/apt" cloud-sdk-xenial main - - change mode from '' to '0644' - - change owner from '' to 'root' - - change group from '' to 'root' - * execute[apt-cache gencaches] action run - - execute apt-cache gencaches - * apt_update[google-cloud-sdk] action update - - force update new lists of packages - * directory[/var/lib/apt/periodic] action create (up to date) - * directory[/etc/apt/apt.conf.d] action create (up to date) - * file[/etc/apt/apt.conf.d/15update-stamp] action create_if_missing - - create new file /etc/apt/apt.conf.d/15update-stamp - - update content in file /etc/apt/apt.conf.d/15update-stamp from none to 174cdb - --- /etc/apt/apt.conf.d/15update-stamp 2017-06-14 17:53:26.136525380 +0000 - +++ /etc/apt/apt.conf.d/.chef-15update-stamp20170614-20-1r28edv 2017-06-14 17:53:26.136525380 +0000 - @@ -1 +1,2 @@ - +APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";}; - * execute[apt-get -q update] action run - - execute apt-get -q update - - - * apt_package[google-cloud-sdk] action install - - - install version 159.0.0-0 of package google-cloud-sdk - - - Running handlers: - Running handlers complete - Chef Client finished, 9/13 resources updated in 55 seconds - Finished converging (1m0.97s). - -----> Setting up ... - Finished setting up (0m0.00s). - -----> Verifying ... - Loaded tests from test/smoke/gcloud - - Profile: tests from test/smoke/gcloud - Version: (not specified) - Target: docker://16562c9afb7c00447169330fc584b442617a810f6b776d2eb6b78ce87d5d652f - - - Command which - ✔ gcloud exit_status should eq 0 - ✔ gcloud stdout should match "/usr/bin/gcloud" - - Test Summary: 2 successful, 0 failures, 0 skipped - Finished verifying (0m0.64s). - -----> Destroying ... - Deleting kitchen sandbox at /home/vagrant/.dokken/kitchen_sandbox/1000b8c847-smoke-gcloud-ubuntu-1604 - Deleting verifier sandbox at /home/vagrant/.dokken/verifier_sandbox/1000b8c847-smoke-gcloud-ubuntu-1604 - Finished destroying (0m10.67s). - Finished testing (1m55.61s). - -----> Kitchen is finished. (4m12.76s) - - -That's how we develop and test the cookbook on local dev. - -You can see the cookbook here at https://github.com/teracyhq-incubator/kubernetes-stack-cookbook - -It's currently a very simple cookbook to support the installation of `kubectl` and `gcloud`. In -the future, it will do more than that and support more platforms than current Ubuntu only. - - -Installing ``kubectl`` and ``gcloud`` -------------------------------------- - -The ``kubernetes-stack-cookbook`` is not available on the Chef Supermarket (yet), so to use it, we need -to install it from the github repo. - -To install ``kubectl``, add this to the ``default.rb`` recipe: - -.. code-block:: ruby - - kubectl 'install the latest kubectl' - - -To install ``gcloud``, add this to the ``default.rb`` recipe: - -.. code-block:: ruby - - gcloud 'install the latest gcloud' - -The configuration step should be like this: -https://github.com/acme101/kubernetes-dev-setup/tree/3-kubectl-gcloud-installation - -After that, ``$ vagrant reload --provision`` and voila (again), you should have both of the packages installed. - -.. code-block:: bash - - $ kubectl version - Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:44:27Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"} - The connection to the server localhost:8080 was refused - did you specify the right host or port? - -.. code-block:: bash - - vagrant@teracy:~$ gcloud --version - Google Cloud SDK 159.0.0 - alpha 2017.06.09 - beta 2017.06.09 - bq 2.0.24 - core 2017.06.09 - gcloud - gsutil 4.26 - - -Summary -------- - -Now you should know how to extend ``teracy-dev`` with Chef cookbooks, this is a very common task to do. -And other newcomer devs can just use your ``dev-setup`` without learning anything new, just follow -the instructions and learn more to master later. - - -References ----------- - -- http://blog.teracy.com/2017/06/15/how-to-extend-teracy-dev-to-work-with-kubernetes/ diff --git a/docs/faqs.rst b/docs/faqs.rst deleted file mode 100755 index c49eb40a..00000000 --- a/docs/faqs.rst +++ /dev/null @@ -1,67 +0,0 @@ -FAQs -==== -This page provides the frequently asked questions (FAQs) about ``teracy-dev``. - -Why teracy-dev? Why not just Docker? ------------------------------------- -Docker is great to work with, it solves a lot of problems on development, distribution, and production deployment. It works great on Linux, but it's very challenging to make it work universal and consistent on Mac and Windows. There are lots of efforts to solve this problem, from Docker themselves and from Docker community, too. However, we haven't achieved that stage yet (until ``teracy-dev``). ``teracy-dev`` is a universal Productive Development Platform With Docker on macOS, Linux and Windows. With ``teracy-dev``, anyone from any OS platforms could collaborate and help each other with no differences in the development environment, and many other reasons why you should use ``teracy-dev`` to develop software more easily, see details at -http://blog.teracy.com/2016/12/20/teracy-dev-the-only-truly-universal-productive-development-platform-with-docker-on-macos-linux-and-windows/. - -How do I know which version of ``teracy-dev`` that I'm using? -------------------------------------------------------------- -Currently, to know the version of teracy-dev which you are using, you need to follow the steps: -First, you need to ``git branch`` to know the current branch, then ``git log`` to know the info about the latest commits. Normally, we have the commits about release the new version, for example, "Merge pull request #313 from hoatle/tasks/#312-release-v0.5.0-b3". - -We'll provide a simpler way soon at https://github.com/teracyhq/dev/issues/366. - - -After ``vaggrant ssh``, why cannot I run the ``grunt`` or ``npm`` command in the VM? ------------------------------------------------------------------------------------- - -The ``grunt`` or ``npm`` command is not used in the ``teracy-dev`` latest version anymore. Instead, ``docker`` and ``docker-compose`` is installed by default and you should use these two. - -What should I do after updating ``vagrant_config_override.json`` to get it applied to the VM? ---------------------------------------------------------------------------------------------- -Make sure to save the ``vagrant_config_override.json`` file, and you can run ``$ vagrant provision`` -, usually this should work. If not, run ``$ vagrant reload --provision``. - -What should I do when ``$ vagrant up`` gets stuck at this step? ---------------------------------------------------------------- - :: - - default: /tmp/vagrant-chef/7cb2926f81b5c74a4ca3dd163f9d9ffd/roles => /Users/hoatle/teracy-dev/workspace/teracy-dev/roles - default: /tmp/vagrant-chef/3071687433aa992e850e416aafea8f25/nodes => /Users/hoatle/teracy-dev/workspace/teracy-dev/nodes - default: /tmp/vagrant-chef/bbfefdc57119d7552b06b24069242f8a/data_bags => /Users/hoatle/teracy-dev/workspace/teracy-dev/data_bags - default: /tmp/vagrant-chef/9b5518c8fee080ca55f1c57179068e17/cookbooks => /Users/hoatle/teracy-dev/workspace/teracy-dev/vendor-cookbooks - default: /tmp/vagrant-chef/87b97d785383812081b2ec7e56be857d/cookbooks => /Users/hoatle/teracy-dev/workspace/teracy-dev/main-cookbooks - ==> default: Running provisioner: chef_solo... - default: Installing Chef (latest)... - -Then stop it, ``$ vagrant ssh`` to update this http://askubuntu.com/questions/620317/apt-get-update-stuck-connecting-to-security-ubuntu-com, then ``$ vagrant reload --provision`` again. - - -``/etc/hosts`` is not properly updated when I got errors, after ``$ vagrant destroy`` and ``$ vagrant up``. I end up having multiple same entries that the wrong one is on the top of the file. This leads to wrong DNS to point to the right VM's IP address. What should I do? -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Follow the steps below: - -1. check VM's ip: ``$ vagrant up`` -2. ``$ vagrant hostmanger`` to make sure ``/etc/hosts`` is updated. -3. ``$ ping `` to see if it pings the right VM IP from step 1. -4. If it's not right, open ``/etc/hosts`` to check and remove wrong entries. -5. Come back to Step 3 to verify. - - -What should I do when the ``teracy-dev`` version is changed? ------------------------------------------------------------- -You should run the command ``vagrant destroy``, then ``vagrant up``. - -What should I do when changing provisioner (Chef, Bash...)? ------------------------------------------------------------ -You should run the command ``$ vagrant reload --provision``. - - -What should I do when meeting other errors, and the problems cannot be solved with ``vagrant reload`` or ``vagrant reload --provision``? ---------------------------------------------------------------------------------------------------------------------------------------------- - -You should run the command ``vagrant destroy``, then ``$ vagrant up``. - diff --git a/docs/firefox_addon_dev_guide.rst b/docs/firefox_addon_dev_guide.rst deleted file mode 100644 index 6896be27..00000000 --- a/docs/firefox_addon_dev_guide.rst +++ /dev/null @@ -1,12 +0,0 @@ -Firefox Add-ons Development Guide -================================= - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/firefox_addon_dev_guide.html - - diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 1ce39960..cd69db8c 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -54,13 +54,13 @@ Open the terminal window: 2. Install ``virtualbox`` and ``vagrant`` - - Install ``virtualbox`` (>=5.1): + - Install ``virtualbox``: .. code-block:: bash $ brew cask install virtualbox - - Install ``vagrant`` (>=1.8.7, >=1.9.1): + - Install ``vagrant``: .. code-block:: bash @@ -89,16 +89,6 @@ Open the terminal window: - // TODO(hoatle): https://github.com/teracyhq/dev/issues/175 -Please check out the instruction video below for more details: - - .. raw:: html - - - - .. note:: - - The video is not really up to date with current teracy-dev v0.5.0, however, you will see the similar workflow and result. - Next: :ref:`teracy-dev Git Clone and Vagrant Up ` Automatic Installation on Linux (Ubuntu) @@ -122,20 +112,20 @@ Open the terminal window: $ sudo apt-get update $ sudo apt-get install -y git -2. Install ``virtualbox`` (>=5.1): +2. Install ``virtualbox``: .. code-block:: bash $ sudo sh -c "echo 'deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free' > /etc/apt/sources.list.d/virtualbox.list" \ && wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc -O- | sudo apt-key add - \ && wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - \ - && sudo apt-get update && sudo apt-get install virtualbox-5.1 -y + && sudo apt-get update && sudo apt-get install virtualbox-5.2 -y -3. Install ``vagrant`` (>=1.8.7, >=1.9.1): +3. Install ``vagrant``: .. code-block:: bash - $ version=1.9.1 && cd /tmp \ + $ version=2.1.2 && cd /tmp \ && wget $(if [ `uname -m` == "x86_64" ]; then echo "https://releases.hashicorp.com/vagrant/$version/vagrant_${version}_x86_64.deb"; else echo "https://releases.hashicorp.com/vagrant/$version/vagrant_${version}_i686.deb"; fi;) \ && sudo dpkg -i vagrant_${version}* && rm vagrant_${version}* && cd -- @@ -253,17 +243,17 @@ Follow step by step instructions below: $ cyg-get.bat git - - Install ``virtualbox`` (>=5.1): + - Install ``virtualbox``: .. code-block:: bash - $ choco install virtualbox --version 5.1.14 -y + $ choco install virtualbox --version 5.2.14 -y - - Install ``vagrant`` (>=1.8.7, >=1.9.1): + - Install ``vagrant``: .. code-block:: bash - $ choco install vagrant --version 1.9.1 -y + $ choco install vagrant --version 2.1.2 -y After finishing the ``vagrant`` installation, restart the machine. @@ -298,22 +288,30 @@ teracy-dev Git Clone and Vagrant Up - Check out the `develop` branch to use the latest development version of teracy-dev. - Check out the `master` branch to use the latest stable version of teracy-dev. + - Checkout the tagged released version for usage. You should see the following similar messages after ``$ vagrant up`` finishes running: :: - ==> default: [2016-11-25T06:02:16+00:00] INFO: Report handlers complete - ==> default: Chef Client finished, 9/15 resources updated in 03 minutes 36 seconds - ==> default: Running provisioner: shell... - ==> default: Running: inline script - ==> default: stdin: is not a tty - ==> default: ip address: 192.168.0.105 - ==> default: vagrant-gatling-rsync is starting the sync engine because you have at least one rsync folder. To disable this behavior, set `config.gatling.rsync_on_startup = false` in your Vagrantfile. - ==> default: Doing an initial rsync... - ==> default: Rsyncing folder: /Users/hoatle/teracy-dev/workspace/ => /home/vagrant/workspace - ==> default: - Exclude: [".vagrant/", ".git", ".idea/", "node_modules/", "bower_components/", ".npm/"] - + ==> node-01: Waiting for machine to boot. This may take a few minutes... + node-01: SSH address: 127.0.0.1:2201 + node-01: SSH username: vagrant + node-01: SSH auth method: private key + node-01: Warning: Remote connection disconnect. Retrying... + node-01: Warning: Connection reset. Retrying... + node-01: + node-01: Vagrant insecure key detected. Vagrant will automatically replace + node-01: this with a newly generated keypair for better security. + node-01: + node-01: Inserting generated public key within guest... + node-01: Removing insecure key from the guest if it's present... + node-01: Key inserted! Disconnecting and reconnecting using new SSH key... + ==> node-01: Machine booted and ready! + ==> node-01: Checking for guest additions in VM... + ==> node-01: Setting hostname... + ==> node-01: Mounting shared folders... + node-01: /vagrant => /Users/hoatle/teracy-dev/workspace/dev .. note:: @@ -335,8 +333,7 @@ teracy-dev Git Clone and Vagrant Up "VBoxDrv.inf" in your installation directory then re-install it to fix the issue. The VirtualBox has an installation issue which was reported `here `_ -2. Keep the first terminal window running, open a new terminal window and use the ``$ vagrant ssh`` - command to access the virtual machine you have just provisioned. +2. Use the ``$ vagrant ssh`` command to access the virtual machine you have just `vagrant up`. .. code-block:: bash @@ -347,31 +344,15 @@ teracy-dev Git Clone and Vagrant Up .. code-block:: bash - Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-51-generic x86_64) - - * Documentation: https://help.ubuntu.com - * Management: https://landscape.canonical.com - * Support: https://ubuntu.com/advantage + Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64) - 1 package can be updated. - 1 update is a security update. + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + 0 packages can be updated. + 0 updates are security updates. - Last login: Tue Dec 6 14:19:56 2016 from 10.0.2.2 - -3. Check if `docker` and `docker-compose` are already installed - - After ``$ vagrant ssh``, use the following commands: - - .. code-block:: bash - - $ docker --version - $ docker-compose --version - - .. note:: - - In case the `docker` command is not found, you should ``$ vagrant destroy``, then - ``$ vagrant up`` again or ``$ vagrant reload --provision``. Git Setup --------- diff --git a/docs/git_training.rst b/docs/git_training.rst deleted file mode 100644 index fcd6db89..00000000 --- a/docs/git_training.rst +++ /dev/null @@ -1,203 +0,0 @@ -Git Training -============ - -Git is a distributed version control systems (DVCS) which was used to manange all Teracy's -development resources. You need to learn to use Git to work with Teracy's projects. - -Studying ---------- - -There are many free available resources for you to study git. The followings are some recommended resources: - -- http://git-scm.com/book - -- http://sixrevisions.com/resources/git-tutorials-beginners/ - -- http://documentup.com/skwp/git-workflows-book - -Practising ----------- - -- Prerequisites - - + You need to have a github account with configured ssh keys. - - + ``teracy-dev`` is running with working ssh (``$ ssh -T git@github.com`` should be ok). - -- Git basics - - + You are going to create a ``pro-git-practice`` repository on github (via github's web UI). - - + The repository on your VM should be at ``workspace/personal/pro-git-practice``. - - + Read the chapter 2 and practice with your ``pro-git-practice`` repository on your VM at - http://git-scm.com/book/en/Git-Basics. - - + Remember to push the changes to github so we could see your work and practice. - - -- Working again on teracy-tutorial - -.. note:: - You are encouraged to practice with as many git commands as possible, but have to follow - strictly all the instructions below, the results will be displayed on github to check. - -As you remember, you practiced to adapt Django's tutorial into Teracy's ``Django boilerplate`` project. - -Now you will continue to work on it with git and push it to github. - -#. Initial setup: - - - Create your repository named ``teracy-tutorial`` on github, and set up the local repo `` workspace/personal/teracy-tutorial`` on your VM. - - - Push this first commit on github (Initial setup). - -#. Setting up project layout - - - Add the remote repository https://github.com/teracyhq/django-boilerplate.git into - your repository with the ``djbp`` name. - - - Fetch and merge the ``djbp/master`` branch. - - - Push the merge to your github's repository at ``origin/master``. - -#. Tutorial 01 at https://docs.djangoproject.com/en/1.5/intro/tutorial01/. - - - Create a branch named ``tutorial01``, branch off from ``origin/master``. - - - Checkout the ``tutorial01`` branch - - - Skip the section of ``startproject`` as we already started a project with ``teracy``. - - - Work on the ``Creating models`` section and commit the changes with the message: ``Creating models``. - - - Work on the ``Activating models`` section and commit the changes with the message: ``Activating - models``. - - - Work on the ``Playing with the API`` section and commit the changes with the message: ``Playing - with the API``. - - - Push the ``tutorial01`` branch to ``origin/tutorial01`` branch. - - (You should open the repository on github and see the branch there.) - - - Merge (no fast forward) (hint: $ git merge --no-ff) the ``tutorial01`` branch into the ``master`` - branch, then push to the ``origin/master`` branch. - -#. Tutorial 02 at https://docs.djangoproject.com/en/1.5/intro/tutorial02/. - - - Create a branch named ``tutorial02``, branch off from ``origin/master``. - - - Checkout ``tutorial02`` branch. - - - Skip ``Activate the admin site`` section as admin is activated by teracy's project layout on - ``settings/dev.py``. - - - Work on the ``Make the poll app modifiable in the admin`` section and commit the changes. - - - Work on the ``Customize the admin form`` section and commit the changes. - - - Work on the ``Adding related objects`` section and commit the changes. - - - Work on the ``Customize the admin change list`` section and commit the changes. - - - Work on the ``Customize the admin look and feel`` section and commit the changes. - - .. note:: - TEMPLATE_DIRS is already configured by ``teracy-django-boilerplate``, you could just use - it. - - - Work on the ``Customize the admin index page`` section and commit the changes. - - - Push ``tutorial02`` to ``origin/tutorial02`` and see it on github. - - - Merge no fast forward ``tutorial02`` into ``master`` and push to ``origin/master``. - -#. Tutorial 03 at https://docs.djangoproject.com/en/1.5/intro/tutorial03/ - - - Create a branch named ``tutorial03``, branch off from ``origin/master``. - - - Checkout the ``tutorial03`` branch. - - - Work on the ``Write your first view`` section and commit. - - - Work on the ``Writing more views`` section and commit. - - - Work on the ``Write views that actually do something`` section and commit. - - - Work on the ``A shortcut: render()`` section and commit. - - - Work on the ``Raising a 404 error`` section and commit. - - - Work on the ``A shortcut: get_object_or_404()`` section and commit. - - - Work on the ``Write a 404 (page not found) view`` section and commit. - - - Work on the ``Write a 500 (server error) view`` section and commit. - - - Work on the ``Use the template system`` section and commit. - - - Work on the ``Removing hardcoded URLs in templates`` section and commit. - - - Work on the ``Namespacing URL names`` section and commit. - - - Push ``tutorial03`` to ``origin/tutorial03`` and see it on github. - - - Merge no fast forward ``tutorial03`` into ``master`` and push to ``origin/master``. - -#. Tutorial 04 at https://docs.djangoproject.com/en/1.5/intro/tutorial04/. - - - Create a branch named ``tutorial04``, branch off from ``origin/master``. - - - Checkout the ``tutorial04`` branch. - - - Work on the ``Write a simple form`` section and commit. - - - Work on the ``Use generic views: Less code is better`` section and commit. - - - Work on the ``Amend URLconf`` section and commit. - - - Work on the ``Amend views`` section and commit. - - - Push ``tutorial04`` to ``origin/tutorial04`` and see it on github. - - - Merge no fast forward ``tutorial04`` into ``master`` and push to ``origin/master``. - -#. Tutorial 05 at https://docs.djangoproject.com/en/1.5/intro/tutorial05/ - - - Create a branch named ``tutorial05``, branch off from ``origin/master``. - - - Checkout the ``tutorial05`` branch. - - - Work on the ``Create a test to expose the bug`` section and commit. - - - Work on the ``Fixing the bug`` section and commit. - - - Work on the ``More comprehensive tests`` section and commit. - - - Work on the ``Improving our view`` section and commit. - - - Work on the ``Testing our new view`` section and commit. - - - Work on the ``Testing the DetailView`` section and commit. - - - Push ``tutorial05`` to ``origin/tutorial05`` and see it on github. - - - Merge no fast forward ``tutorial05`` into ``master`` and push to ``origin/master``. - -#. Tutorial 06 at https://docs.djangoproject.com/en/1.5/intro/tutorial06/. - - - Create a branch named ``tutorial06``, branch off from ``origin/master``. - - - Checkout the ``tutorial06`` branch. - - - Work on the ``Customize your app’s look and feel`` section and commit. - - - Work on the ``Adding a background-image`` section and commit. - - - Push ``tutorial06`` to ``origin/tutorial06`` and see it on github. - - - Merge no fast forward ``tutorial06`` into ``master`` and push to ``origin/master``. - -Congratulations, now you could work with git with basic commands. You will know more about git from time to -time when working at Teracy. diff --git a/docs/html_css_training.rst b/docs/html_css_training.rst deleted file mode 100644 index c4473ed8..00000000 --- a/docs/html_css_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -HTML/CSS Training -================= \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 737efb03..2d775ac9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,34 +15,13 @@ Contents: getting_started basic_usage advanced_usage - best_practices - extending_teracy_dev - docker tool_chain - built_in_ide style_standards workflow - teracy_dev_development - git_training most_used_git_commands - firefox_addon_dev_guide docs_guide - databases_guide - nodejs_dev_guide - c_c++_training - python_dev_guide - django_training - ruby_dev_guide - php_dev_guide - html_css_training - js_training - java_training - objective_c_training - ios_training - android_training semantic_versioning release_process - faqs Indices and tables ================== diff --git a/docs/ios_training.rst b/docs/ios_training.rst deleted file mode 100644 index f3a25f9f..00000000 --- a/docs/ios_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -iOS Training -============ \ No newline at end of file diff --git a/docs/java_training.rst b/docs/java_training.rst deleted file mode 100644 index 0396c18e..00000000 --- a/docs/java_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -Java Training -============= \ No newline at end of file diff --git a/docs/js_training.rst b/docs/js_training.rst deleted file mode 100644 index 3a211433..00000000 --- a/docs/js_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -JavaScript Training -=================== \ No newline at end of file diff --git a/docs/nodejs_dev_guide.rst b/docs/nodejs_dev_guide.rst deleted file mode 100644 index b7779c7a..00000000 --- a/docs/nodejs_dev_guide.rst +++ /dev/null @@ -1,557 +0,0 @@ -Node.js Development Guide -========================= - -Follow this guide to create https://github.com/acme101/nodejs-hello-world from scratch. - -Make sure that you have ``teracy-dev`` running, if not yet, follow the :doc:`getting_started` guide first. - -Make sure that you master the :doc:`basic_usage` guide, too. - - -Enable proxy and add aliases domains ------------------------------------- - -To access your nodejs web app with the domain ``dev.nodejs.teracy.dev`` (dev mode), -``review.nodejs.teracy.dev``` (review mode) and ``nodejs.teracy.dev`` (local prod mode), you need -to enable the proxy container and configure domain aliases so that everything should be -set up automatically under the hood for you. - -- Create ``vagrant_config_override.json`` file under the ``~/teracy-dev`` directory with the - following content: - - .. code-block:: json - - { - "provisioners": [{ - "_id": "0", - "json": { - "teracy-dev": { - "proxy": { - "container": { - "enabled": true - } - } - } - } - }], - "plugins": [{ - "_id": "2", - "options": { - "aliases": ["dev.nodejs.teracy.dev", "review.nodejs.teracy.dev" "nodejs.teracy.dev"] - } - }] - } - -- Reload the VM to get new configuration updated to the VM: - - .. code-block:: bash - - $ cd ~/teracy-dev - $ vagrant reload --provision - -- Update the ``/etc/hosts`` file automatically with the following commands: - - .. code-block:: bash - - $ cd ~/teracy-dev - $ vagrant hostmanager - -- Now open teracy.dev on your browser, it should display the following similar message: - - .. code-block:: bash - - 503 Service Temporarily Unavailable - - nginx/1.11.9 - - so reverse proxy works. - - -Init the project ----------------- - - -- Create the ``nodejs-hello-world`` directory under the ``~/teracy-dev/workspace`` directory by - opening a host terminal window and execute the following commands: - - .. code-block:: bash - - $ cd ~/teracy-dev/workspace - $ mkdir nodejs-hello-world - -- Use the ``node:8.1.3-alpine`` Docker image to run ``$ npm init`` by ``vagrant ssh`` into the VM - and execute the commands as follows: - - .. code-block:: bash - - $ vagrant ssh - $ ws - $ cd nodejs-hello-world - $ docker container run -it --rm -v $(pwd):/opt/nodejs-hello-world -w /opt/nodejs-hello-world node:8.1.3-alpine sh - - You should be presented with the container bash session as: ``/opt/nodejs-hello-world #`` - -- ``# npm init`` and fill in the content as below: - - .. code-block:: bash - - /opt/nodejs-hello-world # npm init - npm info it worked if it ends with ok - npm info using npm@5.0.3 - npm info using node@v8.1.3 - This utility will walk you through creating a package.json file. - It only covers the most common items, and tries to guess sensible defaults. - - See `npm help json` for definitive documentation on these fields - and exactly what they do. - - Use `npm install ` afterwards to install a package and - save it as a dependency in the package.json file. - - Press ^C at any time to quit. - package name: (nodejs-hello-world) - version: (1.0.0) 0.1.0-SNAPSHOT - description: nodejs-hello-world - entry point: (index.js) - test command: - git repository: - keywords: - author: Teracy - license: (ISC) MIT - About to write to /opt/nodejs-hello-world/package.json: - - { - "name": "nodejs-hello-world", - "version": "0.1.0-SNAPSHOT", - "description": "nodejs-hello-world", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Teracy", - "license": "MIT" - } - - - Is this ok? (yes) yes - npm info init written successfully - npm info ok - -- You need to sync the generated files from the VM machine back to the host machine by opening a host - terminal window and type: - - .. code-block:: bash - - $ cd teracy-dev - $ vagrant rsync-back - - After that, you should see the ``package.json`` file under the - ``~/teracy-dev/workspace/nodejs-hello-world`` directory on the host machine. - - -The changes should be like this: -https://github.com/acme101/nodejs-hello-world/commit/893a19a17ced18d8aef5115ff85a109efc0f43a5 - - -Install dependencies --------------------- - -We're going to use ``express`` for the web app construction and ``nodemon`` for development -convenience. - -- Continue running the following commands within the container bash session: - - .. code-block:: bash - - /opt/nodejs-hello-world # yarn add express - /opt/nodejs-hello-world # yarn add nodemon --dev - -- And similarly, you need to sync the generated files from the VM machine back to the host machine - by opening a host terminal window and type: - - .. code-block:: bash - - $ cd teracy-dev - $ vagrant rsync-back - - After that, you should see the updated ``package.json`` file. - -The changes should be like this: -https://github.com/acme101/nodejs-hello-world/commit/a2208b5b1110d920e78d292cfcb9f6aec4f93a3b - - -Add app.js and update package.json's scripts --------------------------------------------- - -- Create ``app.js`` file within the ``nodejs-hello-world`` directory with the following content: - - .. code-block:: javascript - - var express = require('express'); - var app = express(); - - app.get('/', function (req, res) { - res.send('Hello World!'); - }); - - var port = process.env.PORT || 3000; - app.listen(port, function () { - console.log('app listening on port ' + port); - }); - -- Update the ``main``, ``scripts`` section on the ``package.json`` file: - - .. code-block:: json - - "main": "app.js", - "scripts": { - "dev": "nodemon --inspect=0.0.0.0:5858", - "dev:brk": "nodemon --inspec-brk=0.0.0.0:5858", - "test": "echo \"Error: no test specified\" && exit 1" - } - -The changes should be like this: -https://github.com/acme101/nodejs-hello-world/commit/a2228e9c4da01bf3988337def3cf26c4974a9c6f - - -Create dev mode ---------------- - -Dev mode usually contains development packages to assist development productivity, for example: -auto reloading when there are code changes, debugging, etc. - - -- Create ``docker-compose.yml`` file within the ``nodejs-hello-world`` directory with the following - content: - - .. code-block:: yaml - - version: '3' - - services: - - dev: - image: ${DOCKER_IMAGE_DEV:-node:8.1.3-alpine} - working_dir: /opt/app - command: sh run-dev.sh - environment: - NODE_ENV: development - PORT: 3000 - VIRTUAL_HOST: dev.nodejs.teracy.dev, ~^dev\.nodejs\..*\.xip\.io - VIRTUAL_PORT: 3000 - HTTPS_METHOD: noredirect # support both http and https - env_file: - - .env-common - - .env-dev - ports: - - "3000" - - "5858" - volumes: - - .:/opt/app - restart: unless-stopped - # to get this work with https://github.com/jwilder/nginx-proxy - # related: https://github.com/jwilder/nginx-proxy/issues/305 - network_mode: bridge - - -- Create ``run-dev.sh`` with the following content: - - .. code-block:: bash - - #!/bin/bash - - yarn - - yarn run dev - - - -- Create ``.env-common`` and ``.env-dev`` files to set environment variables when required. - - -The changes should be like this: -https://github.com/acme101/nodejs-hello-world/commit/b0a7ac4e95898ecd12651830917a5f4db9561420 - - -Run on dev mode ---------------- - -Open a new terminal window, ``vagrant ssh`` into the ``teracy-dev`` VM to execute the following commands: - -.. code-block:: bash - - $ vagrant ssh - $ ws - $ cd nodejs-hello-world - $ docker-compose up -d dev && docker-compose logs -f dev - - -After that, open: - -- http://dev.nodejs.teracy.dev or https://dev.nodejs.teracy.dev on your host browser to see the app - on the dev mode. -- Check out the VM's :ref:`basic_usage-ip_address` and on any device within your LAN, - open http://dev.nodejs..xip.io or https://dev.nodejs..xip.io to see the web app. - - -Two-way sync for node_modules ------------------------------ - -By default, we disable ``node_modules`` sync. To have two-way sync, we need to configure it. - -- Create the ``node_modules`` directory from the host terminal window: - - .. code-block:: bash - - $ cd ~/teracy-dev/workspace/nodejs-hello-world - $ mkdir node_modules - $ touch node_modules/.gitkeep - -- Add ``.gitignore`` for ``node_modules`` content, except ``.gitkeep`` to keep the empty directory, - this is required by the configuration of the ``vagrant_config_override.json`` file as follows: - - .. code-block:: json - - { - - "vm": { - "synced_folders":[{ - "type": "virtual_box", - "host": "workspace/nodejs-hello-world/node_modules", - "guest": "/home/vagrant/workspace/node-js-hello-world/node_modules", - "mount_options": [ - "dmode=777", - "fmode=755" - ] - }] - }, - "provisioners": [{ - "_id": "0", - "json": { - "teracy-dev": { - "proxy": { - "container": { - "enabled": true - } - } - } - } - }], - "plugins": [{ - "_id": "2", - "options": { - "aliases": ["dev.nodejs.teracy.dev", "review.nodejs.teracy.dev" "nodejs.teracy.dev"] - } - }] - } - -- ``$ vagrant reload`` to get it take effect. - -- Re-run the dev container to get it to install the ``npm`` packages again: - -.. code-block:: bash - - $ vagrant ssh - $ ws - $ cd nodejs-hello-world - $ docker-compose restart dev && docker-compose logs -f dev - -Afer this, the ``npm`` packages should be syned into the host ``node_modules`` directory. - -The changes should be like this: https://github.com/acme101/nodejs-hello-world/commit/7876be54139be716d45f200f2a87a1c3985bf81a - - -Remote debugging ----------------- - -See the forwarded debug ports by: - -.. code-block:: bash - - $ docker-compose ps dev - - -You could see something like this: - -.. code-block:: bash - - Name Command State Ports - ------------------------------------------------------------------------------------------------- - nodejshelloworld_dev_1 sh run-dev.sh Up 0.0.0.0:32770->3000/tcp, 0.0.0.0:32769->5858/tcp - - -=> use ``32769`` as the debug port. - -=> use ``teracy.dev`` as the debug host. - -And you follow the links below for remote debugging: - -- https://www.jetbrains.com/help/webstorm/run-debug-configuration-chromium-remote.html -- https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000161104-Can-t-remote-debug-node-inspect -- https://nodejs.org/en/docs/inspector/#chrome-devtools-55 - - -When you scale the dev services into more containers, you can do the same by attaching more debug hosts into the IDE. - - -Create Prod mode ----------------- - -Prod mode will run the Docker image of the app which is used for production deployment. The Docker image -usually contains only the run-time stuff. - -- Create the ``Dockerfile`` file within the ``nodejs-hello-world`` directory with the following content: - - .. code-block:: docker - - FROM node:8.1.3-alpine - - LABEL authors="hoatle " - - RUN mkdir -p /opt/app - - ENV TERM=xterm APP=/opt/app - - # add more arguments from CI to the image so that `$ env` should reveal more info - ARG CI_BUILD_ID - ARG CI_BUILD_REF - ARG CI_REGISTRY_IMAGE - ARG CI_BUILD_TIME - ARG NODE_ENV - - ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \ - CI_BUILD_TIME=$CI_BUILD_TIME NODE_ENV=$NODE_ENV - - WORKDIR $APP - - ADD package.json yarn.lock $APP/ - - RUN yarn install && \ - yarn global add pm2 && \ - yarn cache clean - - ADD . $APP - - CMD ["sh", "run-prod.sh"] - - -- Create the ``docker-compose.prod.yml`` file within the ``nodejs-hello-world`` directory with the - following content: - - .. code-block:: yaml - - version: '3' - - services: - - prod: - build: - context: . - dockerfile: Dockerfile - args: - CI_BUILD_ID: ${CI_BUILD_ID} - CI_BUILD_REF: ${CI_BUILD_REF} - CI_BUILD_TIME: ${CI_BUILD_TIME} - CI_REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE} - NODE_ENV: production - image: ${DOCKER_IMAGE_PROD:-acme101/nodejs-hello-world:develop} - environment: - PORT: 8080 - VIRTUAL_HOST: nodejs.teracy.dev, ~^nodejs\..*\.xip\.io - HTTPS_METHOD: noredirect # support both http and https - env_file: - - .env-common - - .env-prod - ports: - - "8080" - network_mode: bridge - - - -The changes should be like this: -https://github.com/acme101/nodejs-hello-world/commit/a710fda1e9602e4f5e558198c6a3206affb8976e - - -Run on prod mode ----------------- - -Open a new terminal window,, `vagrant ssh` into the ``teracy-dev`` VM to execute the following -commands: - -.. code-block:: bash - - $ vagrant ssh - $ ws - $ cd nodejs-hello-world - $ docker-compose -f docker-compose.prod.yml build prod # to build the prodution Docker image - $ docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d prod && \ - docker-compose -f docker-compose.yml -f docker-compose.prod.yml logs -f prod # to run the production Docker image - - -After that, open: - -- http://nodejs.teracy.dev or https://nodejs.teracy.dev on your host browser to see the app - on the prod mode. -- Check out the VM's :ref:`basic_usage-ip_address` and on any device within your LAN, - open http://nodejs..xip.io or https://nodejs..xip.io to see the web app. - - -Create review mode ------------------- - -Review mode will be used to review the production docker image from other team members. - -This is very simple docker-compose configuration. - -The changes should be like this: https://github.com/acme101/nodejs-hello-world/commit/1f7d0cfdd82435a482834fb45b2203674134cfc2 - - -Run on review mode ------------------- - -For example, we're going to review `hoatle/nodejs-hello-world:feature-1` Docker image. - -Open a new terminal window,, ``$ vagrant ssh`` into the ``teracy-dev`` VM to execute the following -commands: - -.. code-block:: bash - - $ vagrant ssh - $ ws - $ cd nodejs-hello-world - $ DOCKER_IMAGE_REVIEW=hoatle/nodejs-hello-world:feature-1 \ - docker-compose -f docker-compose.yml -f docker-compose.review.yml up -d review && \ - docker-compose -f docker-compose.yml -f docker-compose.review.yml logs -f review - -After that, open: - -- http://review.nodejs.teracy.dev or https://review.nodejs.teracy.dev on your host browser to see - the app on the review mode. -- Check out the VM's :ref:`basic_usage-ip_address` and on any device within your LAN, - open http://review.nodejs..xip.io or https://review.nodejs..xip.io to see the web app. - - -Create CI/CD system -------------------- - -It's required that we should always run CI/CD to automate the build and deployment. In this guide, -we're going to create CI/CD for travis-ci and gitlab-ci. - -For deployment, we're going to deploy on Heroku, Google Container Engine (Kubernertes). - -The changes should be like this: https://github.com/acme101/nodejs-hello-world/commit/ca822a679691de619200e7cd2a0a5d946e5045ae - -To get the most up-to-date and more information, please checkout the README.md file from the -project https://github.com/acme101/nodejs-hello-world - -We can deploy the app on GKE (Google Container Engine) and Heroku by default. - -We deploy and keep the app on Heroku at: https://develop-acme101-nhw.herokuapp.com/ - - -Summary -------- - -Congratulations, we've created a basic hello world Node.js app with Docker workflow, CI/CD system on -the ``teracy-dev``. These are the current best practices to work with ``teracy-dev``, we can apply -these best practices to different types of projects and stacks. diff --git a/docs/objective_c_training.rst b/docs/objective_c_training.rst deleted file mode 100644 index e3c8ec68..00000000 --- a/docs/objective_c_training.rst +++ /dev/null @@ -1,2 +0,0 @@ -Objective C Training -==================== \ No newline at end of file diff --git a/docs/php_dev_guide.rst b/docs/php_dev_guide.rst deleted file mode 100644 index 5929ee75..00000000 --- a/docs/php_dev_guide.rst +++ /dev/null @@ -1,10 +0,0 @@ -PHP Development Guide -===================== - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/php_dev_guide.html diff --git a/docs/python_dev_guide.rst b/docs/python_dev_guide.rst deleted file mode 100644 index 95f90f4a..00000000 --- a/docs/python_dev_guide.rst +++ /dev/null @@ -1,10 +0,0 @@ -Python Development Guide -======================== - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/python_dev_guide.html diff --git a/docs/ruby_dev_guide.rst b/docs/ruby_dev_guide.rst deleted file mode 100644 index 59096f8e..00000000 --- a/docs/ruby_dev_guide.rst +++ /dev/null @@ -1,10 +0,0 @@ -Ruby Development Guide -====================== - -.. warning:: - - This page will be cleaned up by the next version of teracy-dev: v0.6.0 - -We're leveraging Docker workflow since v0.5.0 and this feature is not available. - -This feature is available at http://dev.teracy.org/docs/0.4.2/ruby_dev_guide.html diff --git a/docs/teracy_dev_development.rst b/docs/teracy_dev_development.rst deleted file mode 100644 index 52e28861..00000000 --- a/docs/teracy_dev_development.rst +++ /dev/null @@ -1,228 +0,0 @@ -teracy-dev Development -====================== - -We use ``teracy-dev`` to develop ``teracy-dev``, and use `teracy/dev:dev_develop` Docker image with all development runtime to execute Rake tasks. - - -Project Setup -------------- - -Please follow the document at https://github.com/teracyhq/dev-setup/blob/develop/README.md to set up teracy-dev and dev-setup. - -Please follow the document at https://github.com/teracyhq/dev/tree/develop/dev-setup/README.md#setting-up-teracy-dev-setup to set up ``dev`` project. - -Get Docker image `teracy/dev:dev_develop` to execute rake tasks - -.. code-block:: bash - - $ cd ~/teracy-dev - $ vagrant ssh - $ ws - $ cd workspace/dev - $ docker-compose pull - - -CI Setup --------- - -Please follow the document at https://github.com/teracyhq/dev/tree/develop/dev-setup/README.md#travis-ci-configuration to set up CI system on travis-ci.org : - - -Rake Tasks ----------- - -- ``$ rake`` or ``$ rake list`` to list all `Rake` tasks. - -.. code-block:: bash - - $ docker-compose run --rm dev rake list - -You will see similiar like this: - -.. code-block:: bash - - Creating network "dev_default" with the default driver - Tasks: - - berks_install - - berks_upload - - build - - check - - chefspec - - default - - foodcritic - - knife_test - - list - - new_cookbook - - -- ``$ rake build`` to check code style and run tests. - -.. code-block:: bash - - $ docker-compose run --rm dev rake build - -You will see something similar to this: - -.. code-block:: bash - - bundle exec knife cookbook test -a -c test/knife.rb - WARNING: DEPRECATED: Please use ChefSpec or Rubocop to syntax-check cookbooks. - Running syntax check on teracy-dev - Validating ruby files - Validating templates - bundle exec foodcritic -I test/foodcritic/* -f any main-cookbooks - - bundle exec rspec main-cookbooks - No examples found. - - - Finished in 0.00132 seconds (files took 0.04576 seconds to load) - 0 examples, 0 failures - - -- ``$ rake berks_install`` to install vendor cookbooks with Berkshelf_. - -.. code-block:: bash - - $ docker-compose run --rm dev rake berks_install - -You will see something similar to this: - -.. code-block:: bash - - bundle exec berks vendor vendor-cookbooks - Resolving cookbook dependencies... - Fetching cookbook index from https://supermarket.chef.io... - Installing compat_resource (12.19.0) - Installing docker (2.15.6) - Installing docker_compose (0.1.1) - Installing magic_shell (1.0.0) - Installing vim (2.0.2) - Vendoring compat_resource (12.19.0) to vendor-cookbooks/compat_resource - Vendoring docker (2.15.6) to vendor-cookbooks/docker - Vendoring docker_compose (0.1.1) to vendor-cookbooks/docker_compose - Vendoring magic_shell (1.0.0) to vendor-cookbooks/magic_shell - Vendoring vim (2.0.2) to vendor-cookbooks/vim - - -Build teracy/dev Docker image ------------------------------ - -When we update the development runtime (for example, change Gemfile or Dockerfile-dev), we need to -build the image with: - -.. code-block:: bash - - $ docker-compose build - - -Base Boxes ----------- - -We're going to use Bento_ to build base boxes. - -#. `Virtualbox` Installation: - - You could install any versions of Virtualbox that matches the host machine. - - .. code-block:: bash - - $ cd /tmp - $ wget http://download.virtualbox.org/virtualbox/5.1.10/virtualbox-5.1_5.1.10-112026~Ubuntu~xenial_amd64.deb - $ sudo dpkg -i virtualbox-5.1_5.1.10-112026~Ubuntu~xenial_amd64.deb - $ sudo apt-get install -f -y - - Note: You may encounter some errors. Do not worry, you should install the missing dependencies. After installing, run `/sbin/vboxconfig` as root. - - After that, ``$ VBoxManage --version`` should print out something like: - - .. code-block:: bash - - $ VBoxManage --version - 5.1.10r112026 - -#. `Packer` Installation - - .. code-block:: bash - - $ ws - $ mkdir packer - $ cd packer - $ wget https://releases.hashicorp.com/packer/1.1.0/packer_1.1.0_linux_amd64.zip - $ sudo apt-get install unzip -f -y - $ unzip packer_1.1.0_linux_amd64.zip - $ echo 'export PATH=~/workspace/packer:$PATH' | sudo tee --append ~/.bash_profile - $ source ~/.bash_profile - - After that, ``$ packer version`` should print out something like: - - .. code-block:: bash - - $ packer version - Packer v1.1.0 - -#. `Bento` Repository Clone - - .. code-block:: bash - - $ ws - $ git clone https://github.com/chef/bento.git - $ cd bento - - Note: You may encounter some errors about `public key`. Do not worry, you should add the RSA key to your github and clone the project again. - -#. Base Boxes Build - - .. tip:: - - This is for developers only. Users should just use provided base boxes instead of - building base boxes from scratch. - - .. warning:: - Building from "headless" mode is not recommended, it should be used only for ci-system. - - We're going to build `ubuntu-16.04-amd64.json` base box as an example. - - We're working on a headless VM so you need to add ``headless`` option to the json file by - openning any .json files and append ``"headless":true,`` before ``"boot_wait: "10s",`` line. - - and then: - - .. code-block:: bash - - $ ws - $ cd bento - $ packer build -only=virtualbox-iso ubuntu-16.04-amd64.json - - After that `Packer` will download the Ubuntu iso files and install, package a vagrant base box for - us to use. - - - We should store and share iso files somewhere to save time from downloading iso files then - put it under `~/workspace/bento/isos/`. - - For example, you put `ubuntu-16.04.3-server-amd64.iso` file under `~/workspace/bento/isos/ubuntu/16.04` - and you can use the mirror like: - - .. code-block:: bash - - $ packer build -var="mirror=/home/vagrant/workspace/bento/isos/ubuntu" -only=virtualbox-iso ubuntu-16.04-amd64.json - - It will take a while for the base box to be completed. The base boxe should be available under - `~/workspace/bento/definitions` path. - - -References ----------- - -- http://bundler.io/ -- https://www.chef.io/ -- http://berkshelf.com/ -- https://www.virtualbox.org/ -- https://packer.io/ -- http://chef.github.io/bento/ -- https://github.com/boxcutter - - -.. _Berkshelf: http://berkshelf.com/ -.. _Bento: http://chef.github.io/bento/ diff --git a/environment.sh b/environment.sh deleted file mode 100755 index f16a166d..00000000 --- a/environment.sh +++ /dev/null @@ -1,10 +0,0 @@ -# change to a node accordingly -export OPSCODE_USER="hoatle" -export OPSCODE_ORGNAME="teracy" -export KNIFE_CLIENT_KEY_FOLDER="$HOME/.chef" -export KNIFE_VALIDATION_KEY_FOLDER="$HOME/.chef" -export KNIFE_CHEF_SERVER="https://api.opscode.com/organizations/$OPSCODE_ORGNAME" -export KNIFE_CACHE_PATH="$HOME/.chef/checksums" -export KNIFE_COOKBOOK_COPYRIGHT="Teracy, Inc." -export KNIFE_COOKBOOK_LICENSE="BSD" -export KNIFE_COOKBOOK_EMAIL="devops@teracy.com" diff --git a/environments/README.md b/environments/README.md deleted file mode 100644 index 854f184d..00000000 --- a/environments/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Requires Chef 0.10.0+. - -This directory is for Ruby DSL and JSON files for environments. For more information see the Chef wiki page: - -http://wiki.opscode.com/display/chef/Environments diff --git a/home/.docker/.gitkeep b/extensions/.gitkeep similarity index 100% rename from home/.docker/.gitkeep rename to extensions/.gitkeep diff --git a/home/.gitkeep b/home/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/provisioner.rb b/lib/provisioner.rb deleted file mode 100644 index 7ff5a7e2..00000000 --- a/lib/provisioner.rb +++ /dev/null @@ -1,583 +0,0 @@ -# provisioner lib for dynamic settings provision from provided config file -# see: https://www.vagrantup.com/docs/provisioning/ - -# TODO(hoatle): should loop over and set the key dynamically - -# https://www.vagrantup.com/docs/provisioning/file.html -private def file_settings(file, config) - file.source = config['source'] - file.destination = config['destination'] -end - -# https://www.vagrantup.com/docs/provisioning/shell.html -private def shell_settings(shell, config) - shell.inline = config['inline'] - shell.path = config['path'] - shell.args = config['args'] - unless config['env'].nil? - shell.env = config['env'] - end - unless config['binary'].nil? - shell.binary = config['binary'] - end - unless config['privileged'].nil? - shell.privileged = config['privileged'] - end - unless config['upload_path'].nil? - #shell.upload_path = config['upload_path'] - end - unless config['keep_color'].nil? - shell.keep_color = config['keep_color'] - end - unless config['powershell_args'].nil? - shell.powershell_args = config['powershell_args'] - end - unless config['powershell_elevated_interactive'].nil? - shell.powershell_elevated_interactive = config['powershell_elevated_interactive'] - end - unless config['md5'].nil? - shell.md5 = config['md5'] - end - unless config['sha1'].nil? - shell.sha1 = config['sha1'] - end -end - - -# https://www.vagrantup.com/docs/provisioning/ansible_common.html -private def ansible_common(ansible, config) - ansible.playbook = config['playbook'] - - unless config['config_file'].nil? - ansible.config_file = config['config_file'] - end - unless config['extra_vars'].nil? - ansible.extra_vars = config['extra_vars'] - end - unless config['galaxy_command'].nil? - ansible.galaxy_command = config['galaxy_command'] - end - unless config['galaxy_role_file'].nil? - ansible.galaxy_role_file = config['galaxy_role_file'] - end - unless config['galaxy_roles_path'].nil? - ansible.galaxy_roles_path = config['galaxy_roles_path'] - end - unless config['groups'].nil? - ansible.groups = config['groups'] - end - unless config['host_vars'].nil? - ansible.host_vars = config['host_vars'] - end - unless config['inventory_path'].nil? - ansible.inventory_path = config['inventory_path'] - end - unless config['limit'].nil? - ansible.limit = config['limit'] - end - unless config['playbook_command'].nil? - ansible.playbook_command = config['playbook_command'] - end - unless config['raw_arguments'].nil? - ansible.raw_arguments = config['raw_arguments'] - end - unless config['skip_tags'].nil? - ansible.skip_tags = config['skip_tags'] - end - unless config['start_at_task'].nil? - ansible.start_at_task = config['start_at_task'] - end - unless config['sudo'].nil? - ansible.sudo = config['sudo'] - end - unless config['sudo_user'].nil? - ansible.sudo_user = config['sudo_user'] - end - unless config['tags'].nil? - ansible.tags = config['tags'] - end - unless config['vault_password_file'].nil? - ansible.vault_password_file = config['vault_password_file'] - end - unless config['verbose'].nil? - ansible.verbose = config['verbose'] - end - -end - -# https://www.vagrantup.com/docs/provisioning/ansible.html -private def ansible_settings(ansible, config) - ansible_common(ansible, config) - unless config['ask_sudo_pass'].nil? - ansible.ask_sudo_pass = config['ask_sudo_pass'] - end - unless config['ask_valt_pass'].nil? - ansible.ask_valt_pass = config['ask_valt_pass'] - end - unless config['force_remote_user'].nil? - ansible.force_remote_user = config['force_remote_user'] - end - unless config['host_key_checking'].nil? - ansible.host_key_checking = config['host_key_checking'] - end - unless config['raw_ssh_args'].nil? - ansible.raw_ssh_args = config['raw_ssh_args'] - end -end - -# https://www.vagrantup.com/docs/provisioning/ansible_local.html -private def ansible_local_settings(ansible, config) - ansible_common(ansible, config) - unless config['install'].nil? - ansible.install = config['install'] - end - unless config['install_mode'].nil? - ansible.install_mode = config['install_mode'].to_sym - end - unless config['provisioning_path'].nil? - ansible.provisioning_path = config['provisioning_path'] - end - unless config['tmp_path'].nil? - ansible.tmp_path = config['tmp_path'] - end - unless config['version'].nil? - ansible.version = config['version'] - end -end - -# https://www.vagrantup.com/docs/provisioning/cfengine.html -private def cfengine_settings(cf, config) - unless config['am_policy_hub'].nil? - cf.am_policy_hub = config['am_policy_hub'] - end - unless config['extra_agent_args'].nil? - cf.extra_agent_args = config['extra_agent_args'] - end - unless config['classes'].nil? - cf.classes = config['classes'] - end - unless config['deb_repo_file'].nil? - cf.deb_repo_file = config['deb_repo_file'] - end - unless config['deb_repo_line'].nil? - cf.deb_repo_file = config['deb_repo_line'] - end - unless config['files_path'].nil? - cf.files_path = config['files_path'] - end - unless config['force_bootstrap'].nil? - cf.force_bootstrap = config['force_bootstrap'] - end - unless config['install'].nil? - install = config['install'] - if !!install == install - # boolean - cf.install = install - else - # string => to_sym - cf.install = install.to_sym - end - end - unless config['mode'].nil? - cf.mode = config['mode'].to_sym - end - unless config['policy_server_address'].nil? - cf.policy_server_address = config['policy_server_address'] - end - unless config['repo_gpg_key_url'].nil? - cf.repo_gpg_key_url = config['repo_gpg_key_url'] - end - unless config['run_file'].nil? - cf.run_file = config['run_file'] - end - unless config['upload_path'].nil? - cf.upload_path = config['upload_path'] - end - unless config['yum_repo_file'].nil? - cf.yum_repo_file = config['yum_repo_file'] - end - unless config['yum_repo_url'].nil? - cf.yum_repo_url = config['yum_repo_url'] - end - unless config['package_name'].nil? - cf.package_name = config['package_name'] - end -end - -# https://www.vagrantup.com/docs/provisioning/chef_common.html -private def chef_common(chef, config) - unless config['binary_path'].nil? - chef.binary_path = config['binary_path'] - end - unless config['binary_env'].nil? - chef.binary_env = config['binary_env'] - end - unless config['install'].nil? - chef.install = config['install'] - end - unless config['installer_download_path'].nil? - chef.installer_download_path = config['installer_download_path'] - end - unless config['log_level'].nil? - chef.log_level = config['log_level'] - end - unless config['product'].nil? - chef.product = config['product'] - end - unless config['channel'].nil? - chef.channel = config['channel'] - end - unless config['version'].nil? - chef.version = config['version'] - end - unless config['arguments'].nil? - chef.arguments = config['arguments'] - end - unless config['attempts'].nil? - chef.attempts = config['attempts'] - end - unless config['custom_config_path'].nil? - chef.custom_config_path = config['custom_config_path'] - end - unless config['encrypted_data_bag_secret_key_path'].nil? - chef.encrypted_data_bag_secret_key_path = config['encrypted_data_bag_secret_key_path'] - end - unless config['environment'].nil? - chef.environment = config['environment'] - end - unless config['formatter'].nil? - chef.formatter = config['formatter'] - end - unless config['http_proxy'].nil? - chef.http_proxy = config['http_proxy'] - end - unless config['http_proxy_user'].nil? - chef.http_proxy_user = config['http_proxy_user'] - end - unless config['http_proxy_pass'].nil? - chef.http_proxy_pass = config['http_proxy_pass'] - end - unless config['no_proxy'].nil? - chef.no_proxy = config['no_proxy'] - end - unless config['json'].nil? - chef.json = config['json'] - end - unless config['node_name'].nil? - chef.node_name = config['node_name'] - end - unless config['provisioning_path'].nil? - chef.provisioning_path = config['provisioning_path'] - end - unless config['run_list'].nil? - chef.run_list = config['run_list'] - end - unless config['file_cache_path'].nil? - chef.file_cache_path = config['file_cache_path'] - end - unless config['file_backup_path'].nil? - chef.file_backup_path = config['file_backup_path'] - end - unless config['verbose_logging'].nil? - chef.verbose_logging = config['verbose_logging'] - end - unless config['enable_reporting'].nil? - chef.enable_reporting = config['enable_reporting'] - end -end - -# https://www.vagrantup.com/docs/provisioning/chef_solo.html -private def chef_solo_settings(chef, config) - chef_common(chef, config) - unless config['cookbooks_path'].nil? - chef.cookbooks_path = config['cookbooks_path'] - end - unless config['roles_path'].nil? - chef.roles_path = config['roles_path'] - end - unless config['roles'].nil? - config['roles'].each do |role| - chef.add_role(role) - end - end - unless config['data_bags_path'].nil? - chef.data_bags_path = config['data_bags_path'] - end -end - -# https://www.vagrantup.com/docs/provisioning/chef_zero.html -private def chef_zero_settings(chef, config) - chef_common(chef, config) - unless config['cookbooks_path'].nil? - chef.cookbooks_path = config['cookbooks_path'] - end - unless config['data_bags_path'].nil? - chef.data_bags_path = config['data_bags_path'] - end - unless config['environments_path'].nil? - chef.environments_path = config['environments_path'] - end - unless config['nodes_path'].nil? - chef.nodes_path = config['nodes_path'] - end - unless config['roles_path'].nil? - chef.roles_path = config['roles_path'] - end - unless config['roles'].nil? - config['roles'].each do |role| - chef.add_role role - end - end - unless config['synced_folder_type'].nil? - config.synced_folder_type = config['synced_folder_type'] - end -end - -# https://www.vagrantup.com/docs/provisioning/chef_client.html -private def chef_client_settings(chef, config) - chef_common(chef, config) - unless config['chef_server_url'].nil? - chef.chef_server_url = config['chef_server_url'] - end - unless config['validation_key_path'].nil? - chef.validation_key_path = config['validation_key_path'] - end - unless config['recipes'].nil? - config['recipes'].each do |recipe| - chef.add_recipe recipe - end - end - unless config['roles'].nil? - config['roles'].each do |role| - chef.add_role role - end - end - unless config['client_key_path'].nil? - chef.client_key_path = config['client_key_path'] - end - unless config['validation_client_name'].nil? - chef.validation_client_name = config['validation_client_name'] - end - unless config['delete_node'].nil? - chef.delete_node = config['delete_node'] - end - unless config['delete_client'].nil? - chef.delete_client = config['delete_client'] - end -end - -# https://www.vagrantup.com/docs/provisioning/chef_apply.html -private def chef_apply_settings(chef, config) - chef_common(chef, config) - unless config['recipe'].nil? - chef.recipe = config['recipe'] - end - unless config['upload_path'].nil? - chef.upload_path = config['upload_path'] - end -end - -# https://www.vagrantup.com/docs/provisioning/docker.html -private def docker_settings(docker, config) - unless config['images'].nil? - docker.images = config['images'] - end - unless config['build_images'].nil? - config['build_images'].each do |build_image| - path = build_image['path'] - args = '' - unless build_image['args'].nil? - args = build_image['args'] - end - docker.build_image path args - end - end - # TODO(hoatle): add support for run -end - -# https://www.vagrantup.com/docs/provisioning/puppet_apply.html -private def puppet_apply(puppet, config) - unless config['binary_path'].nil? - puppet.binary_path = config['binary_path'] - end - unless config['facter'].nil? - puppet.facter = config['facter'] - end - unless config['hiera_config_path'].nil? - puppet.hiera_config_path = config['hiera_config_path'] - end - unless config['manifest_file'].nil? - puppet.manifest_file = config['manifest_file'] - end - unless config['manifest_path'].nil? - puppet.manifest_path = config['manifest_path'] - end - unless config['module_path'].nil? - puppet.module_path = config['module_path'] - end - unless config['environment'].nil? - puppet.environment = config['environment'] - end - unless config['environment_path'].nil? - puppet.environment_path = config['environment_path'] - end - unless config['environment_variables'].nil? - puppet.environment_variables = config['environment_variables'] - end - unless config['options'].nil? - puppet.options = config['options'] - end - unless config['synced_folder_type'].nil? - puppet.synced_folder_type = config['synced_folder_type'] - end - unless config['synced_folder_args'].nil? - puppet.synced_folder_args = config['synced_folder_args'] - end - unless config['temp_dir'].nil? - puppet.temp_dir = config['temp_dir'] - end - unless config['working_directory'].nil? - puppet.working_directory = config['working_directory'] - end -end - -# https://www.vagrantup.com/docs/provisioning/puppet_agent.html -private def puppet_server(puppet, config) - unless config['binary_path'].nil? - puppet.binary_path = config['binary_path'] - end - unless config['client_cert_path'].nil? - puppet.client_cert_path = config['client_cert_path'] - end - unless config['client_private_key_path'].nil? - puppet.client_private_key_path = config['client_private_key_path'] - end - unless config['facter'].nil? - puppet.facter = config['facter'] - end - unless config['options'].nil? - puppet.options = config['options'] - end - unless config['puppet_node'].nil? - puppet.puppet_node = config['puppet_node'] - end - unless config['puppet_server'].nil? - puppet.puppet_server = config['puppet_server'] - end -end - -# https://www.vagrantup.com/docs/provisioning/salt.html -private def salt_settings(salt, config) - unless config['install_master'].nil? - salt.install_master = config['install_master'] - end - unless config['no_minion'].nil? - salt.no_minion = config['no_minion'] - end - unless config['install_syndic'].nil? - salt.install_syndic = config['install_syndic'] - end - unless config['install_type'].nil? - salt.install_type = config['install_type'] - end - unless config['install_args'].nil? - salt.install_args = config['install_args'] - end - unless config['always_install'].nil? - salt.always_install = config['always_install'] - end - unless config['bootstrap_script'].nil? - salt.bootstrap_script = config['bootstrap_script'] - end - unless config['bootstrap_options'].nil? - salt.bootstrap_options = config['bootstrap_options'] - end - unless config['version'].nil? - salt.version = config['version'] - end - unless config['minion_config'].nil? - salt.minion_config = config['minion_config'] - end - unless config['minion_key'].nil? - salt.minion_key = config['minion_key'] - end - unless config['minion_id'].nil? - salt.minion_id = config['minion_id'] - end - unless config['minion_pub'].nil? - salt.minion_pub = config['minion_pub'] - end - unless config['grains_config'].nil? - salt.grains_config = config['grains_config'] - end - unless config['masterless'].nil? - salt.masterless = config['masterless'] - end - unless config['master_config'].nil? - salt.master_config = config['master_config'] - end - unless config['master_key'].nil? - salt.master_key = config['master_key'] - end - unless config['master_pub'].nil? - salt.master_pub = config['master_pub'] - end - unless config['seed_master'].nil? - salt.seed_master = config['seed_master'] - end - unless config['run_highstate'].nil? - salt.run_highstate = config['run_highstate'] - end - unless config['run_overstate'].nil? - salt.run_overstate = config['run_overstate'] - end - unless config['orchestrations'] - salt.orchestrations = config['orchestrations'] - end - unless config['colorize'].nil? - salt.colorize = config['colorize'] - end - unless config['log_level'].nil? - salt.log_level = config['log_level'] - end - unless config['pillars'].nil? - config['pillars'].each do |pillar| - salt.pillar(pillar) - end - end -end - -# the public function to be used -public def provision_settings(type, provision, config) - # puts config - case type - when "file" - file_settings(provision, config) - when "shell" - shell_settings(provision, config) - when "ansible" - ansible_settings(provision, config) - when "ansible_local" - ansible_local_settings(provision, config) - when "cfengine" - cfengine_settings(provision, config) - when "chef_solo" - chef_solo_settings(provision, config) - when "chef_zero" - chef_zero_settings(provision, config) - when "chef_client" - chef_client_settings(provision, config) - when "chef_apply" - chef_apply_settings(provision, config) - when "docker" - docker_settings(provision, config) - when "puppet_apply" - puppet_apply(provision, config) - when "puppet_server" - puppet_server(provision, config) - when "salt" - salt_settings(provision, config) - else - puts red("no matching config type for: #{type}") - end -end diff --git a/lib/teracy-dev.rb b/lib/teracy-dev.rb new file mode 100644 index 00000000..85f1bd4a --- /dev/null +++ b/lib/teracy-dev.rb @@ -0,0 +1,30 @@ +# to use teracy-dev, just require it: require 'teracy-dev' +# and it will load all the required modules loaded here + +require_relative 'teracy-dev/logging' +require_relative 'teracy-dev/loader' +require_relative 'teracy-dev/extension/manager' + + +# define public APIs here +module TeracyDev + + BASE_DIR = File.join(File.dirname(__FILE__), '..') + EXTENSION_ENTRY_PATH = ENV['TERACY_DEV_EXTENSION_ENTRY_PATH'] ||= 'workspace/teracy-dev-entry' + + @@logger = TeracyDev::Logging.logger_for(self) + # we can only create one Loader instance and accessible on this only + @@loader = TeracyDev::Loader.new + + def self.register_processor(processor) + @@loader.processorsManager.register(processor) + end + + + def self.register_configurator(configurator) + @@loader.configManager.register(configurator) + end + + @@loader.start + +end diff --git a/lib/teracy-dev/common.rb b/lib/teracy-dev/common.rb new file mode 100644 index 00000000..f35f0db5 --- /dev/null +++ b/lib/teracy-dev/common.rb @@ -0,0 +1,20 @@ +module TeracyDev + class Common + def self.colorize(text, color_code) + "\e[#{color_code}m#{text}\e[0m" + end + + def self.red(text) + colorize(text, 31) + end + + def self.yellow(text) + colorize(text, 33) + end + + def self.prompt(message) + print message + return STDIN.gets.chomp + end + end +end diff --git a/lib/teracy-dev/config/configurator.rb b/lib/teracy-dev/config/configurator.rb new file mode 100644 index 00000000..721c09e7 --- /dev/null +++ b/lib/teracy-dev/config/configurator.rb @@ -0,0 +1,34 @@ +require_relative '../logging' + +module TeracyDev + module Config + # the base class for Configurator to extend + class Configurator + def initialize + @logger = TeracyDev::Logging.logger_for(self.class.name) + end + + # configurator must have this method to execute actual configuration + def configure(settings, config, type:) + case type + when 'common' + configure_common(settings, config) + when 'node' + configure_node(settings, config) + end + end + + protected + # sub class should override this + def configure_common(settings, config) + + end + + # sub class should override this + def configure_node(settings, config) + + end + + end + end +end diff --git a/lib/teracy-dev/config/manager.rb b/lib/teracy-dev/config/manager.rb new file mode 100644 index 00000000..110f3e29 --- /dev/null +++ b/lib/teracy-dev/config/manager.rb @@ -0,0 +1,39 @@ +require_relative '../logging' + +module TeracyDev + module Config + # Manage the vagrant configuration from the provided settings hash object + class Manager + @@instance = nil + + def initialize + if !!@@instance + raise "TeracyDev::Processors::Manager can only be initialized once" + end + @@instance = self + + @logger = TeracyDev::Logging.logger_for(self.class.name) + @configurators = [] + end + + def register(configurator) + if !configurator.respond_to?(:configure) + @logger.warn("configurator #{configurator} must implement configure method, ignored") + return + end + @configurators << configurator + @logger.debug("configurator: #{configurator} registered") + end + + + def configure(settings, config, type:) + @logger.debug("configure #{type}: #{config} with #{settings}") + + @configurators.each do |configurator| + configurator.configure(settings, config, type: type) + end + end + + end + end +end diff --git a/lib/teracy-dev/extension/manager.rb b/lib/teracy-dev/extension/manager.rb new file mode 100644 index 00000000..87e730e6 --- /dev/null +++ b/lib/teracy-dev/extension/manager.rb @@ -0,0 +1,84 @@ +module TeracyDev + module Extension + class Manager + + def self.manifest(extension) + lookup_path = File.join(TeracyDev::BASE_DIR, extension['path']['lookup'] || 'extensions') + path = File.join(lookup_path, extension['path']['extension']) + manifest_path = File.join(path, 'manifest.yaml') + return YAML.load(File.new(manifest_path)) + end + + def initialize + @logger = Logging.logger_for(self.class.name) + end + + def install(extensions) + @logger.debug("install: #{extensions}") + extensions.each do |extension| + sync(extension) + validate(extension) + end + end + + private + + def sync(extension) + return if extension['enabled'] != true + lookup_path = File.join(TeracyDev::BASE_DIR, extension['path']['lookup'] || 'extensions') + path = File.join(lookup_path, extension['path']['extension']) + git = extension['location']['git'] # maybe we'll support for protocols + branch = extension['location']['tag'] || extension['location']['branch'] + ref = extension['location']['ref'] # TODO: support sync to a specific revision + + @logger.debug("path: #{path}") + + if File.exist? path + # TODO: make sure the extention is always at the correct latest state + # up to date branch; up to date tag, etc. + else + # sync bases on the location specification + if git != nil + if Vagrant::Util::Which.which('git') == nil + @logger.error("git is not avaiable") + abort + end + Dir.chdir(lookup_path) do + @logger.info("cd #{lookup_path} && git clone #{git}") + system("git clone #{git}") + end + + Dir.chdir(path) do + @logger.info("cd #{path} && git checkout #{branch}") + system("git checkout #{branch}") + end + end + end + end + + def validate(extension) + return if extension['enabled'] != true + manifest = Manager.manifest(extension) + + if !Util.exist?(manifest['name']) or !Util.exist?(manifest['version']) + @logger.error("The extension manifest's name and version must be defined: #{manifest}, #{extension}") + abort + end + # check the version requirement + if !Util.require_version_valid?(manifest['version'], extension['require_version']) + @logger.error("`#{extension['require_version']}` is required, but current `#{manifest['version']}`: #{extension}") + @logger.error("The current extension version must be updated to satisfy the requirements above") + abort + end + + # check if teracy-dev version satisfies the manifest['target'] if specified + if Util.exist?(manifest['target']) and !Util.require_version_valid?(TeracyDev::VERSION, manifest['target']) + @logger.error("teracy-dev's current version: #{TeracyDev::VERSION}") + @logger.error("this extension requires teracy-dev version: #{manifest['target']} (#{extension})") + abort + end + end + + end + end +end diff --git a/lib/teracy-dev/loader.rb b/lib/teracy-dev/loader.rb new file mode 100644 index 00000000..b2173f64 --- /dev/null +++ b/lib/teracy-dev/loader.rb @@ -0,0 +1,103 @@ +require 'yaml' + +require_relative 'logging' +require_relative 'plugin' +require_relative 'util' +require_relative 'version' +require_relative 'processors/manager' +require_relative 'config/manager' +require_relative 'settings/manager' + +module TeracyDev + class Loader + @@instance = nil + + attr_reader :processorsManager, :configManager, :settings + + def initialize + if !!@@instance + raise "TeracyDev::Loader can only be initialized once" + end + @@instance = self + @logger = Logging.logger_for(self.class.name) + end + + def start + @processorsManager = Processors::Manager.new + @configManager = Config::Manager.new + @settings = build_settings().freeze + require_teracy_dev_version(settings['teracy-dev']['require_version']) + configure_vagrant(settings) + end + + private + + def build_settings + extension_entry_path = File.join(TeracyDev::BASE_DIR, TeracyDev::EXTENSION_ENTRY_PATH) + settingsManager = Settings::Manager.new + settings = settingsManager.build_settings(extension_entry_path) + load_extension_entry_files(settings) + settings = process(settings) + # updating nodes here so that processors have change to adjust nodes by adjusting default + # create nodes by overrides each node with the default + @logger.debug("settings: #{settings}") + settings["nodes"].each_with_index do |node, index| + settings["nodes"][index] = Util.override(settings['default'], node) + end + @logger.debug("final: #{settings}") + settings + end + + + def load_extension_entry_files(settings) + @logger.debug("load_extension_entry_files: #{settings}") + extensions = settings['teracy-dev']['extensions'] ||= [] + extensions.each do |extension| + next if extension['enabled'] != true + lookup_path = File.join(TeracyDev::BASE_DIR, extension['path']['lookup'] || 'extensions') + path = File.join(lookup_path, extension['path']['extension']) + entry_file_path = File.join(path, 'teracy-dev-ext.rb') + @logger.debug("load_extension_entry_files: entry_file_path: #{entry_file_path}") + if File.exist? entry_file_path + Util.load_file_path(entry_file_path) + else + @logger.debug("load_extension_entry_files: #{entry_file_path} does not exist, ignored.") + end + end + end + + + def process(settings) + @processorsManager.process(settings) + end + + def require_teracy_dev_version(*requirements) + if !Util.require_version_valid?(TeracyDev::VERSION, *requirements) + @@logger.error("teracy-dev's current version: #{VERSION}") + @@logger.error("`#{requirements}` is required, make sure to update teracy-dev to satisfy the requirements.") + abort + end + end + + def configure(settings, config, type:) + @configManager.configure(settings, config, type: type) + end + + + def configure_vagrant(settings) + Vagrant.configure("2") do |common| + + configure(settings, common, type: 'common') + + settings['nodes'].each do |node_settings| + primary = node_settings['primary'] ||= false + autostart = node_settings['autostart'] === false ? false : true + common.vm.define node_settings['name'], primary: primary, autostart: autostart do |node| + configure(node_settings, node, type: 'node') + end + end + end + end + + end +end diff --git a/lib/teracy-dev/logging.rb b/lib/teracy-dev/logging.rb new file mode 100644 index 00000000..740f9a31 --- /dev/null +++ b/lib/teracy-dev/logging.rb @@ -0,0 +1,47 @@ +require 'logger' + +require_relative 'common' + +module TeracyDev + class Logging + # Use a hash class-ivar to cache a unique Logger per class: + @@loggers = {} + + def self.logger_for(classname) + @@loggers[classname] ||= _configure_logger_for(classname) + end + + def self._configure_logger_for(classname) + logger = Logger.new(STDOUT) + logger.progname = classname + log_level = ENV['LOG_LEVEL'] ||= "info" + + case log_level + when "unknown" + logger.level = Logger::UNKNOWN + when "fatal" + logger.level = Logger::FATAL + when "error" + logger.level = Logger::ERROR + when "warn" + logger.level = Logger::WARN + when "info" + logger.level = Logger::INFO + when "debug" + logger.level = Logger::DEBUG + end + + logger.formatter = proc do |severity, datetime, progname, msg| + msg = "[#{progname}][#{severity}]: #{msg}\n\n" + case severity + when "UNKNOWN", "FATAL", "ERROR" + msg = TeracyDev::Common.red(msg) + when "WARN" + msg = TeracyDev::Common.yellow(msg) + end + puts msg + end + logger + end + end +end diff --git a/lib/teracy-dev/plugin.rb b/lib/teracy-dev/plugin.rb new file mode 100644 index 00000000..b8318b6a --- /dev/null +++ b/lib/teracy-dev/plugin.rb @@ -0,0 +1,41 @@ +require_relative 'logging' +require_relative 'util' + +module TeracyDev + class Plugin + # install or uninstall plugins bases on the plugins config + def self.sync(plugins) + logger = TeracyDev::Logging.logger_for('Plugin') + plugins ||= [] + plugin_manager = Vagrant::Plugin::Manager.instance + installed_plugins = plugin_manager.installed_plugins + + # reload_required when any plugin is installed/uninstalled + reload_required = false + + plugins.each do |plugin| + + if !installed_plugins.has_key?(plugin['name']) and plugin['state'] == 'installed' + logger.info("installing plugin: #{plugin}") + plugin_manager.install_plugin(plugin['name'], Util.symbolize(plugin)) + reload_required = true + end + + if installed_plugins.has_key?(plugin['name']) and plugin['state'] == 'uninstalled' + logger.info("uninstalling plugin: #{plugin['name']}") + plugin_manager.uninstall_plugin(plugin['name']) + reload_required = true + end + end + + if reload_required + logger.info("reloading...") + exec "vagrant #{ARGV.join(" ")}" + end + end + + def self.installed?(plugin_name) + return Vagrant.has_plugin?(plugin_name) + end + end +end diff --git a/lib/teracy-dev/processors/manager.rb b/lib/teracy-dev/processors/manager.rb new file mode 100644 index 00000000..79bf40ab --- /dev/null +++ b/lib/teracy-dev/processors/manager.rb @@ -0,0 +1,46 @@ +require_relative '../logging' + +module TeracyDev + module Processors + class Manager + @@instance = nil + + def initialize + if !!@@instance + raise "TeracyDev::Processors::Manager can only be initialized once" + end + @@instance = self + + @logger = Logging.logger_for(self.class.name) + @processors = [] + + end + + def register(processor) + if !processor.respond_to?(:process) + @logger.warn("processor #{processor} must implement process method, ignored") + return + end + @processors << processor + @logger.debug("processor: #{processor} registered") + end + + # run the pipelines + def process(settings) + @logger.debug("start processing: #{settings}") + + @processors.each do |processor| + result = processor.process(settings) + if !result + @logger.warn("invalid result from #{processor}, ignored") + next + end + settings = result + end + + settings + end + + end + end +end diff --git a/lib/teracy-dev/processors/processor.rb b/lib/teracy-dev/processors/processor.rb new file mode 100644 index 00000000..6dedf1cb --- /dev/null +++ b/lib/teracy-dev/processors/processor.rb @@ -0,0 +1,18 @@ +require_relative '../logging' + +module TeracyDev + module Processors + # the base class for Processor to extend + class Processor + def initialize + @logger = TeracyDev::Logging.logger_for(self.class.name) + end + + # processor must implement this to execute actual configuration + def process(settings) + settings + end + + end + end +end diff --git a/lib/teracy-dev/settings/manager.rb b/lib/teracy-dev/settings/manager.rb new file mode 100644 index 00000000..b87cd27a --- /dev/null +++ b/lib/teracy-dev/settings/manager.rb @@ -0,0 +1,82 @@ +require 'yaml' + +require_relative '../logging' +require_relative '../util' +require_relative '../extension/manager' + +module TeracyDev + module Settings + class Manager + + @@instance = nil + + def initialize + if !!@@instance + raise "TeracyDev::Settings::Manager can only be initialized once" + end + @@instance = self + @logger = Logging.logger_for(self.class.name) + @extensionManager = Extension::Manager.new + end + + # build teracy-dev, entry extension and extensions setting levels + # then override: entry extension => extensions => teracy-dev + # the latter extension will override the former one to build extensions settings + def build_settings(entry_dir_path) + + @logger.debug("build_settings: #{entry_dir_path}") + teracy_dev_settings = build_teracy_dev_settings() + entry_settings = build_entry_settings(entry_dir_path) + # we use extensions config from entry overriding teracy-dev only to install and validate + entry_extensions = Util.override(teracy_dev_settings, entry_settings)['teracy-dev']['extensions'] + @logger.debug("build_settings: entry_extensions: #{entry_extensions}") + @extensionManager.install(entry_extensions) + + extensions_settings = build_extensions_settings(entry_extensions) + + settings = Util.override(teracy_dev_settings, extensions_settings) + @logger.debug("override(teracy_dev_settings, extensions_settings): #{settings}") + + settings = Util.override(settings, entry_settings) + @logger.debug("override(settings, entry_settings): #{settings}") + settings + end + + private + + def build_teracy_dev_settings() + config_file_path = File.join(File.dirname(__FILE__), '../../../config.yaml') + settings = Util.load_yaml_file(config_file_path) + @logger.debug("build_teracy_dev_settings: #{settings}") + settings + end + + + def build_entry_settings(lookup_dir) + config_default_file_path = File.join(lookup_dir, 'config_default.yaml') + settings = Util.build_settings_from(config_default_file_path) + @logger.debug("build_entry_settings: #{settings}") + settings + end + + + def build_extensions_settings(extensions) + @logger.debug("build_extensions_settings: extensions: #{extensions}") + extensions_settings = [] + extensions.each do |extension| + next if extension['enabled'] != true + lookup_path = File.join(TeracyDev::BASE_DIR, extension['path']['lookup'] || 'extensions') + path = File.join(lookup_path, extension['path']['extension']) + extensions_settings << Util.build_settings_from(File.join(path, 'config_default.yaml')) + end + settings = {} + extensions_settings.reverse_each do |extension_settings| + settings = Util.override(extension_settings, settings) + end + @logger.debug("build_extensions_settings: settings: #{settings}") + settings + end + + end + end +end diff --git a/lib/teracy-dev/util.rb b/lib/teracy-dev/util.rb new file mode 100644 index 00000000..613a6bb0 --- /dev/null +++ b/lib/teracy-dev/util.rb @@ -0,0 +1,225 @@ +require_relative 'logging' + +module TeracyDev + class Util + @@logger = TeracyDev::Logging.logger_for(self) + + # check if a value exists (not nil and not empty if is a string) + def self.exist?(value) + exist = false + if !value.nil? + if value.instance_of? String + exist = !value.empty? + end + exist = true + end + exist + end + + + # find the extension lookup_path by its name from the provided settings + def self.extension_lookup_path(settings, extension_name) + @@logger.debug("settings: #{settings}") + extensions = settings['teracy-dev']['extensions'] ||= [] + + extensions.each do |ext| + manifest = Extension::Manager.manifest(ext) + if manifest['name'] == extension_name + return ext['path']['lookup'] || 'extensions' + end + end + # extension_name not found + return nil + end + + def self.load_yaml_file(file_path) + if File.exist? file_path + # TODO: exception handling + result = YAML.load(File.new(file_path)) + if result == false + @@logger.debug("load_yaml_file: #{file_path} is empty") + result = {} + end + result + else + @@logger.debug("load_yaml_file: #{file_path} does not exist") + {} + end + end + + def self.build_settings_from(default_file_path) + @@logger.debug("build_settings_from default file path: #{default_file_path}") + override_file_path = default_file_path.gsub(/default\.yaml$/, "override.yaml") + default_settings = load_yaml_file(default_file_path) + @@logger.debug("build_settings_from default_settings: #{default_settings}") + override_settings = load_yaml_file(override_file_path) + @@logger.debug("build_settings_from override_settings: #{override_settings}") + settings = Util.override(default_settings, override_settings) + @@logger.debug("build_settings_from final: #{settings}") + settings + end + + # thanks to https://gist.github.com/Integralist/9503099 + def self.symbolize(obj) + return obj.reduce({}) do |memo, (k, v)| + memo.tap { |m| m[k.to_sym] = symbolize(v) } + end if obj.is_a? Hash + + return obj.reduce([]) do |memo, v| + memo << symbolize(v); memo + end if obj.is_a? Array + + obj + end + + # file_path must be absolute path + def self.load_file_path(file_path) + @@logger.debug("load_file_path: #{file_path}") + begin + load file_path + rescue Exception => msg + @@logger.error(msg) + end + end + + # deep_copy an object to make it immutable + # useful for hash object manipulation + def self.deep_copy(o) + Marshal.load(Marshal.dump(o)) + end + + + def self.require_version_valid?(version, *requirements) + @@logger.debug("require_version_valid?: version: #{version}; requirements: #{requirements}") + req = Gem::Requirement.new(*requirements) + req.satisfied_by?(Gem::Version.new(version)) + end + + # teracy-dev hash override algorithm + # override the originalHash object with the sourceHash object + # this method is immutable + # this method is the combination of hash merge with special treatment to array value: + # "_id" is required for every object within the array. + # By introducing "_id" and "_op" meta key, we can override the configuration by its "_id" with its "_op" option ("a" - append, "o" - override, "r" - replace, "d" - delete). + # _id exist => _op="o" by default. _op could be one of [o, r, d] + # _id does not exist => _op="a" by default and only this value can be used. + # _op="a": adding to the end of the array by default. To specify the index to append after, use "_idx" key with the right index (see Array.insert(index, value) Ruby API to use the right index value) + # We also support force override the array key with: "r" ("r" - replace) to completely replace the array key, this is useful when we want to replace the array completely + # We also support update by adding more array elements by the key with "_ua_" prefix, this is useful for array objects without "_id_" key. + # for example: + # "_r_synced_folders": [] + # "_ua__ua_aliases": ["dev.teracy.com"] + # This will replace default "synced_folders" with an empty array "[]". + # "_" is reserved for teracy-dev to override the default config. + # This is applied for objects within array only, for JSON object, just use its key to override. + # see: https://github.com/teracyhq/dev/issues/239 + # TODO: refactor this into a new module (merger.rb), currently, maintaining this is a nightmare + def self.override(originHash, sourceHash) + # immutable + originHash = originHash.clone + sourceHash = sourceHash.clone + + sourceHash.each do |key, value| + replaced_key = key.to_s.sub(/_u?[ra]_/, '') + + if !originHash.has_key?(replaced_key) + if value.class.name == 'Hash' + originHash[key] = {} + elsif value.class.name == 'Array' + originHash[replaced_key] = [] + end + end + + # replace + if value.class.name == 'Array' + if (key.start_with?('_r_') || key.start_with?('_a_') || key.start_with?('_ua_')) && originHash.has_key?(key) + originHash[replaced_key] = originHash[key].clone + originHash.delete(key) + end + + if (key.start_with?('_r_') || key.start_with?('_a_') || key.start_with?('_ua_')) && !originHash.has_key?(replaced_key) + originHash[replaced_key] = [] + key = replaced_key + else + if key.start_with?('_r_') + originHash[replaced_key] = [] + key = replaced_key + elsif key.start_with?('_a_') + value = originHash[replaced_key].concat(sourceHash[key]) + key = replaced_key + elsif key.start_with?('_ua_') + value = (originHash[replaced_key].concat(sourceHash[key])).uniq + key = replaced_key + end + end + end + + if value.class.name == 'Hash' + originHash[key] = override(originHash[key], sourceHash[key]) + elsif value.class.name == 'Array' + originHash_value = originHash[key].clone || [] + if value[0].class.name != 'Hash' + originHash_value = value + else + value.map! do |val| + if val.class.name == 'Hash' + id_existing = false + originHash[key] ||= [] + originHash[key].each do |val1| + if val1['_id'] == val['_id'] + id_existing = true + break + end + end + if id_existing == false + if !val['_op'].nil? and val['_op'] != 'a' + # warnings + @@logger.warn("_op = #{val['_op']} is invalid for non-existing id: #{val}") + end + operator = 'a' + elsif val['_op'].nil? + operator = 'o' + else + operator = val['_op'] + end + + if operator == 'a' + if val['_idx'].nil? + originHash_value.push(override({}, val)) + else + originHash_value.insert(val['_idx'], override({}, val)) + end + elsif operator == 'o' + originHash_value.map! do |val2| + if val2['_id'] == val['_id'] + val2 = override(val2, val) + end + val2 + end + elsif operator == 'r' + originHash_value.map! do |val3| + if val3['_id'] == val['_id'] + val3 = override({}, val) + end + val3 + end + elsif operator == 'd' + originHash_value.delete_if {|val4| val4['_id'] == val['_id'] } + end + else + originHash_value = value + end + val + end + end + originHash[key] = originHash_value + + else + # merge key here + originHash[key] = value + end + end + return originHash + end + end +end diff --git a/lib/teracy-dev/version.rb b/lib/teracy-dev/version.rb new file mode 100644 index 00000000..bf464fbe --- /dev/null +++ b/lib/teracy-dev/version.rb @@ -0,0 +1,4 @@ +module TeracyDev + # sermver format + VERSION = '0.6.0-a1-SNAPSHOT' +end diff --git a/lib/utility.rb b/lib/utility.rb deleted file mode 100644 index 844037df..00000000 --- a/lib/utility.rb +++ /dev/null @@ -1,156 +0,0 @@ -# Utility functions -def overrides(obj1, obj2) - obj2.each do |key, value| - replaced_key = key.to_s.sub(/_u?[ra]_/, '') - - if !obj1.has_key?(replaced_key) - if value.class.name == 'Hash' - obj1[key] = {} - elsif value.class.name == 'Array' - obj1[replaced_key] = [] - end - end - - # replace - if value.class.name == 'Array' - if (key.start_with?('_r_') || key.start_with?('_a_') || key.start_with?('_ua_')) && obj1.has_key?(key) - obj1[replaced_key] = obj1[key].clone - obj1.delete(key) - end - - if (key.start_with?('_r_') || key.start_with?('_a_') || key.start_with?('_ua_')) && !obj1.has_key?(replaced_key) - obj1[replaced_key] = [] - key = replaced_key - else - if key.start_with?('_r_') - obj1[replaced_key] = [] - key = replaced_key - elsif key.start_with?('_a_') - value = obj1[replaced_key].concat(obj2[key]) - key = replaced_key - elsif key.start_with?('_ua_') - value = (obj1[replaced_key].concat(obj2[key])).uniq - key = replaced_key - end - end - end - - if value.class.name == 'Hash' - obj1[key] = overrides(obj1[key], obj2[key]) - elsif value.class.name == 'Array' - obj1_value = obj1[key].clone - if value[0].class.name != 'Hash' - obj1_value = value - else - value.map! do |val| - if val.class.name == 'Hash' - id_existing = false - obj1[key].each do |val1| - if val1['_id'] == val['_id'] - id_existing = true - break - end - end - if id_existing == false - if !val['_op'].nil? and val['_op'] != 'a' - # warnings - puts yellow("_op = #{val['_op']} is invalid for non-existing id: #{val}") - end - val['_op'] = 'a' - elsif val['_op'].nil? - val['_op'] = 'o' - end - - if val['_op'] == 'a' - if val['_idx'].nil? - obj1_value.push(overrides({}, val)) - else - obj1_value.insert(val['_idx'], overrides({}, val)) - end - elsif val['_op'] == 'o' - obj1_value.map! do |val2| - if val2['_id'] == val['_id'] - val2 = overrides(val2, val) - end - val2 - end - elsif val['_op'] == 'r' - obj1_value.map! do |val3| - if val3['_id'] == val['_id'] - val3 = overrides({}, val) - end - val3 - end - elsif val['_op'] == 'd' - obj1_value.delete_if {|val4| val4['_id'] == val['_id'] } - end - else - obj1_value = value - end - val - end - end - obj1[key] = obj1_value - - else - # merge key here - obj1[key] = value - # puts yellow('ADDED: try to override non-existing key: ' + key + ' with value: ' + value.to_s) - end - end - #puts JSON.pretty_generate(obj1) - return obj1 -end - -def colorize(text, color_code) - "\e[#{color_code}m#{text}\e[0m" -end - -def get_default_nic() - default_interface = "" - if Vagrant::Util::Platform.windows? - default_interface = %x[wmic.exe nic where "NetConnectionStatus=2" get NetConnectionID | more +1] - default_interface = default_interface.strip - elsif Vagrant::Util::Platform.linux? - default_interface = %x[route | grep '^default' | grep -o '[^ ]*$'] - default_interface = default_interface.strip - elsif Vagrant::Util::Platform.darwin? - nicName = %x[route -n get 8.8.8.8 | grep interface | awk '{print $2}'] - default_interface = nicName.strip - nicString = %x[networksetup -listnetworkserviceorder | grep 'Hardware Port' | grep #{default_interface} | awk -F'[:,]' '{print $2}'] - extension = nicString.strip == "Wi-Fi" ? " (AirPort)" : "" - default_interface = default_interface + ': ' + nicString.strip + extension - end - return default_interface -end - -def red(text); colorize(text, 31); end -def yellow(text); colorize(text, 33); end - -def prompt(message) - print message - return STDIN.gets.chomp -end - -# thanks to https://github.com/devopsgroup-io/vagrant-hostmanager/issues/121#issuecomment-69050265 - -def read_ip_address(machine) - command = "LANG=en ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'" - result = "" - - # $logger.info "Processing #{ machine.name } ... " - - begin - # sudo is needed for ifconfig - machine.communicate.sudo(command) do |type, data| - result << data if type == :stdout - end - # $logger.info "Processing #{ machine.name } ... success" - rescue - result = "# NOT-UP" - # $logger.info "Processing #{ machine.name } ... not running" - end - - # the second inet is more accurate - result.chomp.split("\n").last -end diff --git a/main-cookbooks/README.md b/main-cookbooks/README.md deleted file mode 100644 index cb77d8eb..00000000 --- a/main-cookbooks/README.md +++ /dev/null @@ -1 +0,0 @@ -store all chef cookbooks and extended-chef cookbooks. \ No newline at end of file diff --git a/main-cookbooks/teracy-dev/.gitkeep b/main-cookbooks/teracy-dev/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/main-cookbooks/teracy-dev/CHANGELOG.md b/main-cookbooks/teracy-dev/CHANGELOG.md deleted file mode 100644 index 2a0fa680..00000000 --- a/main-cookbooks/teracy-dev/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# CHANGELOG for teracy-dev - -This file is used to list changes made in each version of teracy-dev. - -## 0.1.0: - -* Initial release of teracy-dev - -- - - -Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. - -The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/main-cookbooks/teracy-dev/README.md b/main-cookbooks/teracy-dev/README.md deleted file mode 100644 index 85af75bf..00000000 --- a/main-cookbooks/teracy-dev/README.md +++ /dev/null @@ -1,68 +0,0 @@ -teracy-dev Cookbook -=================== -TODO: Enter the cookbook description here. - -e.g. -This cookbook makes your favorite breakfast sandwhich. - -Requirements ------------- -TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. - -e.g. -#### packages -- `toaster` - teracy-dev needs toaster to brown your bagel. - -Attributes ----------- -TODO: List you cookbook attributes here. - -e.g. -#### teracy-dev::default - - - - - - - - - - - - - -
KeyTypeDescriptionDefault
['teracy-dev']['bacon']Booleanwhether to include bacontrue
- -Usage ------ -#### teracy-dev::default -TODO: Write usage instructions for each cookbook. - -e.g. -Just include `teracy-dev` in your node's `run_list`: - -```json -{ - "name":"my_node", - "run_list": [ - "recipe[teracy-dev]" - ] -} -``` - -Contributing ------------- -TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. - -e.g. -1. Fork the repository on Github -2. Create a named feature branch (like `add_component_x`) -3. Write you change -4. Write tests for your change (if applicable) -5. Run the tests, ensuring they all pass -6. Submit a Pull Request using Github - -License and Authors -------------------- -Authors: TODO: List authors diff --git a/main-cookbooks/teracy-dev/attributes/default.rb b/main-cookbooks/teracy-dev/attributes/default.rb deleted file mode 100644 index f684b92f..00000000 --- a/main-cookbooks/teracy-dev/attributes/default.rb +++ /dev/null @@ -1,2 +0,0 @@ -default['docker_machine']['version'] = 'v0.8.2' -default['docker_machine']['command_path'] = '/usr/local/bin/docker-machine' \ No newline at end of file diff --git a/main-cookbooks/teracy-dev/definitions/.gitkeep b/main-cookbooks/teracy-dev/definitions/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/main-cookbooks/teracy-dev/files/default/.gitkeep b/main-cookbooks/teracy-dev/files/default/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/main-cookbooks/teracy-dev/files/default/nginx/certs/README.md b/main-cookbooks/teracy-dev/files/default/nginx/certs/README.md deleted file mode 100644 index 42dc0f3d..00000000 --- a/main-cookbooks/teracy-dev/files/default/nginx/certs/README.md +++ /dev/null @@ -1,20 +0,0 @@ -#Nginx Certs - -This is self signed certificate for development purpose. - -## How to create - -```bash -$ openssl genrsa -des3 -passout pass:x -out default.pass.key 2048 -$ openssl rsa -passin pass:x -in default.pass.key -out default.key -$ openssl req -new -key default.key -out default.csr -$ openssl x509 -req -sha256 -days 1825 -in default.csr -signkey default.key -out default.crt -``` - -The default certificate is used along with https://github.com/jwilder/nginx-proxy to provide -reverse proxy system for Docker applications. - -## References - -- https://devcenter.heroku.com/articles/ssl-certificate-self -- https://github.com/jwilder/nginx-proxy diff --git a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.crt b/main-cookbooks/teracy-dev/files/default/nginx/certs/default.crt deleted file mode 100644 index 5dbf0039..00000000 --- a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.crt +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDnDCCAoQCCQCrpk8p/6UAgDANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMC -Vk4xDjAMBgNVBAgMBUhhbm9pMQ4wDAYDVQQHDAVIYW5vaTEbMBkGA1UECgwSVGVy -YWN5IENvcnBvcmF0aW9uMRQwEgYDVQQLDAtDb3Jwb3JhdGlvbjEPMA0GA1UEAwwG -VGVyYWN5MRwwGgYJKoZIhvcNAQkBFg1ocUB0ZXJhY3kuY29tMB4XDTE3MDIxMTEy -Mjk0MFoXDTE4MDIxMTEyMjk0MFowgY8xCzAJBgNVBAYTAlZOMQ4wDAYDVQQIDAVI -YW5vaTEOMAwGA1UEBwwFSGFub2kxGzAZBgNVBAoMElRlcmFjeSBDb3Jwb3JhdGlv -bjEUMBIGA1UECwwLQ29ycG9yYXRpb24xDzANBgNVBAMMBlRlcmFjeTEcMBoGCSqG -SIb3DQEJARYNaHFAdGVyYWN5LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBALebUzxN0qthDnEG2dKZVKJnrg3j050JCvb2hzgWjoYFrFbnbXuIwr4q -Hqf+S5QI8VCStlTgV1NwaE5gU+qozYwkUtcggd9nUkze2sX5xgpbz3+3WaMtnhNc -QhCv+Esdp62hH9VeQw1rxBExOk66NXZpY+zSHCJDkOpkvHdzrmuMZAucMqgiJDfZ -3OEl5dN7kScdgTSYbtEUX6+cSPckEICWYJ+QB6d3FsIygWtKLYQvFMWXEtK7egCU -ar416Q/cUcuJHlx8WyHfALOEFCFhoeJt63FEY3QJLXJkZjyhp5HE+zWjCmevVfBX -sX4FccmSl5VXrFynPxsVcA1Cz7q0KRECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA -It9+GbE41hdmnBG7OO+n4BjVPcb1dVD8tfzeMuyNnu4lwScr7A2bh6UVMPne9XG8 -NeXmFiudfvgpcQbWAvIn5iA/nz73d9eHrCY4OjJwm3F9mPLjheSvhhmblFMMVTaG -gMfChpoFappMqJQiEEDqpBb/OM0o8Py1fccgGJczyR03ntAEjEyQbA3KVQdu1kFr -YaMN1w8qTnDR6EiqVxn7YS8riygp747NRD+UtC2OtDhbuzFdPSXZXe5VFWTyngJL -iEaDZEAsBiHi6yW0rrytgHKlhtwXC1uPgpuN6tffTjofQYBpKl8tWQkxi5GGlM7e -I7PE5pYnfXv6GcytH9uGAQ== ------END CERTIFICATE----- diff --git a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.csr b/main-cookbooks/teracy-dev/files/default/nginx/certs/default.csr deleted file mode 100644 index aa8a8309..00000000 --- a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.csr +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIC1TCCAb0CAQAwgY8xCzAJBgNVBAYTAlZOMQ4wDAYDVQQIDAVIYW5vaTEOMAwG -A1UEBwwFSGFub2kxGzAZBgNVBAoMElRlcmFjeSBDb3Jwb3JhdGlvbjEUMBIGA1UE -CwwLQ29ycG9yYXRpb24xDzANBgNVBAMMBlRlcmFjeTEcMBoGCSqGSIb3DQEJARYN -aHFAdGVyYWN5LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALeb -UzxN0qthDnEG2dKZVKJnrg3j050JCvb2hzgWjoYFrFbnbXuIwr4qHqf+S5QI8VCS -tlTgV1NwaE5gU+qozYwkUtcggd9nUkze2sX5xgpbz3+3WaMtnhNcQhCv+Esdp62h -H9VeQw1rxBExOk66NXZpY+zSHCJDkOpkvHdzrmuMZAucMqgiJDfZ3OEl5dN7kScd -gTSYbtEUX6+cSPckEICWYJ+QB6d3FsIygWtKLYQvFMWXEtK7egCUar416Q/cUcuJ -Hlx8WyHfALOEFCFhoeJt63FEY3QJLXJkZjyhp5HE+zWjCmevVfBXsX4FccmSl5VX -rFynPxsVcA1Cz7q0KRECAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQApWQk8ie8D -z+4OV3IPHi1ypAas5IJ7UdVqDECxVJGycjfX6ncy7Ancx7ay4L/VgCQ//jC3famy -3MSrJxn5TS3UnpDGmfPA2by+HMgPqXmHkTeQBW5J300YIFwO2tB3l4asLpSpluZE -BesBK0N6InNJQWZQf8tryUn4OEonzDtyWf86/I8gkM4IbwSlrBIJWJOHCadWvT8Q -PWIsE7bynGV9H9rXUeJDwaqMczvzJOVldi/eyi9ZpswpXjA2vXu3DsZHsfYgf587 -TydcK78tDKv+nev0824bhhEPoDeX7UyhRHArrEr8t14USmCMpyBrpayeflpqIJ3S -3B1BVWjSjWPf ------END CERTIFICATE REQUEST----- diff --git a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.key b/main-cookbooks/teracy-dev/files/default/nginx/certs/default.key deleted file mode 100644 index bfbc1bc9..00000000 --- a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAt5tTPE3Sq2EOcQbZ0plUomeuDePTnQkK9vaHOBaOhgWsVudt -e4jCvioep/5LlAjxUJK2VOBXU3BoTmBT6qjNjCRS1yCB32dSTN7axfnGClvPf7dZ -oy2eE1xCEK/4Sx2nraEf1V5DDWvEETE6Tro1dmlj7NIcIkOQ6mS8d3Oua4xkC5wy -qCIkN9nc4SXl03uRJx2BNJhu0RRfr5xI9yQQgJZgn5AHp3cWwjKBa0othC8UxZcS -0rt6AJRqvjXpD9xRy4keXHxbId8As4QUIWGh4m3rcURjdAktcmRmPKGnkcT7NaMK -Z69V8FexfgVxyZKXlVesXKc/GxVwDULPurQpEQIDAQABAoIBAQCUULhwIj1ni0Nr -MimK4alod3A2cC9kzwU4cfTQ7ge7Y6HPoari+5q0mrmg4t6SepbUi28WKRLhqA/a -IB4plKpV5pG0jeHbYU8uIWeAPUAo5fk8JhQWqKbk5MXJTRy5MP9eVqWsajSoBsGf -UbDUH79II+JAT4nCc+oALdfAdoYTATsKv4pqnb24XI4/ix2vrb7mcBLMw19ifaE5 -/JX3vUoH2LL/AhZ9clc1ZmLuhdf49guo0uRshLR2yzV9EO4QCviG/HBlZES+sX6M -c9Y3i7vfo7emLhDxhqyGyXYn0o3UPoPEwNLLaiBNbJwanSxWG2LkLoZQNGzeCy2K -ralFXEtxAoGBAN0OZzoehG9t89aHKZNBDQdSlAJW6ocL5+L74vvk46hPy6ughgGA -74UU1StnQ7EnqtUIP7c4KcAQIJiNdazf+oVhqM41q8APSlnrOaa9m4GXBw1qSR8o -Rupx4w0T9ABPxHwFIqvhha6P7Vnuc8SNlF1boreHUk0kvML7xrML8/LjAoGBANSh -btGv5PaBPI0cfR6LzM1Q23a3+FDZjlfMUaTds4GtwGI2C17qi0Kk9lDACDvg9x86 -5sIadRgt2PtUt3A7wN/h1a14l6aRL9Tix1RJNQBEIYb+2WvfewNHvBFpKc5MDvcP -NbpmiHQZ9w1sl2NKdnTf2ngUUU22Pp+dvgNAc5J7AoGBAIQrxXrRnlvFwUKmxCwA -fBrBvC996nJeowJrmvcDjz8mnt96dkVV42CN6TsvXiEBV7pSWU5ibUwiGGs+QXrg -3Lh9gOHy40NNoSYMaAcTXXRpadUSlK/ldClfeONr57t79j41D9r3V+fctIzN7zg5 -ctkzHiJf7cykR5zJz69kWTMDAoGAAn3hzpNBG6JoEz9COBlrTPyllb6SKmBiSqUa -T9RJRjvDBWOcvoABIcbNHCUj84+vVa5bBetJc/8Vi9xySd5pZDZBSsce/9Szusrt -iw9Qj7A8tFhIM/tqdZ9hlNKmqsQ5aKvE9Wo+Lx4exwl+vKsiuDvnU4Dpcv+vvC8d -Cuy2bgECgYAisSjQTSppkp6OUfGmFMkzWJ7nibYDXLhMEY5Kua5OcAmFANdovQig -rb54ECXYWv6XpzMCNEIAAJ9z7JflxobGKE1K6NfnHuwhKCeWI4Q3d5b4eC8krXi0 -9iRgKhaBo0a4XM3h94EwQI/cczHqZF1jgIH3Vjl3s7a8Xr7Q6maZeQ== ------END RSA PRIVATE KEY----- diff --git a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.pass.key b/main-cookbooks/teracy-dev/files/default/nginx/certs/default.pass.key deleted file mode 100644 index 541fbe1a..00000000 --- a/main-cookbooks/teracy-dev/files/default/nginx/certs/default.pass.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,6298455821AB1F4D - -H/8JyMjZOrxVrcC6mDB4d4qjEgS5dljed0HZroQPtR4I6vKDDKUG4O0dkHHRuG7H -fvFZgy5TD/GtFpT4rfQo8EVX1h3cYpFUE37iWaprbd6B9oT2jiZCRg7wswvt8OQu -fnGrMz2qkuPmdUnXD3dVJ406t8fQieB0ImceV3WiDpqUvGxiFPNWns4EXtHCRs7n -SPBiRFtXZ4i+KHrtNi1dQSLuyHd44lFoysebf3x+uZ7BG9gPj7zWylbqICVOLd// -z4wr69rn/vaEx9gSQEpMLHIPEMjIu14bHeuVRViv/lmYkAn+z8nSUvNU79i8pPKZ -jxnSJRmDm8whMM5o6DJScLl7aB0lJSyyp8NT0LN9gHFxNEA8gYWSB19i9sH9yODb -eslGISYJXfl3q1cCsVXMTHUvfxSOW0O9/6KlQnJmE3QntxnfB7yN+Muqisp4IjCs -e3ym4rX63Q9bnTtu9EohATkGkcO0iYCMt0Y/7IpsZtVmZoi6jieetMwuqp+d5ick -3DjaeD8i7AjVVn7aVjulHS/elU1FnhwNrsl36dO0r9CCtGN956HgKIGoi97dDZSL -tnIPSLikJV1Dd4Cnr6ywqm1rP5DUDOD+6eeF9l43CBeNXE3Dnpm1+0giWWn7bf4T -uApFcoRmQAIFcmZYC26owzUL0muHIomrhvz0g2R5tqSr2oUK2zz2z2w8uu/XjqUk -NrlmRwDmRp/ZibwXgDeQsKJx0DsjDsuU/miuKyLzGppBZTbazf8ONB6zcrHkYRuK -WV8aCsGMZIUFAySyBb56KtPD+50+nDgHvQx/ESqdfVw8LOMlvdMrG15DTYNRxCed -nAHDj99JrQ0VutWVAgfFZVX9o9UWBj8eGzz9+QnMbMeQ7EftkgUh8NtuAmDFR7fL -wGMyeY/W2+y7nkiotPI5ZGjO4iSvLmNJIHdpSx1ClL9etyemAOYA7vSFZ1uMg2Mn -O3fc+Ovg8ViTI7/Sb/j/lJvP0nDwFWhj6+ACIBbpyPjkt8ub2+qD6DDCJignNmGx -DALKD6JIbwKlOCIWAMUiVMFTM5pZsP3g1s2GKHVo9sg9gtqzgH/+S5J8ECGNQ5lO -ujKGNScv5BUEhuYntrrMdI7TgrfYWkxtCA2CYu6bpXVABIakr0JonWTeMwl69xw8 -Et7GHH9KsmvNOMSKO9PUspQb77kLIh1JKJP1QC0UXy+s2awZrwSjr3alJ0UyQmCz -HFt2c/onCq+6cpGFunxraJnvBM864oEoLgo9oJZ0EwEMYR9UfTl4Rc7MmSmoMZzF -y63smQKSnme6Bnw7vINNYYmDFS7U87jkIN8M/wqMUS+19yuxeSHdN/M/HKsti+7B -zxzQr6trsS/X2dO1ieJ/siI6nwDd4F6DKEAA72GdzQVxfyd2Kw+v/DgAnvjELdi5 -lyKpDlob4480yqhbIoKBgJpjQPabah/QCAwoholf5JKHknlEw/z4ghOvaFxVMwvY -QpnrBC+216osCFPZNB2NG1HO3a+D3ze8b75WK1z0mHQPQOl084QjtRxojew4kj0I -cWPj3O3qh4y11akXyoEBlDW2Zyyip6trqtoNVho1UtGdabAQ0g1y166AO2mAkM2s ------END RSA PRIVATE KEY----- diff --git a/main-cookbooks/teracy-dev/libraries/.gitkeep b/main-cookbooks/teracy-dev/libraries/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/main-cookbooks/teracy-dev/libraries/helpers.rb b/main-cookbooks/teracy-dev/libraries/helpers.rb deleted file mode 100644 index 3a1ba542..00000000 --- a/main-cookbooks/teracy-dev/libraries/helpers.rb +++ /dev/null @@ -1,76 +0,0 @@ -module TeracyDev - module Helpers - def db_empty?(host, username, pwd, db_name) - ::Mysql.new(host, username, pwd).select_db(db_name).list_tables().empty? - end - - def db_tbl_exists?(host, username, pwd, db_name, tbl) - querySt = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '#{tbl}'" - ::Mysql.new(host, username, pwd).select_db(db_name).query(querySt).num_rows > 0 - end - - - def db_tbl_empty?(host, username, pwd, db_name, tbl) - m = ::Mysql.new(host, username, pwd, db_name) - m.select_db(db_name).query('SELECT COUNT(*) FROM ' + tbl).fetch_row()[0].to_i < 1 - end - - def db_column_exists?(host, username, pwd, db_name, tbl, colum) - querySt = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '#{tbl}' and COLUMN_NAME = '#{colum}'" - ::Mysql.new(host, username, pwd).select_db(db_name).query(querySt).num_rows > 0 - end - - # Determines if php is installed on a system. - # - # @return [Boolean] - def php_installed? - !which('php').nil? - end - - # Determines if mysql is installed on a system. - # - # @return [Boolean] - def mysql_installed? - !which('mysql').nil? - end - - # Determines if ruby is installed on a system. - # - # @return [Boolean] - def ruby_installed? - !which('ruby').nil? - end - - # Determines if rbenv is installed on a system. - # - # @return [Boolean] - def rbenv_installed? - !which('rbenv').nil? - end - - # Determines if ruby-build is installed on a system. - # - # @return [Boolean] - def ruby_build_installed? - !which('ruby-build').nil? - end - - # Finds a command in $PATH - # - # @return [String, nil] - def which(cmd) - paths = (ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin)) - - paths.each do |path| - possible = File.join(path, cmd) - return possible if File.executable?(possible) - end - - nil - end - end -end - -Chef::Recipe.send(:include, ::TeracyDev::Helpers) -Chef::Resource.send(:include, ::TeracyDev::Helpers) -Chef::Provider.send(:include, ::TeracyDev::Helpers) diff --git a/main-cookbooks/teracy-dev/metadata.rb b/main-cookbooks/teracy-dev/metadata.rb deleted file mode 100644 index 6ecc0a58..00000000 --- a/main-cookbooks/teracy-dev/metadata.rb +++ /dev/null @@ -1,23 +0,0 @@ -name 'teracy-dev' -maintainer 'Teracy, Inc.' -maintainer_email 'hoatlevan@gmail.com' -license 'All rights reserved' -description 'Installs/Configures teracy-dev' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.3.0' -issues_url 'https://github.com/teracyhq/issues' -source_url 'https://github.com/teracyhq/issues' - -%w{ magic_shell docker docker_compose }.each do |dep| - depends dep -end - -recipe 'teracy::aliases', "Installs useful aliases for teracy's project development." -recipe 'teracy-dev::normalization', 'The normalization recipe will contain all the codes to normalize the VM indeed.' -recipe 'teracy-dev::directories', 'Manage directories.' -recipe 'teracy-dev::env_vars', 'Configures environment variables.' -recipe 'teracy-dev::docker', 'Installs Docker, docker-compose' -recipe 'teracy-dev::docker_registry', "Docker registry's tasks: login, ..." -recipe 'teracy-dev::docker_machine', 'Installs docker-machine' -recipe 'teracy-dev::inotify', 'Modify inotify, useful for development watching a lot of files' -recipe 'teracy-dev::proxy', 'Create a reverse proxy with nginx' diff --git a/main-cookbooks/teracy-dev/providers/.gitkeep b/main-cookbooks/teracy-dev/providers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/main-cookbooks/teracy-dev/recipes/aliases.rb b/main-cookbooks/teracy-dev/recipes/aliases.rb deleted file mode 100644 index 85e55b15..00000000 --- a/main-cookbooks/teracy-dev/recipes/aliases.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: aliases -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -node['teracy-dev']['aliases'].each do |ali| - act = :create - act = ali['action'].to_sym unless ali['action'].nil? or ali['action'].strip().empty? - magic_shell_alias ali['name'] do - command ali['command'] - action act - end -end diff --git a/main-cookbooks/teracy-dev/recipes/default.rb b/main-cookbooks/teracy-dev/recipes/default.rb deleted file mode 100644 index c68e8e90..00000000 --- a/main-cookbooks/teracy-dev/recipes/default.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: github -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include_recipe 'teracy-dev::normalization' -include_recipe 'teracy-dev::directories' -include_recipe 'teracy-dev::aliases' -include_recipe 'teracy-dev::env_vars' -include_recipe 'teracy-dev::docker' -include_recipe 'teracy-dev::docker_registry' -include_recipe 'teracy-dev::docker_machine' -include_recipe 'teracy-dev::inotify' -include_recipe 'teracy-dev::proxy' diff --git a/main-cookbooks/teracy-dev/recipes/directories.rb b/main-cookbooks/teracy-dev/recipes/directories.rb deleted file mode 100644 index 0e26c1c5..00000000 --- a/main-cookbooks/teracy-dev/recipes/directories.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: directories -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -node['teracy-dev']['directories'].each do |dir| - mode = 0775 - act = :create - mod = dir['mode'] unless dir['mode'].nil? or dir['mode'].strip().empty? - act = dir['action'].to_sym unless dir['action'].nil? or dir['action'].strip().empty? - directory dir['path'] do - owner dir['owner'] - group dir['group'] - mode mod - action act - end -end diff --git a/main-cookbooks/teracy-dev/recipes/docker.rb b/main-cookbooks/teracy-dev/recipes/docker.rb deleted file mode 100644 index e43b452a..00000000 --- a/main-cookbooks/teracy-dev/recipes/docker.rb +++ /dev/null @@ -1,154 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: docker -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -docker_conf = node['docker'] - -def get_docker_compose_release - release = node['docker_compose']['version'] - - if release.empty? - result = Mixlib::ShellOut.new('curl -s https://api.github.com/repos/docker/compose/releases/latest | grep "tag_name" | cut -d\" -f4') - - result.run_command - - result.error! - - release = result.stdout.strip - - # TODO(hoatle): what if error or empty result? need to handle this case - end - node.override['docker_compose']['release'] = release - Chef::Log.info("get_docker_compose_release::release: #{release}") - release -end - -def existing_docker_compose_version - existing_docker_compose_version_cmd = Mixlib::ShellOut.new("docker-compose version | head -1 | grep -o -E '[0-9].*' | cut -d ',' -f1") - - existing_docker_compose_version_cmd.run_command - - existing_version = '' - - existing_version = existing_docker_compose_version_cmd.stdout.strip if existing_docker_compose_version_cmd.stderr.empty? && !existing_docker_compose_version_cmd.stdout.empty? - Chef::Log.debug("existing_docker_compose_version_cmd.stderr: #{existing_docker_compose_version_cmd.stderr}") - Chef::Log.debug("existing_docker_compose_version_cmd.stdout: #{existing_docker_compose_version_cmd.stdout}") - existing_version -end - -def get_docker_compose_autocomplete_url - "https://raw.githubusercontent.com/docker/compose/#{get_docker_compose_release}/contrib/completion/bash/docker-compose" -end - -if docker_conf['enabled'] == true - - act = :create - if docker_conf['action'] == 'delete' - act = :delete - end - - if !docker_conf['version'].empty? - # to make sure docker-engine is added into the package - # see: https://github.com/teracyhq/dev/issues/278 - docker_installation 'default' do - repo docker_conf['repo'] - action act - not_if 'which docker' - end - - # TODO(hoatle): better to uninstall only if the 2 versions mismatch - docker_installation 'default' do - repo docker_conf['repo'] - action :delete - end - - docker_installation_package 'default' do - version docker_conf['version'] - action act - package_options docker_conf['package_options'] - end - else - docker_installation 'default' do - repo docker_conf['repo'] - action act - end - end - - group 'docker' do - action :modify - members docker_conf['members'] - append true - end - - - if node['docker_compose']['enabled'] == true - release = get_docker_compose_release() - - existing_docker_compose_version = existing_docker_compose_version() - docker_compose_path = node['docker_compose']['command_path'] - docker_compose_autocomplete_path = '/etc/bash_completion.d/docker-compose' - Chef::Log.debug("existing_docker_compose_version: #{existing_docker_compose_version}") - # empty could mean broken installation, it's safe to do clean up. - if existing_docker_compose_version.empty? or existing_docker_compose_version != release - file docker_compose_path do - action :delete - only_if { File.exist?(docker_compose_path) } - end - - file docker_compose_autocomplete_path do - action :delete - only_if { File.exist?(docker_compose_autocomplete_path) } - end - end - - if !File.exist?(docker_compose_path) - # TODO(hoatle): get the cache file here - include_recipe 'docker_compose::installation' - # put the cache file here - end - - if !File.exist?(docker_compose_autocomplete_path) - # TODO(hoatle): get the cache file here - autocomplete_url = get_docker_compose_autocomplete_url - # install docker-compose auto complete - execute 'install docker-compose autocomplete' do - action :run - command "curl -sSL #{autocomplete_url} > /etc/bash_completion.d/docker-compose" - creates docker_compose_autocomplete_path - user 'root' - group 'docker' - only_if { node['platform'] == 'ubuntu' } - end - # put the cache file here - end - end -end diff --git a/main-cookbooks/teracy-dev/recipes/docker_machine.rb b/main-cookbooks/teracy-dev/recipes/docker_machine.rb deleted file mode 100644 index 59260699..00000000 --- a/main-cookbooks/teracy-dev/recipes/docker_machine.rb +++ /dev/null @@ -1,123 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: docker_machine -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -docker_machine_conf = node['docker_machine'] - - -if docker_machine_conf['enabled'] == true - def get_release_version - release = node['docker_machine']['release'] - if release.empty? - result = Mixlib::ShellOut.new('curl -s https://api.github.com/repos/docker/machine/releases/latest | grep "tag_name" | cut -d\" -f4') - result.run_command - result.error! - node.override['docker_machine']['release'] = release = result.stdout.strip - end - release - end - - def get_install_url - release = get_release_version - kernel_name = node['kernel']['name'] - machine_hw_name = node['kernel']['machine'] - "https://github.com/docker/machine/releases/download/#{release}/docker-machine-#{kernel_name}-#{machine_hw_name}" - end - - def get_docker_machine_autocomplete_url - release = node['docker_machine']['release'] - "https://raw.githubusercontent.com/docker/machine/#{release}/contrib/completion/bash/docker-machine.bash" - end - - def get_docker_machine_prompt_autocomplete_url - release = node['docker_machine']['release'] - "https://raw.githubusercontent.com/docker/machine/#{release}/contrib/completion/bash/docker-machine-prompt.bash" - end - - def get_docker_machine_wrapper_autocomplete_url - release = node['docker_machine']['release'] - "https://raw.githubusercontent.com/docker/machine/#{release}/contrib/completion/bash/docker-machine-wrapper.bash" - end - - command_path = docker_machine_conf['command_path'] - install_url = get_install_url - - package 'curl' do - action :install - end - - - execute 'install docker-machine' do - action :run - command "curl -sSL #{install_url} > #{command_path} && chmod +x #{command_path}" - creates command_path - user 'root' - group 'docker' - umask '0027' - end - - # install autocomplete (Ubuntu compatible only) - - # install docker-compose auto complete - if node['platform'] == 'ubuntu' - docker_machine_url = get_docker_machine_autocomplete_url - - execute 'install docker-machine autocomplete' do - action :run - command "curl -sSL #{docker_machine_url} > /etc/bash_completion.d/docker-machine.bash" - creates '/etc/bash_completion.d/docker-machine.bash' - user 'root' - group 'docker' - end - - docker_machine_prompt_url = get_docker_machine_prompt_autocomplete_url - - execute 'install docker-machine-prompt autocomplete' do - action :run - command "curl -sSL #{docker_machine_prompt_url} > /etc/bash_completion.d/docker-machine-prompt.bash" - creates '/etc/bash_completion.d/docker-machine-prompt.bash' - user 'root' - group 'docker' - end - - docker_machine_wrapper_url = get_docker_machine_wrapper_autocomplete_url - - execute 'install docker-machine-wrapper autocomplete' do - action :run - command "curl -sSL #{docker_machine_wrapper_url} > /etc/bash_completion.d/docker-machine-wrapper.bash" - creates '/etc/bash_completion.d/docker-machine-wrapper.bash' - user 'root' - group 'docker' - end - end - -end diff --git a/main-cookbooks/teracy-dev/recipes/docker_registry.rb b/main-cookbooks/teracy-dev/recipes/docker_registry.rb deleted file mode 100644 index 58819560..00000000 --- a/main-cookbooks/teracy-dev/recipes/docker_registry.rb +++ /dev/null @@ -1,56 +0,0 @@ -# Author:: Hoat Le -# Cookbook:: teracy-dev -# Recipe:: docker_registry -# Login into the Docker registries - -docker_conf = node['docker'] - -docker_registry_conf = node['docker_registry'] - -docker_config_path = docker_registry_conf['config_path'] - - -if docker_conf['enabled'] == true - execute 'rm ~/.docker/config.json' do - command "rm #{docker_config_path} || true" - only_if { - docker_registry_conf['force'] == true and - File.exist?(docker_config_path) - } - end - - docker_registry_conf['entries'].each do |entry| - # private registry login - - username = entry['username'] ? entry['username'] : '' - - password = entry['password'] ? entry['password'] : '' - - if not username.empty? and not password.empty? - opt = [ - "-u #{username}", - "-p #{password}" - ].join(' '); - - execute 'docker login' do - command "docker login #{entry['host']} #{opt}" - # because we need root to execute docker-compose, not 'vagrant' - only_if { - docker_registry_conf['force'] == true or - not File.exist?('/root/.docker/config.json') - } - end - end - end - - - execute 'copy /root/.docker/config.json to ~/.docker/config.json' do - command "cp /root/.docker/config.json #{docker_config_path}" - only_if { - File.exist?('/root/.docker/config.json') and ( - docker_registry_conf['force'] == true or - not File.exist?(docker_config_path) - ) - } - end -end diff --git a/main-cookbooks/teracy-dev/recipes/env_vars.rb b/main-cookbooks/teracy-dev/recipes/env_vars.rb deleted file mode 100644 index 7610ed95..00000000 --- a/main-cookbooks/teracy-dev/recipes/env_vars.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: env_vars -# Description: Configures environment -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -node['teracy-dev']['env_vars'].each do |env| - act = :add - act = env['action'].to_sym unless env['action'].nil? or env['action'].strip().empty? - magic_shell_environment env['key'] do - value env['value'] - action act - end -end diff --git a/main-cookbooks/teracy-dev/recipes/inotify.rb b/main-cookbooks/teracy-dev/recipes/inotify.rb deleted file mode 100644 index 2a4e3f99..00000000 --- a/main-cookbooks/teracy-dev/recipes/inotify.rb +++ /dev/null @@ -1,54 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: inotify -# Description: Configures inotify watchers -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# see https://github.com/teracyhq/dev/issues/208 -if node['platform'] == 'ubuntu' - max_user_watches = node['teracy-dev']['inotify']['max_user_watches'] - - # should remove the existing line - execute 'remove existing fs.inotify.max_user_watches line' do - command "sudo sed -i '/fs.inotify.max_user_watches/d' /etc/sysctl.conf" - end - - execute 'add new fs.inotify.max_user_watches config' do - command "echo fs.inotify.max_user_watches=#{max_user_watches} | sudo tee -a /etc/sysctl.conf" - not_if { max_user_watches < 1 } - end - - # this must run after settings - execute 'sudo sysctl -p' do - command 'sudo sysctl -p' - end - -end diff --git a/main-cookbooks/teracy-dev/recipes/normalization.rb b/main-cookbooks/teracy-dev/recipes/normalization.rb deleted file mode 100644 index 6efbc363..00000000 --- a/main-cookbooks/teracy-dev/recipes/normalization.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# Author:: hieptranquoc -# Cookbook Name:: teracy-dev -# Recipe:: normalization -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -bash 'check exist and install bash-completion' do - code <<-EOH - apt-get install --reinstall -f -y bash-completion - . /etc/bash_completion - EOH - not_if { ::File.exist?('/etc/bash_completion') && ::File.exist?('/usr/share/bash-completion/bash_completion') } -end diff --git a/main-cookbooks/teracy-dev/recipes/proxy.rb b/main-cookbooks/teracy-dev/recipes/proxy.rb deleted file mode 100644 index 401ec016..00000000 --- a/main-cookbooks/teracy-dev/recipes/proxy.rb +++ /dev/null @@ -1,92 +0,0 @@ -# -# Author:: Hoat Le -# Cookbook Name:: teracy-dev -# Recipe:: proxy -# -# Copyright 2013 - current, Teracy, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -proxy_conf = node['teracy-dev']['proxy'] - -if proxy_conf['enabled'] == true - certs_conf = node['teracy-dev']['proxy']['certs'] - - if certs_conf['enabled'] == true - - owner = certs_conf['owner'] - group = certs_conf['group'] - mode = certs_conf['mode'] - sources = certs_conf['sources'] - destination = certs_conf['destination'] - - # create the destination directory first - directory destination do - owner owner - group group - mode '0755' - action :create - recursive true - end - - # then copy files - sources.each do |source| - source_path = "default/#{source}" - file_ext_splits = source.split('.') - file_ext = file_ext_splits[file_ext_splits.length-1] - destination_path = "#{destination}/#{node.name}.#{file_ext}" - - cookbook_file destination_path do - source source_path - owner owner - group group - mode mode - action :create - end - end - end - - # start docker nginx-proxy - # this require that docker must be available implicitly (error will happen if no docker installed) - container_conf = node['teracy-dev']['proxy']['container'] - if container_conf['enabled'] == true - - docker_image container_conf['repo'] do - tag container_conf['tag'] - action :pull - notifies :redeploy, "docker_container[#{container_conf['name']}]" - end - - docker_container container_conf['name'] do - repo container_conf['repo'] - tag container_conf['tag'] - volumes container_conf['volumes'] - restart_policy container_conf['restart_policy'] - port container_conf['port'] - end - end -end diff --git a/main-cookbooks/teracy-dev/resources/.gitkeep b/main-cookbooks/teracy-dev/resources/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/main-cookbooks/teracy-dev/templates/default/.gitkeep b/main-cookbooks/teracy-dev/templates/default/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/nodes/README.md b/nodes/README.md deleted file mode 100644 index b4477a8c..00000000 --- a/nodes/README.md +++ /dev/null @@ -1,2 +0,0 @@ -Chef Nodes -========== \ No newline at end of file diff --git a/provisioners/shells/ip.sh b/provisioners/shells/ip.sh deleted file mode 100644 index fc08cd3b..00000000 --- a/provisioners/shells/ip.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/bash - -ipaddress=`hostname -I | cut -d' ' -f2` -echo "ip address: $ipaddress" diff --git a/provisioners/shells/save_mac_address.sh b/provisioners/shells/save_mac_address.sh deleted file mode 100644 index f324f8b4..00000000 --- a/provisioners/shells/save_mac_address.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -if [ -f '/vagrant/.vagrant/.public_mac_address' ]; then - ifconfig | grep "$(route | grep '^default' | grep -o '[^ ]*$')" | awk '{print $5}' > /vagrant/.vagrant/.public_mac_address -fi \ No newline at end of file diff --git a/resources/README.md b/resources/README.md deleted file mode 100644 index a8212ccc..00000000 --- a/resources/README.md +++ /dev/null @@ -1,16 +0,0 @@ -teracy-dev's resources -====================== - -Contain all common and useful resources for Teraciers. - -project-template ----------------- - -`project-template` includes common resources needed for creating a new project. - -``` bash -$ mkdir -$ cd -$ git init -$ cp -r /vagrant/resources/project-template/. . -``` diff --git a/resources/project-template/.gitignore b/resources/project-template/.gitignore deleted file mode 100644 index 42c7a6ff..00000000 --- a/resources/project-template/.gitignore +++ /dev/null @@ -1,137 +0,0 @@ -# Compiled source # -################### -*.com -*.class -*.dll -*.exe -*.o -*.so - -# Logs and databases # -###################### -*.log -*.sql -*.sqlite - -## https://github.com/github/gitignore/blob/master/Global/Archives.gitignore - -# It's better to unpack these files and commit the raw source because -# git has its own built in compression methods. -*.7z -*.jar -*.rar -*.zip -*.gz -*.bzip -*.bz2 -*.xz -*.lzma - -#packing-only formats -*.iso -*.tar - -#package management formats -*.dmg -*.xpi -*.gem -*.egg -*.deb -*.rpm - -## https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore - -*.pydevproject -.project -.metadata -bin/** -tmp/** -tmp/**/* -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - -## https://github.com/github/gitignore/blob/master/Global/IntelliJ.gitignore - -*.iml -*.ipr -*.iws -.idea/ - -## https://github.com/github/gitignore/blob/master/Global/Linux.gitignore - -.* -!.gitignore -*~ - -## https://github.com/github/gitignore/blob/master/Global/OSX.gitignore - -.DS_Store -.AppleDouble -.LSOverride -Icon - - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -## https://github.com/github/gitignore/blob/master/Global/SASS.gitignore - -### SASS Ignores - "Sassy CSS" http://sass-lang.com/ -*.sass-cache - -## https://github.com/github/gitignore/blob/master/Global/SublimeText.gitignore - -# SublimeText project files -*.sublime-workspace - -## https://github.com/github/gitignore/blob/master/Global/Windows.gitignore - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -## https://github.com/github/gitignore/blob/master/Global/vim.gitignore - -*.s[a-w][a-z] -*.un~ -Session.vim -.netrwhist -*~ - -# teracy -!.rbenv-version -!.travis.yml -!.gitkeep -!.gitmodules - -# docs -_build -_deploy diff --git a/resources/project-template/AUTHORS.md b/resources/project-template/AUTHORS.md deleted file mode 100644 index e76e41cc..00000000 --- a/resources/project-template/AUTHORS.md +++ /dev/null @@ -1,4 +0,0 @@ -Authors -======= - -Author Name - Email \ No newline at end of file diff --git a/resources/project-template/CHANGELOG.md b/resources/project-template/CHANGELOG.md deleted file mode 100644 index 9a203e1b..00000000 --- a/resources/project-template/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -Change Log -========== diff --git a/resources/project-template/CONTRIBUTORS.md b/resources/project-template/CONTRIBUTORS.md deleted file mode 100644 index 6a06897c..00000000 --- a/resources/project-template/CONTRIBUTORS.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributors -============ - -Contributor Name - Email diff --git a/resources/project-template/LICENSE b/resources/project-template/LICENSE deleted file mode 100644 index 113810e5..00000000 --- a/resources/project-template/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) Teracy, Inc. and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/resources/project-template/README.md b/resources/project-template/README.md deleted file mode 100644 index 744c92ab..00000000 --- a/resources/project-template/README.md +++ /dev/null @@ -1,84 +0,0 @@ -project-name -============ - -Project name introduction - -Continuous Integration ----------------------- - -Usage ------ - - -Installation ------------- - - -Configuration -------------- - - -Contributing ------------- - -- File issues at https://issues.teracy.org/browse/ - -- Follow Teracy's workflow at http://dev.teracy.org/docs/develop/workflow.html - -Discussions ------------ - -Join us: - -- https://groups.google.com/forum/#!forum/teracy - -- https://www.facebook.com/groups/teracy - -Get our news: - -- https://www.facebook.com/teracy.official - -- https://twitter.com/teracy_official - - -Author and contributors ------------------------ - -See more details at `AUTHORS.md` and `CONTRIBUTORS.md` files. - - -License -------- - -BSD License - -``` -Copyright (c) Teracy, Inc. and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -``` diff --git a/roles/README.md b/roles/README.md deleted file mode 100644 index b0ee0b4d..00000000 --- a/roles/README.md +++ /dev/null @@ -1,16 +0,0 @@ -Create roles here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install roles on the server, use knife. - -For example, create `roles/base_example.rb`: - - name "base_example" - description "Example base role applied to all nodes." - # List of recipes and roles to apply. Requires Chef 0.8, earlier versions use 'recipes()'. - #run_list() - # Attributes applied if the node doesn't have it set already. - #default_attributes() - # Attributes applied no matter what the node has set already. - #override_attributes() - -Then upload it to the Chef Server: - - knife role from file roles/base_example.rb diff --git a/scripts/Download-File.ps1 b/scripts/Download-File.ps1 deleted file mode 100644 index e8ab9000..00000000 --- a/scripts/Download-File.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -<# -.SYNOPSIS - Downloads a file showing the progress of the download -.DESCRIPTION - This Script will download a file locally while showing the progress of the download -.EXAMPLE - .\Download-File.ps1 'http:\\someurl.com\somefile.zip' -.EXAMPLE - .\Download-File.ps1 'http:\\someurl.com\somefile.zip' 'C:\Temp\somefile.zip' -.PARAMETER url - url to be downloaded -.PARAMETER localFile - the local filename where the download should be placed -.NOTES - FileName : Download-File.ps1 - Author : CrazyDave - LastModified : 18 Jan 2011 9:39 AM PST -#Requires -Version 2.0 -#> -<# -param( - [Parameter(Mandatory=$true)] - [String] $url, - [Parameter(Mandatory=$false)] - [String] $localFile = (Join-Path $pwd.Path $url.SubString($url.LastIndexOf('/'))) -) -#> -param( - [Parameter(Mandatory=$true)] - [String] $url, - [Parameter(Mandatory=$false)] - [String] $localFile = (Join-Path $pwd.Path $url.SubString($url.LastIndexOf('/'))) -) - -begin { - - $client = New-Object System.Net.WebClient - $Global:downloadComplete = $false - - $eventDataComplete = Register-ObjectEvent $client DownloadFileCompleted ` - -SourceIdentifier WebClient.DownloadFileComplete ` - -Action {$Global:downloadComplete = $true} - $eventDataProgress = Register-ObjectEvent $client DownloadProgressChanged ` - -SourceIdentifier WebClient.DownloadProgressChanged ` - -Action { $Global:DPCEventArgs = $EventArgs } -} - -process { - Write-Progress -Activity 'Downloading file' -Status $url - $client.DownloadFileAsync($url, $localFile) - - while (!($Global:downloadComplete)) { - $pc = $Global:DPCEventArgs.ProgressPercentage - if ($pc -ne $null) { - Write-Progress -Activity 'Downloading file' -Status $url -PercentComplete $pc - } - } - - Write-Progress -Activity 'Downloading file' -Status $url -Complete -} - -end { - Unregister-Event -SourceIdentifier WebClient.DownloadProgressChanged - Unregister-Event -SourceIdentifier WebClient.DownloadFileComplete - $client.Dispose() - $Global:downloadComplete = $null - $Global:DPCEventArgs = $null - Remove-Variable client - Remove-Variable eventDataComplete - Remove-Variable eventDataProgress - [GC]::Collect() -} \ No newline at end of file diff --git a/scripts/rbenv.sh b/scripts/rbenv.sh deleted file mode 100755 index 5f8e48fe..00000000 --- a/scripts/rbenv.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# install rbenv and switch ruby to 1.9.3-p194 -# kudos to https://learnchef.opscode.com/quickstart/workstation-setup/#linux for manual installation - -# How to install: -# $ cd /tmp && wget https://raw.github.com/teracy-official/dev/master/scripts/rbenv.sh && chmod +x rbenv.sh && . ./rbenv.sh && cd ~ -# TODO(phuonglm): improve this: non-root user? this was validated on dev VM only, what's about clean Ubuntu instance? -function install_support_packages() { - sudo apt-get install build-essential git -} - -function install_rbenv() { - #clone rbenv from official git repository and add it to your path - cd ~ - git clone git://github.com/sstephenson/rbenv.git .rbenv - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .profile - echo 'eval "$(rbenv init -)"' >> .profile - source ~/.profile -} - -function install_ruby_build() { - cd /tmp - git clone git://github.com/sstephenson/ruby-build.git - cd ruby-build - sudo ./install.sh -} - -function install_ruby() { - rbenv rehash - rbenv install 1.9.3-p194 - rbenv shell 1.9.3-p194 - rbenv global 1.9.3-p194 -} - -sudo apt-get update -install_support_packages -install_rbenv -install_ruby_build -install_ruby diff --git a/scripts/setup_working_env_mac.sh b/scripts/setup_working_env_mac.sh deleted file mode 100644 index 32486d7f..00000000 --- a/scripts/setup_working_env_mac.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Setup initial working environment for host machines. This initial script only serves Mac. - -# requires -# brew -# brew-cask - -# to install: -# virtualbox -# vagrant -# docker -# docker-sync diff --git a/scripts/setup_working_env_ubuntu.sh b/scripts/setup_working_env_ubuntu.sh deleted file mode 100644 index de706973..00000000 --- a/scripts/setup_working_env_ubuntu.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -# Setup initial working environment for host machines. This initial script only serves Ubuntu. -# -# install git -# install virtualbox-5.1.8 -# install vagrant 1.8.7 - -function command_exists() { - type "$1" &> /dev/null; -} - -distributor_id=`command_exists lsb_release && lsb_release -i` - - -if [[ "$distributor_id" != *Ubuntu* ]]; then - echo "You're not on Ubuntu. This script is currently provided to run under Ubuntu only." - exit 1 -fi - -code_name=$(lsb_release -a 2>&1 | grep Codename | awk '{print $2}') -vagrant_version="1.8.7" - -if [ "$code_name" == "trusty" ] || [ "$code_name" == "saucy" ] || [ "$code_name" == "utopic" ]; then - vbox_download_code_name="raring" -else - vbox_download_code_name="$code_name" -fi - -is_32_bit=true -virtualbox_link="http://download.virtualbox.org/virtualbox/5.1.8/virtualbox-5.1_5.1.8-111374~Ubuntu~${vbox_download_code_name}_i386.deb" -vagrant_link="https://releases.hashicorp.com/vagrant/${vagrant_version}/vagrant_${vagrant_version}_i686.deb" - -function determine_32_64_bit() { - local machine=$(uname -m) - if ! [[ $machine =~ i686 ]] ; then - is_32_bit=false - fi -} - -determine_32_64_bit - -if ! $is_32_bit ; then - echo "installing packages of 64-bit virtualbox and vagrant..." - virtualbox_link="http://download.virtualbox.org/virtualbox/5.1.8/virtualbox-5.1_5.1.8-111374~Ubuntu~${vbox_download_code_name}_amd64.deb" - vagrant_link="https://releases.hashicorp.com/vagrant/${vagrant_version}/vagrant_${vagrant_version}_x86_64.deb" -fi - - -function install_git() { - sudo apt-get -f -y install git -} - -function install_virtualbox() { - cd /tmp - wget $virtualbox_link - sudo dpkg -i virtualbox-*~Ubuntu~* - sudo apt-get install -f -y - cd - -} - -function install_vagrant() { - cd /tmp - wget $vagrant_link - sudo dpkg -i vagrant_* - sudo apt-get install -f -y - cd - -} - -function install_docker() { - sudo apt-get update - if [ "$code_name" == "precise" ]; then - sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring - sudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring - sudo apt-get install -f - [ -e /usr/lib/apt/methods/https ] || { - apt-get install apt-transport-https - } - else - sudo apt-get install linux-image-extra-`uname -r` - fi - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 - sudo sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list" - sudo apt-get update - sudo apt-get -f -y install lxc-docker -} - -sudo apt-get update -install_git -install_virtualbox -install_vagrant -#install_docker diff --git a/scripts/setup_working_env_windows.bat b/scripts/setup_working_env_windows.bat deleted file mode 100644 index a8f6204a..00000000 --- a/scripts/setup_working_env_windows.bat +++ /dev/null @@ -1,183 +0,0 @@ -@echo off - -:: BatchGotAdmin -:------------------------------------- -REM ->nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" - -REM -if '%errorlevel%' NEQ '0' ( - echo Requesting administrative privileges... - goto UACPrompt -) else ( goto gotAdmin ) - -:UACPrompt - echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" - set "params = %*:"="" - echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" - - "%temp%\getadmin.vbs" - del "%temp%\getadmin.vbs" - exit /B - -:gotAdmin - pushd "%CD%" - CD /D "%~dp0" -:-------------------------------------- - -@echo off -echo =========================================================== -echo !! Powered by Teracy !! -echo !! This script will install VirtualBox and Vagrant on !! -echo !! your computer. Please say NO during the setup when !! -echo !! you see the message "Restart your computer". We will !! -echo !! do it when complete. !! -echo =========================================================== -echo ........................................................... -echo Prepare and downloading resources -copy /y NUL c:\dp.ps1 >NUL - -powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/teracyhq/dev/develop/scripts/Download-File.ps1', 'c:\dp.ps1')" - -echo Prepare completed - -echo. - -echo --- Findding installed vagrant and virtualbox --- -echo. - -setlocal EnableDelayedExpansion -set vagrantV=0.0 -set vboxV=0.0 -set restart="false" - -set LF=^ - -:findVagrant -echo. -echo ..............Findding vagrant.............. -echo. - -for /F "skip=1 tokens=1" %%a in ('wmic product where "Name like 'vagrant'" get Version') do ( - set "item=%%a" - call :removeCR - if !vagrantV! EQU 0.0 ( - if not "!item!"=="" set vagrantV=!item! - ) -) - -IF %ERRORLEVEL% NEQ 0 GOTO vagrantNotfound -IF %vagrantV% EQU 0.0 GOTO vagrantNotfound - -set vagrantVs=%vagrantV:.=% - -if %vagrantVs% LSS 162 ( - echo Vagrant found with version %vagrantV% that is not valid, process next step - GOTO processVagrant - ) -echo Vagrant found with a valid version (%vagrantV%) -GOTO findVBox - - -:vagrantNotfound -echo Vagrant notfound, process to download -GOTO processVagrant - -:findVBox -echo. -echo ..............Findding virtualbox............. -echo. - -for /F "skip=1 tokens=1" %%b in ('wmic product where "Name like 'Oracle VM VirtualBox%%'" get Version') do ( - set "item=%%b" - call :removeCR - if !vboxV! EQU 0.0 ( - if not "!item!"=="" set vboxV=!item! - ) -) - -IF %ERRORLEVEL% NEQ 0 GOTO vboxNotfound -IF %vboxV% EQU 0.0 GOTO vboxNotfound - -set vboxVs=%vboxV:.=% - - -if %vboxVs% LSS 4312 ( - echo VirtualBox found with version %vboxV% that is not valid, process next step - GOTO processVBox - ) -echo VirtualBox found with a valid version (%vboxV%) -GOTO mainProcess - -:vboxNotfound -echo VirtualBox notfound, process to download -GOTO processVBox - -:processVBox -echo. -echo --- DOWNLOAD and INSTALL VIRTUAL BOX --- -echo. - -copy /y NUL c:\vbox.exe >NUL -powershell -ExecutionPolicy RemoteSigned -File "c:\dp.ps1" "http://download.virtualbox.org/virtualbox/5.1.8/VirtualBox-5.1.8-111374-Win.exe" "c:\vbox.exe" - - -echo Virtual Box is installing -START /wait /b C:\vbox.exe - -set restart="true" - -GOTO mainProcess - -echo ........................................................... - -:processVagrant -echo. -echo --- DOWNLOAD and INSTALL VAGRANT --- -echo. - -copy /y NUL c:\vgrant.msi >NUL -powershell -ExecutionPolicy RemoteSigned -File "c:\dp.ps1" "https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7.msi" "c:\vgrant.msi" - -echo Vagrant is installing -start /wait /b C:\vgrant.msi - -set restart="true" - -GOTO findVBox - -:mainProcess - -set pathToInsert=%ProgramFiles%\Oracle\VirtualBox -setx path "%pathToInsert%;%PATH%" - -echo. - -:: delete temp file -IF EXIST c:\vgrant.msi del c:\vgrant.msi -IF EXIST c:\vbox.exe del c:\vbox.exe -IF EXIST c:\dp.ps1 del c:\dp.ps1 - -if %restart% EQU "false" GOTO END - - -SET /P AREYOUSURE=Do you want to restart your computer now. It will apply changes and config (y/N)? - - -IF /I "%AREYOUSURE%" NEQ "Y" GOTO END - -shutdown.exe /r - -:END - -pause - -goto :eof -:removeCR - -:removeCR -set "Item=%Item%" -exit /b - - -:exit diff --git a/shared/.gitkeep b/shared/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/utility_spec.rb b/spec/utility_spec.rb index 340f9e16..af49dc06 100644 --- a/spec/utility_spec.rb +++ b/spec/utility_spec.rb @@ -1,6 +1,10 @@ require 'json' require "./lib/utility" +#TODO: add this case +# first = {"default"=>{"provisioners"=>nil}} +# second = {"default"=>{"provisioners"=>[{"_id"=>"dev-setup-0", "verbose"=>"v", "type"=>"ansible_local", "playbook"=>"workspace/dev-setup/ansible/playbook.yml"}]}} + describe "utility" do describe "overrides" do context "given an empty obj2" do diff --git a/system.yaml b/system.yaml new file mode 100644 index 00000000..7d51d162 --- /dev/null +++ b/system.yaml @@ -0,0 +1,8 @@ +# teracy-dev system config, not overriable +vagrant: + require_version: ">= 2.1.0" + # rubygems (vagrant plugins) + plugins: [] + # - name: wisper + # version: "" + # state: installed # or uninstalled diff --git a/test/foodcritic/customink b/test/foodcritic/customink deleted file mode 160000 index d67b7ae8..00000000 --- a/test/foodcritic/customink +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d67b7ae8ced2580cd926b3717d087ab9ff8309e6 diff --git a/test/foodcritic/etsy b/test/foodcritic/etsy deleted file mode 160000 index e9cf7eff..00000000 --- a/test/foodcritic/etsy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9cf7eff55dcbc0f1906361e9b801dbe303c0af3 diff --git a/test/knife.rb b/test/knife.rb deleted file mode 100644 index 902d2366..00000000 --- a/test/knife.rb +++ /dev/null @@ -1,4 +0,0 @@ -current_dir = File.dirname(__FILE__) -cookbook_path ["#{current_dir}/../main-cookbooks"] -cache_type 'BasicFile' -cache_options(:path => "#{ENV['HOME']}/.chef/checksums") diff --git a/vagrant_config.json b/vagrant_config.json deleted file mode 100644 index 5c280808..00000000 --- a/vagrant_config.json +++ /dev/null @@ -1,234 +0,0 @@ -{ - "vm": { - "hostname": "teracy.dev", - "box": "bento/ubuntu-16.04", - "box_version": "", - "networks": [{ // see: http://docs.vagrantup.com/v2/networking/index.html - "_id": "0", - "mode": "public_network", // one of "forwarded_port", "private_network" or "public_network" - //by default, 192.168.99.100 is used for Boot2Docker - // for convention, use 192.168.99.101 for teracy-dev, 192.168.99.102 for teracy-staging, etc. - //"ip": "" // for private_network, public_network mode - //"type":"dhcp", // for private_network mode; if ip and type are both defined, ip takes precedence - //"auto_config":true, // for private_network mode + ip - "bridge": [ - // see: https://github.com/teracyhq/dev/issues/262 - // "eth0", //wired LAN, the first priority - // "en0: Wi-Fi (AirPort)", // macOS 10.12 - // "en1: Wi-Fi (AirPort)", // macOS 10.11 - // "wlan0" // linux - ], // for public_network mode - "auto_bridge_default_network": true, - "reuse_mac_address": true - }], - "synced_folders":[{ //see: http://docs.vagrantup.com/v2/synced-folders/index.html - "_id": "0", - "type": "virtual_box", - "host": ".", - "guest": "/vagrant" - }, { - "_id": "1", - "type": "rsync", - "host": "./workspace", - "guest": "/home/vagrant/workspace", - "rsync__exclude": [".git", ".idea", ".#*"] - }, { // should persist docker auth token after login success #170 - "_id": "2", - "type": "virtual_box", - "host": "./home/.docker", - "guest": "/home/vagrant/.docker", - "mount_options": [ - "dmode=775", - "fmode=755" - ] - // { - // "type":"virtual_box", // virtual_box, "nfs", "rsync" or "smb", incase smb mount failed, - // // ssh to vm and install cifs-utils allow vm mount smb directory - // // mount.cifs needs to be used with dir_mode file_mode instead of dmode fmode - // // Windows 7 needs powershell 3.0 to create smb share on windows - // // http://www.microsoft.com/en-us/download/details.aspx?id=34595 - // "host":"./docker", - // "guest":"/var/lib/docker/", - // "mount_options":[ - // "dmode=775", - // "fmode=755" - // ] - // }, - //TODO: how to keep and reused existing Docker images after destroying the VM? - // or even attaching the existing data into it, so that developers should share the Docker images - // remove /vagrant default file sync on the VM guest machine #184 - }] - // Other configs - // "boot_timeout": 300, - // "box_check_update": true, - // "box_download_checksum": "", - // "box_download_checksum_type": "", // "md5", "sha1", "sha256" - // "box_download_client_cert": "", - // "box_download_ca_cert": "", - // "box_download_ca_path": "", - // "box_download_insecure": true, // true, false - // "communicator": "ssh", // ssh, winrm - // "graceful_halt_timeout": 60, - // "guest": "linux", // linux - // "hostname": "", - // "post_up_message": "", - // "usable_port_range": "2200..2250" // 2200..2250 - }, - "vb": { //virtualbox settings from https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm - //"gui":true, - //"name":"teracy-dev", - "memory": 1024, - //"cpus":1, - "description": "teracy-dev #{Time.now.getutc.to_i}" - }, - "provisioners": [{ - "_id": "0", - "version": "13.1.31", - "type": "chef_solo", - "log_level": "info", //one of debug, info, warn, error, fatal. Default: info - "cookbooks_path": [ - "vendor-cookbooks", - "main-cookbooks" - ], - "roles_path": "roles", - "nodes_path": "nodes", - "data_bags_path": "data_bags", - "run_list": [ - "vim", - "teracy-dev" - ], - "json": { - // we mix teracy-dev config along with vender-cookbooks config, hopefully this is better than - // separated as we did before, this is for advanded users only - "docker": { - "enabled": true, - "version": "", // use this to install a specific docker version, default: "" - // used along with the version key, this is default for Ubuntu - "package_options": "--force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-all'", - "repo": "main", // one of main, test, experimental, default: "main" - "members": ["vagrant"], // to append this member to "docker" group - "action": "create" // one of create, delete. Default: create - }, - "docker_registry": { - // set true to force re-login with all the defined entries, default: false (login once) - "force": false, - "config_path": "/home/vagrant/.docker/config.json", - "entries": [] - // example: - // "entries": [ - // { - // "host": "https://index.docker.io/v1/", - // "username": "", - // "password": "" - // }, - // { - // "host": "registry.gitlab.com", - // "username": "", - // "password": "" - // } - // ] - }, - "docker_compose": { - "version": "", // more: https://github.com/docker/compose/releases/ - "enabled": true // "docker" must be enabled to get this - }, - "docker_machine": { - "enabled": false, - "release": "" // more: https://github.com/docker/machine/releases/ - }, - "teracy-dev": { - "directories": [{ - "_id": "0", - "path": "/home/vagrant/workspace", - "owner": "vagrant", - "group": "vagrant", - "mode": "0775", - "action": "create" // one of create, delete, nothing. Default: create. - // See more: https://docs.chef.io/resource_directory.html - }], - "aliases": [{ - "_id": "0", - "name": "ws", - "command": "cd ~/workspace", - "action": "add" // one of add, remove. Default: add. - // See more: https://github.com/customink-webops/magic_shell/blob/master/resources/alias.rb - }, { - "_id": "1", - "name": "ctop", // `$ ctop` for top-like interface for container metrics, see: https://github.com/bcicen/ctop - "command": "docker run -ti --name ctop --rm -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest", - "action": "add" - },{ - "_id": "2", - "name": "http", // `$ http` to make http requests, how to use: https://github.com/teracyhq/httpie-jwt-auth - "command": "docker container run -it --rm --net=host teracy/httpie-jwt-auth:latest-alpine", - "action": "add" - }, { - "_id": "3", - "name": "https", // shortcut for making https requests - "command": "http --default-scheme=https", - "action": "add" - }], - "env_vars": [{ - "_id": "0", - "key": "EDITOR", - "value": "vim", - "action": "add" // one of add, remove. Default: add. - // See more: https://github.com/customink-webops/magic_shell/blob/master/resources/environment.rb - }], - "inotify": { - "max_user_watches": 524288 // see: https://github.com/teracyhq/dev/issues/208, set value = 0 to unset this setting - }, - "proxy": { - "enabled": true, - "certs": { - "enabled": true, - "sources": ["nginx/certs/default.crt", "nginx/certs/default.key"], - "destination": "/etc/nginx/certs", - "owner": "vagrant", - "group": "vagrant", - "mode": "0644" - }, - "container": { - "enabled": false, - "name": "nginx-proxy", - "repo": "jwilder/nginx-proxy", - "tag": "alpine", - "volumes": ["/var/run/docker.sock:/tmp/docker.sock:ro", "/etc/nginx/certs:/etc/nginx/certs"], - "restart_policy": "always", - "port": ["80:80", "443:443"] - } - } - } - } - }], - "plugins": [{ - "_id": "0", - "name": "vagrant-gatling-rsync", - "config_key": "gatling", - "required": true, - "enabled": true, - "options": { - // auto rsync watch when up/ reload done - // should try to reduce rsync latency to 0.5s instead of 1s #173 - "latency": 0.5, //0.5s - "time_format": "%H:%M:%S", - "rsync_on_startup": true - } - }, { - "_id": "1", - "name": "vagrant-rsync-back", - "required": true, - "enabled": true - }, { - "_id" : "2", - "name" : "vagrant-hostmanager", - "config_key" : "hostmanager", - "required" : true, - "enabled" : true, - "options" : { - "enabled" : true, - "manage_host" : true, - "manage_guest" : true - } - }] -} diff --git a/vendor-cookbooks/compat_resource/CHANGELOG.md b/vendor-cookbooks/compat_resource/CHANGELOG.md deleted file mode 100644 index 79081964..00000000 --- a/vendor-cookbooks/compat_resource/CHANGELOG.md +++ /dev/null @@ -1,53 +0,0 @@ -# compat_resource Cookbook CHANGELOG - -This file is used to list changes made in each version of the compat_resource cookbook. - -## 12.19.0 (2017-04-17) - -- Suppress warning already initialized constant -- Backport yum/apt changes from 12.19 - -## 12.16.2 (2016-11-09) - -- Sync chef-client changes from Chef 12.16.42 - -## 12.16.1 (2016-10-20) - -- add delayed_action helper - -## 12.16.0 (2016-10-19) - -- Sync chef-client changes from Chef 12.16.14 - -## 12.14.7 (2016-09-26) - -- Update to 12.14.89 Chef -- Fix autoload by applying fix from #106 - -## 12.14.6 (2016-09-20) - -- Update backported codebase to Chef 12.14.77 which brings in yum_repository updates and why-run enabled by default in custom resources - -## 12.14.5 (2016-09-19) - -- Prevent spamming messages in Chefspec runs for cookbooks that depend on compat_resource - -## 12.14.4 (2016-09-19) - -- Fix delayed notifications cloning - -## 12.14.3 (2016-09-12) - -- Fix subscribes notifications - -## 12.14.2 (2016-09-09) - -- Improve documentation -- keep ChefCompat::Resource defined even if we don't load - -## 12.14.1 (2016-09-07) - -- add yum_repository resource from Chef 12.14 -- Update the minimum chef version in the metadata to 12.1 -- Added maintainers files -- suppress constant redef warnings when running chefspec diff --git a/vendor-cookbooks/compat_resource/CONTRIBUTING.md b/vendor-cookbooks/compat_resource/CONTRIBUTING.md deleted file mode 100644 index ef2f2b80..00000000 --- a/vendor-cookbooks/compat_resource/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/compat_resource/MAINTAINERS.md b/vendor-cookbooks/compat_resource/MAINTAINERS.md deleted file mode 100644 index 5ae0806c..00000000 --- a/vendor-cookbooks/compat_resource/MAINTAINERS.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Maintainers - -This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead. - -# Project Maintainer -* [Lamont Granquist](https://github.com/lamont-granquist) - -# Maintainers -* [Jennifer Davis](https://github.com/sigje) -* [Tim Smith](https://github.com/tas50) -* [Thom May](https://github.com/thommay) -* [Lamont Granquist](https://github.com/lamont-granquist) diff --git a/vendor-cookbooks/compat_resource/README.md b/vendor-cookbooks/compat_resource/README.md deleted file mode 100644 index f5c17e5a..00000000 --- a/vendor-cookbooks/compat_resource/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# compat_resource cookbook - -[![Build Status](https://travis-ci.org/chef-cookbooks/compat_resource.svg?branch=master)](https://travis-ci.org/chef-cookbooks/compat_resource) [![Cookbook Version](https://img.shields.io/cookbook/v/compat_resource.svg)](https://supermarket.chef.io/cookbooks/compat_resource) - -This cookbook backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards. This includes [Custom Resource](https://docs.chef.io/custom_resources.html) functionality, notification improvements, as well as new resources added to core chef. It allows for the usage of these new resources in cookbooks without requiring the very latest Chef client release. - -## Backported functionality - -- [Custom Resources](https://docs.chef.io/custom_resources.html) -- [apt_repository](https://docs.chef.io/resource_apt_repository.html) -- [apt_update](https://docs.chef.io/resource_apt_update.html) -- [systemd_unit](https://docs.chef.io/resource_systemd_unit.html) -- [yum_repository](https://docs.chef.io/resource_yum_repository.html) -- [:before notifications](https://docs.chef.io/resources.html#timers) - -## Requirements - -### Platforms - -- All platforms supported by Chef - -### Chef - -- Chef 12.1+ - -### Cookbooks - -- none - -## Usage - -To use this cookbook, put `depends 'compat_resource'` in the metadata.rb of your cookbook. Once this is done, you can use all the new custom resource features to define resources. It Just Works. - -## Custom Resources? - -Curious about how to use custom resources? - -- Docs: -- Slides: - -## License & Authors - -- Author:: Lamont Granquist ([lamont@chef.io](mailto:lamont@chef.io)) -- Author:: John Keiser ([jkeiser@chef.io](mailto:jkeiser@chef.io)) - -```text -Copyright:: 2015-2016 Chef Software, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -``` diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef.rb deleted file mode 100644 index 219b05b4..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef.rb +++ /dev/null @@ -1,29 +0,0 @@ -module ChefCompat - module CopiedFromChef - def self.extend_chef_module(chef_module, target) - target.instance_eval do - include chef_module - @chef_module = chef_module - def self.method_missing(name, *args, &block) - @chef_module.send(name, *args, &block) - end - def self.const_missing(name) - @chef_module.const_get(name) - end - end - end - - # This patch to CopiedFromChef's ActionClass is necessary for the include to work - require 'chef/resource' - class Chef < ::Chef - class Resource < ::Chef::Resource - module ActionClass - def self.use_inline_resources - end - def self.include_resource_dsl(include_resource_dsl) - end - end - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/constants.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/constants.rb deleted file mode 100644 index 4acd742b..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/constants.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/constants' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: John Keiser -# Copyright:: Copyright 2015-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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. - -class Chef < (defined?(::Chef) ? ::Chef : Object) - NOT_PASSED = Object.new - def NOT_PASSED.to_s - "NOT_PASSED" - end - - def NOT_PASSED.inspect - to_s - end - NOT_PASSED.freeze -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb deleted file mode 100644 index 4fb687e1..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/delayed_evaluator' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: John Keiser -# Copyright:: Copyright 2015-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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. - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class DelayedEvaluator < (defined?(::Chef::DelayedEvaluator) ? ::Chef::DelayedEvaluator : Proc) - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb deleted file mode 100644 index 8e30d304..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb +++ /dev/null @@ -1,73 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/dsl/core' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -#-- -# Author:: Adam Jacob () -# Author:: Christopher Walters () -# Copyright:: Copyright 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/dsl/declare_resource" -require "chef_compat/copied_from_chef/chef/dsl/universal" -require "chef_compat/copied_from_chef/chef/mixin/notifying_block" -require "chef_compat/copied_from_chef/chef/mixin/lazy_module_include" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module DSL - CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL) - # Part of a family of DSL mixins. - # - # Chef::DSL::Recipe mixes into Recipes and LWRP Providers. - # - this does not target core chef resources and providers. - # - this is restricted to recipe/resource/provider context where a resource collection exists. - # - cookbook authors should typically include modules into here. - # - # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers - # - this adds cores providers on top of the Recipe DSL. - # - this is restricted to recipe/resource/provider context where a resource collection exists. - # - core chef authors should typically include modules into here. - # - # Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files. - # - this adds resources and attributes files. - # - do not add helpers which manipulate the resource collection. - # - this is for general-purpose stuff that is useful nearly everywhere. - # - it also pollutes the namespace of nearly every context, watch out. - # - module Core - CopiedFromChef.extend_chef_module(::Chef::DSL::Core, self) if defined?(::Chef::DSL::Core) - include Chef::DSL::Universal - include Chef::DSL::DeclareResource - include Chef::Mixin::NotifyingBlock - extend Chef::Mixin::LazyModuleInclude - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb deleted file mode 100644 index 45e69dc3..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +++ /dev/null @@ -1,315 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/dsl/declare_resource' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -#-- -# Author:: Adam Jacob () -# Author:: Christopher Walters -# Copyright:: Copyright 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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. -# - - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module DSL - CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL) - module DeclareResource - CopiedFromChef.extend_chef_module(::Chef::DSL::DeclareResource, self) if defined?(::Chef::DSL::DeclareResource) - - # Helper for switching run_contexts. Allows for using :parent or :root in place of - # passing the run_context. Executes the block in the run_context. Returns the return - # value of the passed block. - # - # @param rc [Chef::RunContext,Symbol] Either :root, :parent or a Chef::RunContext - # - # @return return value of the block - # - # @example - # # creates/returns a 'service[foo]' resource in the root run_context - # resource = with_run_context(:root) - # edit_resource(:service, "foo") do - # action :nothing - # end - # end - # - def with_run_context(rc) - raise ArgumentError, "with_run_context is useless without a block" unless block_given? - old_run_context = @run_context - @run_context = - case rc - when Chef::RunContext - rc - when :root - run_context.root_run_context - when :parent - run_context.parent_run_context - else - raise ArgumentError, "bad argument to run_context helper, must be :root, :parent, or a Chef::RunContext" - end - yield - ensure - @run_context = old_run_context - end - - # Lookup a resource in the resource collection by name and delete it. This - # will raise Chef::Exceptions::ResourceNotFound if the resource is not found. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # - # @return [Chef::Resource] The resource - # - # @example - # delete_resource!(:template, '/x/y.txy') - # - def delete_resource!(type, name, run_context: self.run_context) - run_context.resource_collection.delete("#{type}[#{name}]").tap do |resource| - # Purge any pending notifications too. This will not raise an exception - # if there are no notifications. - if resource - run_context.before_notification_collection.delete(resource.declared_key) - run_context.immediate_notification_collection.delete(resource.declared_key) - run_context.delayed_notification_collection.delete(resource.declared_key) - end - end - end - - # Lookup a resource in the resource collection by name and delete it. Returns - # nil if the resource is not found and should not fail. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # - # @return [Chef::Resource] The resource - # - # @example - # delete_resource(:template, '/x/y.txy') - # - def delete_resource(type, name, run_context: self.run_context) - delete_resource!(type, name, run_context: run_context) - rescue Chef::Exceptions::ResourceNotFound - nil - end - - # Lookup a resource in the resource collection by name and edit the resource. If the resource is not - # found this will raise Chef::Exceptions::ResourceNotFound. This is the correct API to use for - # "chef_rewind" functionality. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # @param resource_attrs_block A block that lets you set attributes of the - # resource (it is instance_eval'd on the resource instance). - # - # @return [Chef::Resource] The updated resource - # - # @example - # edit_resource!(:template, '/x/y.txy') do - # cookbook_name: cookbook_name - # end - # - def edit_resource!(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block) - resource = find_resource!(type, name, run_context: run_context) - if resource_attrs_block - if defined?(new_resource) - resource.instance_exec(new_resource, &resource_attrs_block) - else - resource.instance_exec(&resource_attrs_block) - end - end - resource - end - - # Lookup a resource in the resource collection by name. If it exists, - # return it. If it does not exist, create it. This is a useful function - # for accumulator patterns. In CRUD terminology this is an "upsert" operation and is - # used to assert that the resource must exist with the specified properties. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param created_at [String] The caller of the resource. Use `caller[0]` - # to get the caller of your function. Defaults to the caller of this - # function. - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # @param resource_attrs_block A block that lets you set attributes of the - # resource (it is instance_eval'd on the resource instance). - # - # @return [Chef::Resource] The updated or created resource - # - # @example - # resource = edit_resource(:template, '/x/y.txy') do - # source "y.txy.erb" - # variables {} - # end - # resource.variables.merge!({ home: "/home/klowns" }) - # - def edit_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block) - edit_resource!(type, name, created_at, run_context: run_context, &resource_attrs_block) - rescue Chef::Exceptions::ResourceNotFound - declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block) - end - - # Lookup a resource in the resource collection by name. If the resource is not - # found this will raise Chef::Exceptions::ResourceNotFound. This API is identical to the - # resources() call and while it is a synonym it is not intended to deprecate that call. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # - # @return [Chef::Resource] The updated resource - # - # @example - # resource = find_resource!(:template, '/x/y.txy') - # - def find_resource!(type, name, run_context: self.run_context) - raise ArgumentError, "find_resource! does not take a block" if block_given? - run_context.resource_collection.find(type => name) - end - - # Lookup a resource in the resource collection by name. If the resource is not found - # the will be no exception raised and the call will return nil. If a block is given and - # no resource is found it will create the resource using the block, if the resource is - # found then the block will not be applied. The block version is similar to create_if_missing - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # - # @return [Chef::Resource] The updated resource - # - # @example - # if ( find_resource(:template, '/x/y.txy') ) - # # do something - # else - # # don't worry about the error - # end - # - # @example - # # this API can be used to return a resource from an outer run context, and will only create - # # an action :nothing service if one does not already exist. - # resource = with_run_context(:root) do - # find_resource(:service, 'whatever') do - # action :nothing - # end - # end - # - def find_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block) - find_resource!(type, name, run_context: run_context) - rescue Chef::Exceptions::ResourceNotFound - if resource_attrs_block - declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block) - end # returns nil otherwise - end - - # Instantiates a resource (via #build_resource), then adds it to the - # resource collection. Note that resource classes are looked up directly, - # so this will create the resource you intended even if the method name - # corresponding to that resource has been overridden. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param created_at [String] The caller of the resource. Use `caller[0]` - # to get the caller of your function. Defaults to the caller of this - # function. - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # @param resource_attrs_block A block that lets you set attributes of the - # resource (it is instance_eval'd on the resource instance). - # - # @return [Chef::Resource] The new resource. - # - # @example - # declare_resource(:file, '/x/y.txy', caller[0]) do - # action :delete - # end - # # Equivalent to - # file '/x/y.txt' do - # action :delete - # end - # - def declare_resource(type, name, created_at = nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block) - created_at ||= caller[0] - - if create_if_missing - Chef::Log.deprecation "build_resource with a create_if_missing flag is deprecated, use edit_resource instead" - # midly goofy since we call edit_resource only to re-call ourselves, but that's why its deprecated... - return edit_resource(type, name, created_at, run_context: run_context, &resource_attrs_block) - end - - resource = build_resource(type, name, created_at, &resource_attrs_block) - - run_context.resource_collection.insert(resource, resource_type: type, instance_name: name) - resource - end - - # Instantiate a resource of the given +type+ with the given +name+ and - # attributes as given in the +resource_attrs_block+. - # - # The resource is NOT added to the resource collection. - # - # @param type [Symbol] The type of resource (e.g. `:file` or `:package`) - # @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2') - # @param created_at [String] The caller of the resource. Use `caller[0]` - # to get the caller of your function. Defaults to the caller of this - # function. - # @param run_context [Chef::RunContext] the run_context of the resource collection to operate on - # @param resource_attrs_block A block that lets you set attributes of the - # resource (it is instance_eval'd on the resource instance). - # - # @return [Chef::Resource] The new resource. - # - # @example - # build_resource(:file, '/x/y.txy', caller[0]) do - # action :delete - # end - # - def build_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block) - created_at ||= caller[0] - - # this needs to be lazy in order to avoid circular dependencies since ResourceBuilder - # will requires the entire provider+resolver universe - require "chef_compat/copied_from_chef/chef/resource_builder" unless defined?(Chef::ResourceBuilder) - - Chef::ResourceBuilder.new( - type: type, - name: name, - created_at: created_at, - params: @params, - run_context: run_context, - cookbook_name: cookbook_name, - recipe_name: recipe_name, - enclosing_provider: self.is_a?(Chef::Provider) ? self : nil - ).build(&resource_attrs_block) - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb deleted file mode 100644 index 78860004..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb +++ /dev/null @@ -1,292 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/dsl/platform_introspection' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Adam Jacob () -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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. -# - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module DSL - CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL) - - # == Chef::DSL::PlatformIntrospection - # Provides the DSL for platform-dependent switch logic, such as - # #value_for_platform. - module PlatformIntrospection - CopiedFromChef.extend_chef_module(::Chef::DSL::PlatformIntrospection, self) if defined?(::Chef::DSL::PlatformIntrospection) - - # Implementation class for determining platform dependent values - class PlatformDependentValue < (defined?(::Chef::DSL::PlatformIntrospection::PlatformDependentValue) ? ::Chef::DSL::PlatformIntrospection::PlatformDependentValue : Object) - - # Create a platform dependent value object. - # === Arguments - # platform_hash (Hash) a hash of the same structure as Chef::Platform, - # like this: - # { - # :debian => {:default => 'the value for all debian'} - # [:centos, :redhat, :fedora] => {:default => "value for all EL variants"} - # :ubuntu => { :default => "default for ubuntu", '10.04' => "value for 10.04 only"}, - # :default => "the default when nothing else matches" - # } - # * platforms can be specified as Symbols or Strings - # * multiple platforms can be grouped by using an Array as the key - # * values for platforms need to be Hashes of the form: - # {platform_version => value_for_that_version} - # * the exception to the above is the default value, which is given as - # :default => default_value - def initialize(platform_hash) -super if defined?(::Chef::DSL::PlatformIntrospection::PlatformDependentValue) - @values = {} - platform_hash.each { |platforms, value| set(platforms, value) } - end - - def value_for_node(node) - platform, version = node[:platform].to_s, node[:platform_version].to_s - # Check if we match a version constraint via Chef::VersionConstraint::Platform and Chef::Version::Platform - matched_value = match_versions(node) - if @values.key?(platform) && @values[platform].key?(version) - @values[platform][version] - elsif matched_value - matched_value - elsif @values.key?(platform) && @values[platform].key?("default") - @values[platform]["default"] - elsif @values.key?("default") - @values["default"] - else - nil - end - end - - private - - def match_versions(node) - begin - platform, version = node[:platform].to_s, node[:platform_version].to_s - return nil unless @values.key?(platform) - node_version = Chef::Version::Platform.new(version) - key_matches = [] - keys = @values[platform].keys - keys.each do |k| - begin - if Chef::VersionConstraint::Platform.new(k).include?(node_version) - key_matches << k - end - rescue Chef::Exceptions::InvalidVersionConstraint => e - Chef::Log.debug "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint::Platform." - Chef::Log.debug(e) - end - end - return @values[platform][version] if key_matches.include?(version) - case key_matches.length - when 0 - return nil - when 1 - return @values[platform][key_matches.first] - else - raise "Multiple matches detected for #{platform} with values #{@values}. The matches are: #{key_matches}" - end - rescue Chef::Exceptions::InvalidCookbookVersion => e - # Lets not break because someone passes a weird string like 'default' :) - Chef::Log.debug(e) - Chef::Log.debug "InvalidCookbookVersion exceptions are common and expected here: the generic constraint matcher attempted to match something which is not a constraint. Moving on to next version or constraint" - return nil - rescue Chef::Exceptions::InvalidPlatformVersion => e - Chef::Log.debug "Caught InvalidPlatformVersion, this means that Chef::Version::Platform does not know how to turn #{node_version} into an x.y.z format" - Chef::Log.debug(e) - return nil - end - end - - def set(platforms, value) - if platforms.to_s == "default" - @values["default"] = value - else - assert_valid_platform_values!(platforms, value) - Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value) } - value - end - end - - def normalize_keys(hash) - hash.inject({}) do |h, key_value| - keys, value = *key_value - Array(keys).each do |key| - h[key.to_s] = value - end - h - end - end - - def assert_valid_platform_values!(platforms, value) - unless value.kind_of?(Hash) - msg = "platform dependent values must be specified in the format :platform => {:version => value} " - msg << "you gave a value #{value.inspect} for platform(s) #{platforms}" - raise ArgumentError, msg - end - end - end - - # Given a hash similar to the one we use for Platforms, select a value from the hash. Supports - # per platform defaults, along with a single base default. Arrays may be passed as hash keys and - # will be expanded. - # - # === Parameters - # platform_hash:: A platform-style hash. - # - # === Returns - # value:: Whatever the most specific value of the hash is. - def value_for_platform(platform_hash) - PlatformDependentValue.new(platform_hash).value_for_node(node) - end - - # Given a list of platforms, returns true if the current recipe is being run on a node with - # that platform, false otherwise. - # - # === Parameters - # args:: A list of platforms. Each platform can be in string or symbol format. - # - # === Returns - # true:: If the current platform is in the list - # false:: If the current platform is not in the list - def platform?(*args) - has_platform = false - - args.flatten.each do |platform| - has_platform = true if platform.to_s == node[:platform] - end - - has_platform - end - - # Implementation class for determining platform family dependent values - class PlatformFamilyDependentValue < (defined?(::Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue) ? ::Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue : Object) - - # Create a platform family dependent value object. - # === Arguments - # platform_family_hash (Hash) a map of platform families to values. - # like this: - # { - # :rhel => "value for all EL variants" - # :fedora => "value for fedora variants fedora and amazon" , - # [:fedora, :rhel] => "value for all known redhat variants" - # :debian => "value for debian variants including debian, ubuntu, mint" , - # :default => "the default when nothing else matches" - # } - # * platform families can be specified as Symbols or Strings - # * multiple platform families can be grouped by using an Array as the key - # * values for platform families can be any object, with no restrictions. Some examples: - # - [:stop, :start] - # - "mysql-devel" - # - { :key => "value" } - def initialize(platform_family_hash) -super if defined?(::Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue) - @values = {} - @values["default"] = nil - platform_family_hash.each { |platform_families, value| set(platform_families, value) } - end - - def value_for_node(node) - if node.key?(:platform_family) - platform_family = node[:platform_family].to_s - if @values.key?(platform_family) - @values[platform_family] - else - @values["default"] - end - else - @values["default"] - end - end - - private - - def set(platform_family, value) - if platform_family.to_s == "default" - @values["default"] = value - else - Array(platform_family).each { |family| @values[family.to_s] = value } - value - end - end - end - - # Given a hash mapping platform families to values, select a value from the hash. Supports a single - # base default if platform family is not in the map. Arrays may be passed as hash keys and will be - # expanded - # - # === Parameters - # platform_family_hash:: A hash in the form { platform_family_name => value } - # - # === Returns - # value:: Whatever the most specific value of the hash is. - def value_for_platform_family(platform_family_hash) - PlatformFamilyDependentValue.new(platform_family_hash).value_for_node(node) - end - - # Given a list of platform families, returns true if the current recipe is being run on a - # node within that platform family, false otherwise. - # - # === Parameters - # args:: A list of platform families. Each platform family can be in string or symbol format. - # - # === Returns - # true:: if the current node platform family is in the list. - # false:: if the current node platform family is not in the list. - def platform_family?(*args) - args.flatten.any? do |platform_family| - platform_family.to_s == node[:platform_family] - end - end - - # Shamelessly stolen from https://github.com/sethvargo/chef-sugar/blob/master/lib/chef/sugar/docker.rb - # Given a node object, returns whether the node is a docker container. - # - # === Parameters - # node:: [Chef::Node] The node to check. - # - # === Returns - # true:: if the current node is a docker container - # false:: if the current node is not a docker container - def docker?(node = run_context.nil? ? nil : run_context.node) - # Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad, - # and that makes us sad too. - node && node[:virtualization] && node[:virtualization][:systems] && - node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest" - end - - end - end -end - -# **DEPRECATED** -# This used to be part of chef/mixin/language. Load the file to activate the deprecation code. -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb deleted file mode 100644 index f896ec7c..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb +++ /dev/null @@ -1,37 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/dsl/recipe' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -require "chef_compat/copied_from_chef/chef/dsl/core" -require "chef_compat/copied_from_chef/chef/mixin/lazy_module_include" -class Chef < (defined?(::Chef) ? ::Chef : Object) - module DSL - CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL) - module Recipe - CopiedFromChef.extend_chef_module(::Chef::DSL::Recipe, self) if defined?(::Chef::DSL::Recipe) - include Chef::DSL::Core - extend Chef::Mixin::LazyModuleInclude - module FullDSL - CopiedFromChef.extend_chef_module(::Chef::DSL::Recipe::FullDSL, self) if defined?(::Chef::DSL::Recipe::FullDSL) - include Chef::DSL::Recipe - extend Chef::Mixin::LazyModuleInclude - end - end - end -end -require "chef_compat/copied_from_chef/chef/resource" -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb deleted file mode 100644 index 7f529f1c..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb +++ /dev/null @@ -1,70 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/dsl/universal' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -#-- -# Author:: Adam Jacob () -# Author:: Christopher Walters () -# Copyright:: Copyright 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/dsl/platform_introspection" -require "chef_compat/copied_from_chef/chef/mixin/powershell_out" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module DSL - CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL) - # Part of a family of DSL mixins. - # - # Chef::DSL::Recipe mixes into Recipes and LWRP Providers. - # - this does not target core chef resources and providers. - # - this is restricted to recipe/resource/provider context where a resource collection exists. - # - cookbook authors should typically include modules into here. - # - # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers - # - this adds cores providers on top of the Recipe DSL. - # - this is restricted to recipe/resource/provider context where a resource collection exists. - # - core chef authors should typically include modules into here. - # - # Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files. - # - this adds resources and attributes files. - # - do not add helpers which manipulate the resource collection. - # - this is for general-purpose stuff that is useful nearly everywhere. - # - it also pollutes the namespace of nearly every context, watch out. - # - module Universal - CopiedFromChef.extend_chef_module(::Chef::DSL::Universal, self) if defined?(::Chef::DSL::Universal) - include Chef::DSL::PlatformIntrospection - include Chef::Mixin::PowershellOut - include Chef::Mixin::ShellOut - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb deleted file mode 100644 index a6b52441..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb +++ /dev/null @@ -1,98 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/mixin/lazy_module_include' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Copyright:: Copyright 2011-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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. -# - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module Mixin - CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin) - # If you have: - # - # module A - # extend LazyModuleInclude - # end - # - # module B - # include A - # end - # - # module C - # include B - # end - # - # module Monkeypatches - # def monkey - # puts "monkey!" - # end - # end - # - # A.send(:include, Monkeypatches) - # - # Then B and C and any classes that they're included in will also get the #monkey method patched into them. - # - module LazyModuleInclude - CopiedFromChef.extend_chef_module(::Chef::Mixin::LazyModuleInclude, self) if defined?(::Chef::Mixin::LazyModuleInclude) - - # Most of the magick is in this hook which creates a closure over the parent class and then builds an - # "infector" module which infects all descendants and which is responsible for updating the list of - # descendants in the parent class. - def included(klass) - super - parent_klass = self - infector = Module.new do - define_method(:included) do |subklass| - super(subklass) - subklass.extend(infector) - parent_klass.descendants.push(subklass) - end - end - klass.extend(infector) - parent_klass.descendants.push(klass) - end - - def descendants - @descendants ||= [] - end - - def include(*classes) - super - classes.each do |klass| - descendants.each do |descendant| - descendant.send(:include, klass) - end - end - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb deleted file mode 100644 index 0b90e276..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb +++ /dev/null @@ -1,74 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/mixin/notifying_block' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -#-- -# Author:: Lamont Granquist -# Copyright:: Copyright 2010-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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. - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module Mixin - CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin) - module NotifyingBlock - CopiedFromChef.extend_chef_module(::Chef::Mixin::NotifyingBlock, self) if defined?(::Chef::Mixin::NotifyingBlock) - - def notifying_block(&block) - begin - subcontext = subcontext_block(&block) - Chef::Runner.new(subcontext).converge - ensure - # recipes don't have a new_resource - if respond_to?(:new_resource) - if subcontext && subcontext.resource_collection.any?(&:updated?) - new_resource.updated_by_last_action(true) - end - end - end - end - - def subcontext_block(parent_context = nil, &block) - parent_context ||= @run_context - sub_run_context = parent_context.create_child - - begin - outer_run_context = @run_context - @run_context = sub_run_context - instance_eval(&block) - ensure - @run_context = outer_run_context - end - - sub_run_context - end - - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb deleted file mode 100644 index 0a16147d..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +++ /dev/null @@ -1,510 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/mixin/params_validate' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Adam Jacob () -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/constants" -require "chef_compat/copied_from_chef/chef/property" -require "chef_compat/copied_from_chef/chef/delayed_evaluator" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module Mixin - CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin) - module ParamsValidate - CopiedFromChef.extend_chef_module(::Chef::Mixin::ParamsValidate, self) if defined?(::Chef::Mixin::ParamsValidate) - # Takes a hash of options, along with a map to validate them. Returns the original - # options hash, plus any changes that might have been made (through things like setting - # default values in the validation map) - # - # For example: - # - # validate({ :one => "neat" }, { :one => { :kind_of => String }}) - # - # Would raise an exception if the value of :one above is not a kind_of? string. Valid - # map options are: - # - # @param opts [Hash] Validation opts. - # @option opts [Object,Array] :is An object, or list of - # objects, that must match the value using Ruby's `===` operator - # (`opts[:is].any? { |v| v === value }`). (See #_pv_is.) - # @option opts [Object,Array] :equal_to An object, or list - # of objects, that must be equal to the value using Ruby's `==` - # operator (`opts[:is].any? { |v| v == value }`) (See #_pv_equal_to.) - # @option opts [Regexp,Array] :regex An object, or - # list of objects, that must match the value with `regex.match(value)`. - # (See #_pv_regex) - # @option opts [Class,Array] :kind_of A class, or - # list of classes, that the value must be an instance of. (See - # #_pv_kind_of.) - # @option opts [Hash] :callbacks A hash of - # messages -> procs, all of which match the value. The proc must - # return a truthy or falsey value (true means it matches). (See - # #_pv_callbacks.) - # @option opts [Symbol,Array] :respond_to A method - # name, or list of method names, the value must respond to. (See - # #_pv_respond_to.) - # @option opts [Symbol,Array] :cannot_be A property, - # or a list of properties, that the value cannot have (such as `:nil` or - # `:empty`). The method with a questionmark at the end is called on the - # value (e.g. `value.empty?`). If the value does not have this method, - # it is considered valid (i.e. if you don't respond to `empty?` we - # assume you are not empty). (See #_pv_cannot_be.) - # @option opts [Proc] :coerce A proc which will be called to - # transform the user input to canonical form. The value is passed in, - # and the transformed value returned as output. Lazy values will *not* - # be passed to this method until after they are evaluated. Called in the - # context of the resource (meaning you can access other properties). - # (See #_pv_coerce.) (See #_pv_coerce.) - # @option opts [Boolean] :required `true` if this property - # must be present and not `nil`; `false` otherwise. This is checked - # after the resource is fully initialized. (See #_pv_required.) - # @option opts [Boolean] :name_property `true` if this - # property defaults to the same value as `name`. Equivalent to - # `default: lazy { name }`, except that #property_is_set? will - # return `true` if the property is set *or* if `name` is set. (See - # #_pv_name_property.) - # @option opts [Boolean] :name_attribute Same as `name_property`. - # @option opts [Object] :default The value this property - # will return if the user does not set one. If this is `lazy`, it will - # be run in the context of the instance (and able to access other - # properties). (See #_pv_default.) - # - def validate(opts, map) - map = map.validation_options if map.is_a?(Property) - - #-- - # validate works by taking the keys in the validation map, assuming it's a hash, and - # looking for _pv_:symbol as methods. Assuming it find them, it calls the right - # one. - #++ - raise ArgumentError, "Options must be a hash" unless opts.kind_of?(Hash) - raise ArgumentError, "Validation Map must be a hash" unless map.kind_of?(Hash) - - map.each do |key, validation| - unless key.kind_of?(Symbol) || key.kind_of?(String) - raise ArgumentError, "Validation map keys must be symbols or strings!" - end - case validation - when true - _pv_required(opts, key) - when false - true - when Hash - validation.each do |check, carg| - check_method = "_pv_#{check}" - if self.respond_to?(check_method, true) - self.send(check_method, opts, key, carg) - else - raise ArgumentError, "Validation map has unknown check: #{check}" - end - end - end - end - opts - end - - def lazy(&block) - DelayedEvaluator.new(&block) - end - - def set_or_return(symbol, value, validation) - property = SetOrReturnProperty.new(name: symbol, **validation) - property.call(self, value) - end - - private - - def explicitly_allows_nil?(key, validation) - validation.has_key?(:is) && _pv_is({ key => nil }, key, validation[:is], raise_error: false) - end - - # Return the value of a parameter, or nil if it doesn't exist. - def _pv_opts_lookup(opts, key) - if opts.has_key?(key.to_s) - opts[key.to_s] - elsif opts.has_key?(key.to_sym) - opts[key.to_sym] - else - nil - end - end - - # Raise an exception if the parameter is not found. - def _pv_required(opts, key, is_required = true, explicitly_allows_nil = false) - if is_required - return true if opts.has_key?(key.to_s) && (explicitly_allows_nil || !opts[key.to_s].nil?) - return true if opts.has_key?(key.to_sym) && (explicitly_allows_nil || !opts[key.to_sym].nil?) - raise Exceptions::ValidationFailed, "Required argument #{key.inspect} is missing!" - end - true - end - - # - # List of things values must be equal to. - # - # Uses Ruby's `==` to evaluate (equal_to == value). At least one must - # match for the value to be valid. - # - # `nil` passes this validation automatically. - # - # @return [Array,nil] List of things values must be equal to, or nil if - # equal_to is unspecified. - # - def _pv_equal_to(opts, key, to_be) - value = _pv_opts_lookup(opts, key) - unless value.nil? - to_be = Array(to_be) - to_be.each do |tb| - return true if value == tb - end - raise Exceptions::ValidationFailed, "Option #{key} must be equal to one of: #{to_be.join(", ")}! You passed #{value.inspect}." - end - end - - # - # List of things values must be instances of. - # - # Uses value.kind_of?(kind_of) to evaluate. At least one must match for - # the value to be valid. - # - # `nil` automatically passes this validation. - # - def _pv_kind_of(opts, key, to_be) - value = _pv_opts_lookup(opts, key) - unless value.nil? - to_be = Array(to_be) - to_be.each do |tb| - return true if value.kind_of?(tb) - end - raise Exceptions::ValidationFailed, "Option #{key} must be a kind of #{to_be}! You passed #{value.inspect}." - end - end - - # - # List of method names values must respond to. - # - # Uses value.respond_to?(respond_to) to evaluate. At least one must match - # for the value to be valid. - # - def _pv_respond_to(opts, key, method_name_list) - value = _pv_opts_lookup(opts, key) - unless value.nil? - Array(method_name_list).each do |method_name| - unless value.respond_to?(method_name) - raise Exceptions::ValidationFailed, "Option #{key} must have a #{method_name} method!" - end - end - end - end - - # - # List of things that must not be true about the value. - # - # Calls `value.?` All responses must be false for the value to be - # valid. - # Values which do not respond to ? are considered valid (because if - # a value doesn't respond to `:readable?`, then it probably isn't - # readable.) - # - # @example - # ```ruby - # property :x, cannot_be: [ :nil, :empty ] - # x [ 1, 2 ] #=> valid - # x 1 #=> valid - # x [] #=> invalid - # x nil #=> invalid - # ``` - # - def _pv_cannot_be(opts, key, predicate_method_base_name) - value = _pv_opts_lookup(opts, key) - if !value.nil? - Array(predicate_method_base_name).each do |method_name| - predicate_method = :"#{method_name}?" - - if value.respond_to?(predicate_method) - if value.send(predicate_method) - raise Exceptions::ValidationFailed, "Option #{key} cannot be #{predicate_method_base_name}" - end - end - end - end - end - - # - # The default value for a property. - # - # When the property is not assigned, this will be used. - # - # If this is a lazy value, it will either be passed the resource as a value, - # or if the lazy proc does not take parameters, it will be run in the - # context of the instance with instance_eval. - # - # @example - # ```ruby - # property :x, default: 10 - # ``` - # - # @example - # ```ruby - # property :x - # property :y, default: lazy { x+2 } - # ``` - # - # @example - # ```ruby - # property :x - # property :y, default: lazy { |r| r.x+2 } - # ``` - # - def _pv_default(opts, key, default_value) - value = _pv_opts_lookup(opts, key) - if value.nil? - default_value = default_value.freeze if !default_value.is_a?(DelayedEvaluator) - opts[key] = default_value - end - end - - # - # List of regexes values that must match. - # - # Uses regex.match() to evaluate. At least one must match for the value to - # be valid. - # - # `nil` passes regex validation automatically. - # - # @example - # ```ruby - # property :x, regex: [ /abc/, /xyz/ ] - # ``` - # - def _pv_regex(opts, key, regex) - value = _pv_opts_lookup(opts, key) - if !value.nil? - Array(regex).flatten.each do |r| - return true if r.match(value.to_s) - end - raise Exceptions::ValidationFailed, "Option #{key}'s value #{value} does not match regular expression #{regex.inspect}" - end - end - - # - # List of procs we pass the value to. - # - # All procs must return true for the value to be valid. If any procs do - # not return true, the key will be used for the message: `"Property x's - # value :y "`. - # - # @example - # ```ruby - # property :x, callbacks: { "is bigger than 10" => proc { |v| v <= 10 }, "is not awesome" => proc { |v| !v.awesome }} - # ``` - # - def _pv_callbacks(opts, key, callbacks) - raise ArgumentError, "Callback list must be a hash!" unless callbacks.kind_of?(Hash) - value = _pv_opts_lookup(opts, key) - if !value.nil? - callbacks.each do |message, zeproc| - unless zeproc.call(value) - raise Exceptions::ValidationFailed, "Option #{key}'s value #{value} #{message}!" - end - end - end - end - - # - # Allows a parameter to default to the value of the resource name. - # - # @example - # ```ruby - # property :x, name_property: true - # ``` - # - def _pv_name_property(opts, key, is_name_property = true) - if is_name_property - if opts[key].nil? - raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate - opts[key] = self.instance_variable_get(:"@name") - end - end - end - alias :_pv_name_attribute :_pv_name_property - - # - # List of valid things values can be. - # - # Uses Ruby's `===` to evaluate (is === value). At least one must match - # for the value to be valid. - # - # If a proc is passed, it is instance_eval'd in the resource, passed the - # value, and must return a truthy or falsey value. - # - # @example Class - # ```ruby - # property :x, String - # x 'valid' #=> valid - # x 1 #=> invalid - # x nil #=> invalid - # - # @example Value - # ```ruby - # property :x, [ :a, :b, :c, nil ] - # x :a #=> valid - # x nil #=> valid - # ``` - # - # @example Regex - # ```ruby - # property :x, /bar/ - # x 'foobar' #=> valid - # x 'foo' #=> invalid - # x nil #=> invalid - # ``` - # - # @example Proc - # ```ruby - # property :x, proc { |x| x > y } - # property :y, default: 2 - # x 3 #=> valid - # x 1 #=> invalid - # ``` - # - # @example Property - # ```ruby - # type = Property.new(is: String) - # property :x, type - # x 'foo' #=> valid - # x 1 #=> invalid - # x nil #=> invalid - # ``` - # - # @example RSpec Matcher - # ```ruby - # include RSpec::Matchers - # property :x, a_string_matching /bar/ - # x 'foobar' #=> valid - # x 'foo' #=> invalid - # x nil #=> invalid - # ``` - # - def _pv_is(opts, key, to_be, raise_error: true) - return true if !opts.has_key?(key.to_s) && !opts.has_key?(key.to_sym) - value = _pv_opts_lookup(opts, key) - to_be = [ to_be ].flatten(1) - errors = [] - passed = to_be.any? do |tb| - case tb - when Proc - raise CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate - instance_exec(value, &tb) - when Property - begin - validate(opts, { key => tb.validation_options }) - true - rescue Exceptions::ValidationFailed - # re-raise immediately if there is only one "is" so we get a better stack - raise if to_be.size == 1 - errors << $! - false - end - else - tb === value - end - end - if passed - true - else - message = "Property #{key} must be one of: #{to_be.map { |v| v.inspect }.join(", ")}! You passed #{value.inspect}." - unless errors.empty? - message << " Errors:\n#{errors.map { |m| "- #{m}" }.join("\n")}" - end - raise Exceptions::ValidationFailed, message - end - end - - # - # Method to mess with a value before it is validated and stored. - # - # Allows you to transform values into a canonical form that is easy to - # work with. - # - # This is passed the value to transform, and is run in the context of the - # instance (so it has access to other resource properties). It must return - # the value that will be stored in the instance. - # - # @example - # ```ruby - # property :x, Integer, coerce: { |v| v.to_i } - # ``` - # - def _pv_coerce(opts, key, coercer) - if opts.has_key?(key.to_s) - raise CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate - opts[key.to_s] = instance_exec(opts[key], &coercer) - elsif opts.has_key?(key.to_sym) - raise CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate - opts[key.to_sym] = instance_exec(opts[key], &coercer) - end - end - - # We allow Chef::Mixin::ParamsValidate.validate(), but we will raise an - # error if you try to do anything requiring there to be an actual resource. - # This way, you can statically validate things if you have constant validation - # (which is the norm). - extend self - - # Used by #set_or_return to avoid emitting a deprecation warning for - # "value nil" and to keep default stickiness working exactly the same - # @api private - class SetOrReturnProperty < (defined?(::Chef::Mixin::ParamsValidate::SetOrReturnProperty) ? ::Chef::Mixin::ParamsValidate::SetOrReturnProperty : Chef::Property) - def get(resource, nil_set: false) - value = super - # All values are sticky, frozen or not - if !is_set?(resource) - set_value(resource, value) - end - value - end - - def call(resource, value = NOT_PASSED) - # setting to nil does a get - if value.nil? && !explicitly_accepts_nil?(resource) - get(resource, nil_set: true) - else - super - end - end - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/powershell_out.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/powershell_out.rb deleted file mode 100644 index b6b56f9a..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/powershell_out.rb +++ /dev/null @@ -1,117 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/mixin/powershell_out' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -#-- -# Copyright:: Copyright 2015-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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. - - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module Mixin - CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin) - module PowershellOut - CopiedFromChef.extend_chef_module(::Chef::Mixin::PowershellOut, self) if defined?(::Chef::Mixin::PowershellOut) - include Chef::Mixin::ShellOut - include Chef::Mixin::WindowsArchitectureHelper - - # Run a command under powershell with the same API as shell_out. The - # options hash is extended to take an "architecture" flag which - # can be set to :i386 or :x86_64 to force the windows architecture. - # - # @param script [String] script to run - # @param options [Hash] options hash - # @return [Mixlib::Shellout] mixlib-shellout object - def powershell_out(*command_args) - script = command_args.first - options = command_args.last.is_a?(Hash) ? command_args.last : nil - - run_command_with_os_architecture(script, options) - end - - # Run a command under powershell with the same API as shell_out! - # (raises exceptions on errors) - # - # @param script [String] script to run - # @param options [Hash] options hash - # @return [Mixlib::Shellout] mixlib-shellout object - def powershell_out!(*command_args) - cmd = powershell_out(*command_args) - cmd.error! - cmd - end - - private - - # Helper function to run shell_out and wrap it with the correct - # flags to possibly disable WOW64 redirection (which we often need - # because chef-client runs as a 32-bit app on 64-bit windows). - # - # @param script [String] script to run - # @param options [Hash] options hash - # @return [Mixlib::Shellout] mixlib-shellout object - def run_command_with_os_architecture(script, options) - options ||= {} - options = options.dup - arch = options.delete(:architecture) - - with_os_architecture(nil, architecture: arch) do - shell_out( - build_powershell_command(script), - options - ) - end - end - - # Helper to build a powershell command around the script to run. - # - # @param script [String] script to run - # @retrurn [String] powershell command to execute - def build_powershell_command(script) - flags = [ - # Hides the copyright banner at startup. - "-NoLogo", - # Does not present an interactive prompt to the user. - "-NonInteractive", - # Does not load the Windows PowerShell profile. - "-NoProfile", - # always set the ExecutionPolicy flag - # see http://technet.microsoft.com/en-us/library/ee176961.aspx - "-ExecutionPolicy Unrestricted", - # Powershell will hang if STDIN is redirected - # http://connect.microsoft.com/PowerShell/feedback/details/572313/powershell-exe-can-hang-if-stdin-is-redirected - "-InputFormat None", - ] - - "powershell.exe #{flags.join(' ')} -Command \"#{script.gsub('"', '\"')}\"" - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb deleted file mode 100644 index bdf9f7e4..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb +++ /dev/null @@ -1,328 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/mixin/properties' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -require "chef_compat/copied_from_chef/chef/delayed_evaluator" -require "chef_compat/copied_from_chef/chef/mixin/params_validate" -require "chef_compat/copied_from_chef/chef/property" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - module Mixin - CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin) - module Properties - CopiedFromChef.extend_chef_module(::Chef::Mixin::Properties, self) if defined?(::Chef::Mixin::Properties) - module ClassMethods - CopiedFromChef.extend_chef_module(::Chef::Mixin::Properties::ClassMethods, self) if defined?(::Chef::Mixin::Properties::ClassMethods) - # - # The list of properties defined on this resource. - # - # Everything defined with `property` is in this list. - # - # @param include_superclass [Boolean] `true` to include properties defined - # on superclasses; `false` or `nil` to return the list of properties - # directly on this class. - # - # @return [Hash] The list of property names and types. - # - def properties(include_superclass = true) - if include_superclass - result = {} - ancestors.reverse_each { |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) } - result - else - @properties ||= {} - end - end - - # - # Create a property on this resource class. - # - # If a superclass has this property, or if this property has already been - # defined by this resource, this will *override* the previous value. - # - # @param name [Symbol] The name of the property. - # @param type [Object,Array] The type(s) of this property. - # If present, this is prepended to the `is` validation option. - # @param options [Hash] Validation options. - # @option options [Object,Array] :is An object, or list of - # objects, that must match the value using Ruby's `===` operator - # (`options[:is].any? { |v| v === value }`). - # @option options [Object,Array] :equal_to An object, or list - # of objects, that must be equal to the value using Ruby's `==` - # operator (`options[:is].any? { |v| v == value }`) - # @option options [Regexp,Array] :regex An object, or - # list of objects, that must match the value with `regex.match(value)`. - # @option options [Class,Array] :kind_of A class, or - # list of classes, that the value must be an instance of. - # @option options [Hash] :callbacks A hash of - # messages -> procs, all of which match the value. The proc must - # return a truthy or falsey value (true means it matches). - # @option options [Symbol,Array] :respond_to A method - # name, or list of method names, the value must respond to. - # @option options [Symbol,Array] :cannot_be A property, - # or a list of properties, that the value cannot have (such as `:nil` or - # `:empty`). The method with a questionmark at the end is called on the - # value (e.g. `value.empty?`). If the value does not have this method, - # it is considered valid (i.e. if you don't respond to `empty?` we - # assume you are not empty). - # @option options [Proc] :coerce A proc which will be called to - # transform the user input to canonical form. The value is passed in, - # and the transformed value returned as output. Lazy values will *not* - # be passed to this method until after they are evaluated. Called in the - # context of the resource (meaning you can access other properties). - # @option options [Boolean] :required `true` if this property - # must be present; `false` otherwise. This is checked after the resource - # is fully initialized. - # @option options [Boolean] :name_property `true` if this - # property defaults to the same value as `name`. Equivalent to - # `default: lazy { name }`, except that #property_is_set? will - # return `true` if the property is set *or* if `name` is set. - # @option options [Boolean] :name_attribute Same as `name_property`. - # @option options [Object] :default The value this property - # will return if the user does not set one. If this is `lazy`, it will - # be run in the context of the instance (and able to access other - # properties). - # @option options [Boolean] :desired_state `true` if this property is - # part of desired state. Defaults to `true`. - # @option options [Boolean] :identity `true` if this property - # is part of object identity. Defaults to `false`. - # @option options [Boolean] :sensitive `true` if this property could - # contain sensitive information and whose value should be redacted - # in any resource reporting / auditing output. Defaults to `false`. - # - # @example Bare property - # property :x - # - # @example With just a type - # property :x, String - # - # @example With just options - # property :x, default: 'hi' - # - # @example With type and options - # property :x, String, default: 'hi' - # - def property(name, type = NOT_PASSED, **options) - name = name.to_sym - - options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo } - - options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name) - options[:name] = name - options[:declared_in] = self - - if type == NOT_PASSED - # If a type is not passed, the property derives from the - # superclass property (if any) - if properties.has_key?(name) - property = properties[name].derive(**options) - else - property = property_type(**options) - end - - # If a Property is specified, derive a new one from that. - elsif type.is_a?(Property) || (type.is_a?(Class) && type <= Property) - property = type.derive(**options) - - # If a primitive type was passed, combine it with "is" - else - if options[:is] - options[:is] = ([ type ] + [ options[:is] ]).flatten(1) - else - options[:is] = type - end - property = property_type(**options) - end - - local_properties = properties(false) - local_properties[name] = property - - property.emit_dsl - end - - # - # Create a reusable property type that can be used in multiple properties - # in different resources. - # - # @param options [Hash] Validation options. see #property for - # the list of options. - # - # @example - # property_type(default: 'hi') - # - def property_type(**options) - Property.derive(**options) - end - - # - # Create a lazy value for assignment to a default value. - # - # @param block The block to run when the value is retrieved. - # - # @return [Chef::DelayedEvaluator] The lazy value - # - def lazy(&block) - DelayedEvaluator.new(&block) - end - - # - # Get or set the list of desired state properties for this resource. - # - # State properties are properties that describe the desired state - # of the system, such as file permissions or ownership. - # In general, state properties are properties that could be populated by - # examining the state of the system (e.g., File.stat can tell you the - # permissions on an existing file). Contrarily, properties that are not - # "state properties" usually modify the way Chef itself behaves, for example - # by providing additional options for a package manager to use when - # installing a package. - # - # This list is used by the Chef client auditing system to extract - # information from resources to describe changes made to the system. - # - # This method is unnecessary when declaring properties with `property`; - # properties are added to state_properties by default, and can be turned off - # with `desired_state: false`. - # - # ```ruby - # property :x # part of desired state - # property :y, desired_state: false # not part of desired state - # ``` - # - # @param names [Array] A list of property names to set as desired - # state. - # - # @return [Array] All properties in desired state. - # - def state_properties(*names) - if !names.empty? - names = names.map { |name| name.to_sym }.uniq - - local_properties = properties(false) - # Add new properties to the list. - names.each do |name| - property = properties[name] - if !property - self.property name, instance_variable_name: false, desired_state: true - elsif !property.desired_state? - self.property name, desired_state: true - end - end - - # If state_attrs *excludes* something which is currently desired state, - # mark it as desired_state: false. - local_properties.each do |name, property| - if property.desired_state? && !names.include?(name) - self.property name, desired_state: false - end - end - end - - properties.values.select { |property| property.desired_state? } - end - - # - # Set the identity of this resource to a particular set of properties. - # - # This drives #identity, which returns data that uniquely refers to a given - # resource on the given node (in such a way that it can be correlated - # across Chef runs). - # - # This method is unnecessary when declaring properties with `property`; - # properties can be added to identity during declaration with - # `identity: true`. - # - # ```ruby - # property :x, identity: true # part of identity - # property :y # not part of identity - # ``` - # - # If no properties are marked as identity, "name" is considered the identity. - # - # @param names [Array] A list of property names to set as the identity. - # - # @return [Array] All identity properties. - # - def identity_properties(*names) - if !names.empty? - names = names.map { |name| name.to_sym } - - # Add or change properties that are not part of the identity. - names.each do |name| - property = properties[name] - if !property - self.property name, instance_variable_name: false, identity: true - elsif !property.identity? - self.property name, identity: true - end - end - - # If identity_properties *excludes* something which is currently part of - # the identity, mark it as identity: false. - properties.each do |name, property| - if property.identity? && !names.include?(name) - - self.property name, identity: false - end - end - end - - result = properties.values.select { |property| property.identity? } - result = [ properties[:name] ] if result.empty? - result - end - - def included(other) - other.extend ClassMethods - end - end - - def self.included(other) - other.extend ClassMethods - end - - include Chef::Mixin::ParamsValidate - - # - # Whether this property has been set (or whether it has a default that has - # been retrieved). - # - # @param name [Symbol] The name of the property. - # @return [Boolean] `true` if the property has been set. - # - def property_is_set?(name) - property = self.class.properties[name.to_sym] - raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property - property.is_set?(self) - end - - # - # Clear this property as if it had never been set. It will thereafter return - # the default. - # been retrieved). - # - # @param name [Symbol] The name of the property. - # - def reset_property(name) - property = self.class.properties[name.to_sym] - raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property - property.reset(self) - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb deleted file mode 100644 index 33995968..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb +++ /dev/null @@ -1,713 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/property' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: John Keiser -# Copyright:: Copyright 2015-2016, John Keiser. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/delayed_evaluator" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - # - # Type and validation information for a property on a resource. - # - # A property named "x" manipulates the "@x" instance variable on a - # resource. The *presence* of the variable (`instance_variable_defined?(@x)`) - # tells whether the variable is defined; it may have any actual value, - # constrained only by validation. - # - # Properties may have validation, defaults, and coercion, and have full - # support for lazy values. - # - # @see Chef::Resource.property - # @see Chef::DelayedEvaluator - # - class Property < (defined?(::Chef::Property) ? ::Chef::Property : Object) - # - # Create a reusable property type that can be used in multiple properties - # in different resources. - # - # @param options [Hash] Validation options. See Chef::Resource.property for - # the list of options. - # - # @example - # Property.derive(default: 'hi') - # - def self.derive(**options) - new(**options) - end - - # - # Create a new property. - # - # @param options [Hash] Property options, including - # control options here, as well as validation options (see - # Chef::Mixin::ParamsValidate#validate for a description of validation - # options). - # @option options [Symbol] :name The name of this property. - # @option options [Class] :declared_in The class this property comes from. - # @option options [Symbol] :instance_variable_name The instance variable - # tied to this property. Must include a leading `@`. Defaults to `@`. - # `nil` means the property is opaque and not tied to a specific instance - # variable. - # @option options [Boolean] :desired_state `true` if this property is part of desired - # state. Defaults to `true`. - # @option options [Boolean] :identity `true` if this property is part of object - # identity. Defaults to `false`. - # @option options [Boolean] :name_property `true` if this - # property defaults to the same value as `name`. Equivalent to - # `default: lazy { name }`, except that #property_is_set? will - # return `true` if the property is set *or* if `name` is set. - # @option options [Boolean] :nillable `true` opt-in to Chef-13 style behavior where - # attempting to set a nil value will really set a nil value instead of issuing - # a warning and operating like a getter - # @option options [Object] :default The value this property - # will return if the user does not set one. If this is `lazy`, it will - # be run in the context of the instance (and able to access other - # properties) and cached. If not, the value will be frozen with Object#freeze - # to prevent users from modifying it in an instance. - # @option options [Proc] :coerce A proc which will be called to - # transform the user input to canonical form. The value is passed in, - # and the transformed value returned as output. Lazy values will *not* - # be passed to this method until after they are evaluated. Called in the - # context of the resource (meaning you can access other properties). - # @option options [Boolean] :required `true` if this property - # must be present; `false` otherwise. This is checked after the resource - # is fully initialized. - # - def initialize(**options) -super if defined?(::Chef::Property) - options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo } - @options = options - options[:name] = options[:name].to_sym if options[:name] - options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name] - - # Replace name_attribute with name_property - if options.has_key?(:name_attribute) - # If we have both name_attribute and name_property and they differ, raise an error - if options.has_key?(:name_property) - raise ArgumentError, "Cannot specify both name_property and name_attribute together on property #{self}." - end - # replace name_property with name_attribute in place - options = Hash[options.map { |k, v| k == :name_attribute ? [ :name_property, v ] : [ k, v ] }] - @options = options - end - - # Only pick the first of :default, :name_property and :name_attribute if - # more than one is specified. - if options.has_key?(:default) && options[:name_property] - if options[:default].nil? || options.keys.index(:name_property) < options.keys.index(:default) - options.delete(:default) - preferred_default = :name_property - else - options.delete(:name_property) - preferred_default = :default - end - Chef.log_deprecation("Cannot specify both default and name_property together on property #{self}. Only one (#{preferred_default}) will be obeyed. In Chef 13, this will become an error. Please remove one or the other from the property.") - end - - # Validate the default early, so the user gets a good error message, and - # cache it so we don't do it again if so - begin - # If we can validate it all the way to output, do it. - @stored_default = input_to_stored_value(nil, default, is_default: true) - rescue Chef::Exceptions::CannotValidateStaticallyError - # If the validation is not static (i.e. has procs), we will have to - # coerce and validate the default each time we run - end - end - - def to_s - "#{name || ""}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}" - end - - # - # The name of this property. - # - # @return [String] - # - def name - options[:name] - end - - # - # The class this property was defined in. - # - # @return [Class] - # - def declared_in - options[:declared_in] - end - - # - # The instance variable associated with this property. - # - # Defaults to `@` - # - # @return [Symbol] - # - def instance_variable_name - if options.has_key?(:instance_variable_name) - options[:instance_variable_name] - elsif name - :"@#{name}" - end - end - - # - # The raw default value for this resource. - # - # Does not coerce or validate the default. Does not evaluate lazy values. - # - # Defaults to `lazy { name }` if name_property is true; otherwise defaults to - # `nil` - # - def default - return options[:default] if options.has_key?(:default) - return Chef::DelayedEvaluator.new { name } if name_property? - nil - end - - # - # Whether this is part of the resource's natural identity or not. - # - # @return [Boolean] - # - def identity? - options[:identity] - end - - # - # Whether this is part of desired state or not. - # - # Defaults to true. - # - # @return [Boolean] - # - def desired_state? - return true if !options.has_key?(:desired_state) - options[:desired_state] - end - - # - # Whether this is name_property or not. - # - # @return [Boolean] - # - def name_property? - options[:name_property] - end - - # - # Whether this property has a default value. - # - # @return [Boolean] - # - def has_default? - options.has_key?(:default) || name_property? - end - - # - # Whether this property is required or not. - # - # @return [Boolean] - # - def required? - options[:required] - end - - # - # Whether this property is sensitive or not. - # - # Defaults to false. - # - # @return [Boolean] - # - def sensitive? - options.fetch(:sensitive, false) - end - - # - # Validation options. (See Chef::Mixin::ParamsValidate#validate.) - # - # @return [Hash] - # - def validation_options - @validation_options ||= options.reject do |k, v| - [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable, :sensitive].include?(k) - end - end - - # - # Handle the property being called. - # - # The base implementation does the property get-or-set: - # - # ```ruby - # resource.myprop # get - # resource.myprop value # set - # ``` - # - # Subclasses may implement this with any arguments they want, as long as - # the corresponding DSL calls it correctly. - # - # @param resource [Chef::Resource] The resource to get the property from. - # @param value The value to set (or NOT_PASSED if it is a get). - # - # @return The current value of the property. If it is a `set`, lazy values - # will be returned without running, validating or coercing. If it is a - # `get`, the non-lazy, coerced, validated value will always be returned. - # - def call(resource, value = NOT_PASSED) - if value == NOT_PASSED - return get(resource) - end - - if value.nil? && !nillable? - # In Chef 12, value(nil) does a *get* instead of a set, so we - # warn if the value would have been changed. In Chef 13, it will be - # equivalent to value = nil. - result = get(resource, nil_set: true) - - # Warn about this becoming a set in Chef 13. - begin - input_to_stored_value(resource, value) - # If nil is valid, and it would change the value, warn that this will change to a set. - if !result.nil? - Chef.log_deprecation("An attempt was made to change #{name} from #{result.inspect} to nil by calling #{name}(nil). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil.") - end - rescue Chef::Exceptions::DeprecatedFeatureError - raise - rescue - # If nil is invalid, warn that this will become an error. - Chef.log_deprecation("nil is an invalid value for #{self}. In Chef 13, this warning will change to an error. Error: #{$!}") - end - - result - else - # Anything else, such as myprop(value) is a set - set(resource, value) - end - end - - # - # Get the property value from the resource, handling lazy values, - # defaults, and validation. - # - # - If the property's value is lazy, it is evaluated, coerced and validated. - # - If the property has no value, and is required, raises ValidationFailed. - # - If the property has no value, but has a lazy default, it is evaluated, - # coerced and validated. If the evaluated value is frozen, the resulting - # - If the property has no value, but has a default, the default value - # will be returned and frozen. If the default value is lazy, it will be - # evaluated, coerced and validated, and the result stored in the property. - # - If the property has no value, but is name_property, `resource.name` - # is retrieved, coerced, validated and stored in the property. - # - Otherwise, `nil` is returned. - # - # @param resource [Chef::Resource] The resource to get the property from. - # - # @return The value of the property. - # - # @raise Chef::Exceptions::ValidationFailed If the value is invalid for - # this property, or if the value is required and not set. - # - def get(resource, nil_set: false) - # If it's set, return it (and evaluate any lazy values) - if is_set?(resource) - value = get_value(resource) - value = stored_value_to_output(resource, value) - - else - # We are getting the default value. - - # If the user does something like this: - # - # ``` - # class MyResource < Chef::Resource - # property :content - # action :create do - # file '/x.txt' do - # content content - # end - # end - # end - # ``` - # - # It won't do what they expect. This checks whether you try to *read* - # `content` while we are compiling the resource. - if !nil_set && - resource.respond_to?(:resource_initializing) && - resource.resource_initializing && - resource.respond_to?(:enclosing_provider) && - resource.enclosing_provider && - resource.enclosing_provider.new_resource && - resource.enclosing_provider.new_resource.respond_to?(name) - Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}") - end - - if has_default? - # If we were able to cache the stored_default, grab it. - if defined?(@stored_default) - value = @stored_default - else - # Otherwise, we have to validate it now. - value = input_to_stored_value(resource, default, is_default: true) - end - value = stored_value_to_output(resource, value, is_default: true) - - # If the value is mutable (non-frozen), we set it on the instance - # so that people can mutate it. (All constant default values are - # frozen.) - if !value.frozen? && !value.nil? - set_value(resource, value) - end - - value - - elsif required? - raise Chef::Exceptions::ValidationFailed, "#{name} is required" - end - end - end - - # - # Set the value of this property in the given resource. - # - # Non-lazy values are coerced and validated before being set. Coercion - # and validation of lazy values is delayed until they are first retrieved. - # - # @param resource [Chef::Resource] The resource to set this property in. - # @param value The value to set. - # - # @return The value that was set, after coercion (if lazy, still returns - # the lazy value) - # - # @raise Chef::Exceptions::ValidationFailed If the value is invalid for - # this property. - # - def set(resource, value) - set_value(resource, input_to_stored_value(resource, value)) - end - - # - # Find out whether this property has been set. - # - # This will be true if: - # - The user explicitly set the value - # - The property has a default, and the value was retrieved. - # - # From this point of view, it is worth looking at this as "what does the - # user think this value should be." In order words, if the user grabbed - # the value, even if it was a default, they probably based calculations on - # it. If they based calculations on it and the value changes, the rest of - # the world gets inconsistent. - # - # @param resource [Chef::Resource] The resource to get the property from. - # - # @return [Boolean] - # - def is_set?(resource) - value_is_set?(resource) - end - - # - # Reset the value of this property so that is_set? will return false and the - # default will be returned in the future. - # - # @param resource [Chef::Resource] The resource to get the property from. - # - def reset(resource) - reset_value(resource) - end - - # - # Coerce an input value into canonical form for the property. - # - # After coercion, the value is suitable for storage in the resource. - # You must validate values after coercion, however. - # - # Does no special handling for lazy values. - # - # @param resource [Chef::Resource] The resource we're coercing against - # (to provide context for the coerce). - # @param value The value to coerce. - # - # @return The coerced value. - # - # @raise Chef::Exceptions::ValidationFailed If the value is invalid for - # this property. - # - def coerce(resource, value) - if options.has_key?(:coerce) - # If we have no default value, `nil` is never coerced or validated - unless !has_default? && value.nil? - value = exec_in_resource(resource, options[:coerce], value) - end - end - value - end - - # - # Validate a value. - # - # Calls Chef::Mixin::ParamsValidate#validate with #validation_options as - # options. - # - # @param resource [Chef::Resource] The resource we're validating against - # (to provide context for the validate). - # @param value The value to validate. - # - # @raise Chef::Exceptions::ValidationFailed If the value is invalid for - # this property. - # - def validate(resource, value) - # If we have no default value, `nil` is never coerced or validated - unless value.nil? && !has_default? - if resource - resource.validate({ name => value }, { name => validation_options }) - else - name = self.name || :property_type - Chef::Mixin::ParamsValidate.validate({ name => value }, { name => validation_options }) - end - end - end - - # - # Derive a new Property that is just like this one, except with some added or - # changed options. - # - # @param options [Hash] List of options that would be passed - # to #initialize. - # - # @return [Property] The new property type. - # - def derive(**modified_options) - # Since name_property, name_attribute and default override each other, - # if you specify one of them in modified_options it overrides anything in - # the original options. - options = self.options - if modified_options.has_key?(:name_property) || - modified_options.has_key?(:name_attribute) || - modified_options.has_key?(:default) - options = options.reject { |k, v| k == :name_attribute || k == :name_property || k == :default } - end - self.class.new(options.merge(modified_options)) - end - - # - # Emit the DSL for this property into the resource class (`declared_in`). - # - # Creates a getter and setter for the property. - # - def emit_dsl - # We don't create the getter/setter if it's a custom property; we will - # be using the existing getter/setter to manipulate it instead. - return if !instance_variable_name - - # We prefer this form because the property name won't show up in the - # stack trace if you use `define_method`. - declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1 - def #{name}(value=NOT_PASSED) - raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given? - self.class.properties[#{name.inspect}].call(self, value) - end - def #{name}=(value) - raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given? - self.class.properties[#{name.inspect}].set(self, value) - end - EOM - rescue SyntaxError - # If the name is not a valid ruby name, we use define_method. - declared_in.define_method(name) do |value = NOT_PASSED, &block| - raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block - self.class.properties[name].call(self, value) - end - declared_in.define_method("#{name}=") do |value, &block| - raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block - self.class.properties[name].set(self, value) - end - end - - # - # The options this Property will use for get/set behavior and validation. - # - # @see #initialize for a list of valid options. - # - attr_reader :options - - # - # Find out whether this type accepts nil explicitly. - # - # A type accepts nil explicitly if "is" allows nil, it validates as nil, *and* is not simply - # an empty type. - # - # A type is presumed to accept nil if it does coercion (which must handle nil). - # - # These examples accept nil explicitly: - # ```ruby - # property :a, [ String, nil ] - # property :a, [ String, NilClass ] - # property :a, [ String, proc { |v| v.nil? } ] - # ``` - # - # This does not (because the "is" doesn't exist or doesn't have nil): - # - # ```ruby - # property :x, String - # ``` - # - # These do not, even though nil would validate fine (because they do not - # have "is"): - # - # ```ruby - # property :a - # property :a, equal_to: [ 1, 2, 3, nil ] - # property :a, kind_of: [ String, NilClass ] - # property :a, respond_to: [ ] - # property :a, callbacks: { "a" => proc { |v| v.nil? } } - # ``` - # - # @param resource [Chef::Resource] The resource we're coercing against - # (to provide context for the coerce). - # - # @return [Boolean] Whether this value explicitly accepts nil. - # - # @api private - def explicitly_accepts_nil?(resource) - options.has_key?(:coerce) || - (options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false)) - end - - # @api private - def get_value(resource) - if instance_variable_name - resource.instance_variable_get(instance_variable_name) - else - resource.send(name) - end - end - - # @api private - def set_value(resource, value) - if instance_variable_name - resource.instance_variable_set(instance_variable_name, value) - else - resource.send(name, value) - end - end - - # @api private - def value_is_set?(resource) - if instance_variable_name - resource.instance_variable_defined?(instance_variable_name) - else - true - end - end - - # @api private - def reset_value(resource) - if instance_variable_name - if value_is_set?(resource) - resource.remove_instance_variable(instance_variable_name) - end - else - raise ArgumentError, "Property #{name} has no instance variable defined and cannot be reset" - end - end - - private - - def exec_in_resource(resource, proc, *args) - if resource - if proc.arity > args.size - value = proc.call(resource, *args) - else - value = resource.instance_exec(*args, &proc) - end - else - # If we don't have a resource yet, we can't exec in resource! - raise Chef::Exceptions::CannotValidateStaticallyError, "Cannot validate or coerce without a resource" - end - end - - def input_to_stored_value(resource, value, is_default: false) - unless value.is_a?(DelayedEvaluator) - value = coerce_and_validate(resource, value, is_default: is_default) - end - value - end - - def stored_value_to_output(resource, value, is_default: false) - # Crack open lazy values before giving the result to the user - if value.is_a?(DelayedEvaluator) - value = exec_in_resource(resource, value) - value = coerce_and_validate(resource, value, is_default: is_default) - end - value - end - - # Coerces and validates the value. If the value is a default, it will warn - # the user that invalid defaults are bad mmkay, and return it as if it were - # valid. - def coerce_and_validate(resource, value, is_default: false) - result = coerce(resource, value) - begin - # If the input is from a default, we need to emit an invalid default warning on validate. - validate(resource, result) - rescue Chef::Exceptions::CannotValidateStaticallyError - # This one gets re-raised - raise - rescue - # Anything else is just an invalid default: in those cases, we just - # warn and return the (possibly coerced) value to the user. - if is_default - if value.nil? - Chef.log_deprecation("Default value nil is invalid for property #{self}. Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property #{name.inspect}, [ String, nil ], default: nil'). Error: #{$!}") - else - Chef.log_deprecation("Default value #{value.inspect} is invalid for property #{self}. In Chef 13 this will become an error: #{$!}.") - end - else - raise - end - end - - result - end - - def nillable? - !!options[:nillable] - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb deleted file mode 100644 index 7ccf87bf..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb +++ /dev/null @@ -1,164 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/provider' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -require "chef_compat/copied_from_chef/chef/dsl/core" -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object) - include Chef::DSL::Core - attr_accessor :action - def initialize(new_resource, run_context) -super if defined?(::Chef::Provider) - @new_resource = new_resource - @action = action - @current_resource = nil - @run_context = run_context - @converge_actions = nil - - @recipe_name = nil - @cookbook_name = nil - self.class.include_resource_dsl_module(new_resource) - end - def converge_if_changed(*properties, &converge_block) - if !converge_block - raise ArgumentError, "converge_if_changed must be passed a block!" - end - - properties = new_resource.class.state_properties.map { |p| p.name } if properties.empty? - properties = properties.map { |p| p.to_sym } - if current_resource - # Collect the list of modified properties - specified_properties = properties.select { |property| new_resource.property_is_set?(property) } - modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) } - if modified.empty? - properties_str = if sensitive - specified_properties.join(", ") - else - specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ") - end - Chef::Log.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.") - return false - end - - # Print the pretty green text and run the block - property_size = modified.map { |p| p.size }.max - modified.map! do |p| - properties_str = if sensitive - "(suppressed sensitive property)" - else - "#{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})" - end - " set #{p.to_s.ljust(property_size)} to #{properties_str}" - end - converge_by([ "update #{current_resource.identity}" ] + modified, &converge_block) - - else - # The resource doesn't exist. Mark that we are *creating* this, and - # write down any properties we are setting. - property_size = properties.map { |p| p.size }.max - created = properties.map do |property| - default = " (default value)" unless new_resource.property_is_set?(property) - properties_str = if sensitive - "(suppressed sensitive property)" - else - new_resource.send(property).inspect - end - " set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}" - end - - converge_by([ "create #{new_resource.identity}" ] + created, &converge_block) - end - true - end - def self.include_resource_dsl(include_resource_dsl) - @include_resource_dsl = include_resource_dsl - end - def self.include_resource_dsl_module(resource) - if @include_resource_dsl && !defined?(@included_resource_dsl_module) - provider_class = self - @included_resource_dsl_module = Module.new do - extend Forwardable - define_singleton_method(:to_s) { "forwarder module for #{provider_class}" } - define_singleton_method(:inspect) { to_s } - # Add a delegator for each explicit property that will get the *current* value - # of the property by default instead of the *actual* value. - resource.class.properties.each do |name, property| - class_eval(<<-EOM, __FILE__, __LINE__) - def #{name}(*args, &block) - # If no arguments were passed, we process "get" by defaulting - # the value to current_resource, not new_resource. This helps - # avoid issues where resources accidentally overwrite perfectly - # valid stuff with default values. - if args.empty? && !block - if !new_resource.property_is_set?(__method__) && current_resource - return current_resource.public_send(__method__) - end - end - new_resource.public_send(__method__, *args, &block) - end - EOM - end - dsl_methods = - resource.class.public_instance_methods + - resource.class.protected_instance_methods - - provider_class.instance_methods - - resource.class.properties.keys - def_delegators(:new_resource, *dsl_methods) - end - include @included_resource_dsl_module - end - end - def self.use_inline_resources - extend InlineResources::ClassMethods - include InlineResources - end - module InlineResources - CopiedFromChef.extend_chef_module(::Chef::Provider::InlineResources, self) if defined?(::Chef::Provider::InlineResources) - def compile_and_converge_action(&block) - old_run_context = run_context - @run_context = run_context.create_child - return_value = instance_eval(&block) - Chef::Runner.new(run_context).converge - return_value - ensure - if run_context.resource_collection.any? { |r| r.updated? } - new_resource.updated_by_last_action(true) - end - @run_context = old_run_context - end - module ClassMethods - CopiedFromChef.extend_chef_module(::Chef::Provider::InlineResources::ClassMethods, self) if defined?(::Chef::Provider::InlineResources::ClassMethods) - def action(name, &block) - # We need the block directly in a method so that `super` works - define_method("compile_action_#{name}", &block) - # We try hard to use `def` because define_method doesn't show the method name in the stack. - begin - class_eval <<-EOM - def action_#{name} - compile_and_converge_action { compile_action_#{name} } - end - EOM - rescue SyntaxError - define_method("action_#{name}") { send("compile_action_#{name}") } - end - end - end - end - protected - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_repository.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_repository.rb deleted file mode 100644 index ccc07c43..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_repository.rb +++ /dev/null @@ -1,269 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/provider/apt_repository' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/resource" -require "chef_compat/copied_from_chef/chef/dsl/declare_resource" -require "chef_compat/copied_from_chef/chef/provider/noop" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object) - class AptRepository < (defined?(::Chef::Provider::AptRepository) ? ::Chef::Provider::AptRepository : Chef::Provider) - use_inline_resources - - include Chef::Mixin::ShellOut - extend Chef::Mixin::Which - - provides :apt_repository do - which("apt-get") - end - - def whyrun_supported? - true - end - - def load_current_resource - end - - action :add do - unless new_resource.key.nil? - if is_key_id?(new_resource.key) && !has_cookbook_file?(new_resource.key) - install_key_from_keyserver - else - install_key_from_uri - end - end - - declare_resource(:execute, "apt-cache gencaches") do - ignore_failure true - action :nothing - end - - declare_resource(:apt_update, new_resource.name) do - ignore_failure true - action :nothing - end - - components = if is_ppa_url?(new_resource.uri) && new_resource.components.empty? - "main" - else - new_resource.components - end - - repo = build_repo( - new_resource.uri, - new_resource.distribution, - components, - new_resource.trusted, - new_resource.arch, - new_resource.deb_src - ) - - declare_resource(:file, "/etc/apt/sources.list.d/#{new_resource.name}.list") do - owner "root" - group "root" - mode "0644" - content repo - sensitive new_resource.sensitive - action :create - notifies :run, "execute[apt-cache gencaches]", :immediately - notifies :update, "apt_update[#{new_resource.name}]", :immediately if new_resource.cache_rebuild - end - end - - action :remove do - if ::File.exist?("/etc/apt/sources.list.d/#{new_resource.name}.list") - converge_by "Removing #{new_resource.name} repository from /etc/apt/sources.list.d/" do - declare_resource(:file, "/etc/apt/sources.list.d/#{new_resource.name}.list") do - sensitive new_resource.sensitive - action :delete - notifies :update, "apt_update[#{new_resource.name}]", :immediately if new_resource.cache_rebuild - end - - declare_resource(:apt_update, new_resource.name) do - ignore_failure true - action :nothing - end - - end - end - end - - def is_key_id?(id) - id = id[2..-1] if id.start_with?("0x") - id =~ /^\h+$/ && [8, 16, 40].include?(id.length) - end - - def extract_fingerprints_from_cmd(cmd) - so = shell_out(cmd) - so.run_command - so.stdout.split(/\n/).map do |t| - if z = t.match(/^ +Key fingerprint = ([0-9A-F ]+)/) - z[1].split.join - end - end.compact - end - - def key_is_valid?(cmd, key) - valid = true - - so = shell_out(cmd) - so.run_command - so.stdout.split(/\n/).map do |t| - if t =~ %r{^\/#{key}.*\[expired: .*\]$} - Chef::Log.debug "Found expired key: #{t}" - valid = false - break - end - end - - Chef::Log.debug "key #{key} #{valid ? "is valid" : "is not valid"}" - valid - end - - def cookbook_name - new_resource.cookbook || new_resource.cookbook_name - end - - def has_cookbook_file?(fn) - run_context.has_cookbook_file_in_cookbook?(cookbook_name, fn) - end - - def no_new_keys?(file) - installed_keys = extract_fingerprints_from_cmd("apt-key finger") - proposed_keys = extract_fingerprints_from_cmd("gpg --with-fingerprint #{file}") - (installed_keys & proposed_keys).sort == proposed_keys.sort - end - - def install_key_from_uri - key_name = new_resource.key.gsub(/[^0-9A-Za-z\-]/, "_") - cached_keyfile = ::File.join(Chef::Config[:file_cache_path], key_name) - type = if new_resource.key.start_with?("http") - :remote_file - elsif has_cookbook_file?(new_resource.key) - :cookbook_file - else - raise Chef::Exceptions::FileNotFound, "Cannot locate key file" - end - - declare_resource(type, cached_keyfile) do - source new_resource.key - mode "0644" - sensitive new_resource.sensitive - action :create - end - - raise "The key #{cached_keyfile} is invalid and cannot be used to verify an apt repository." unless key_is_valid?("gpg #{cached_keyfile}", "") - - declare_resource(:execute, "apt-key add #{cached_keyfile}") do - sensitive new_resource.sensitive - action :run - not_if do - no_new_keys?(cached_keyfile) - end - notifies :run, "execute[apt-cache gencaches]", :immediately - end - end - - def install_key_from_keyserver(key = new_resource.key, keyserver = new_resource.keyserver) - cmd = "apt-key adv --recv" - cmd << " --keyserver-options http-proxy=#{new_resource.key_proxy}" if new_resource.key_proxy - cmd << " --keyserver " - cmd << if keyserver.start_with?("hkp://") - keyserver - else - "hkp://#{keyserver}:80" - end - - cmd << " #{key}" - - declare_resource(:execute, "install-key #{key}") do - command cmd - sensitive new_resource.sensitive - not_if do - present = extract_fingerprints_from_cmd("apt-key finger").any? do |fp| - fp.end_with? key.upcase - end - present && key_is_valid?("apt-key list", key.upcase) - end - notifies :run, "execute[apt-cache gencaches]", :immediately - end - - raise "The key #{key} is invalid and cannot be used to verify an apt repository." unless key_is_valid?("apt-key list", key.upcase) - end - - def install_ppa_key(owner, repo) - url = "https://launchpad.net/api/1.0/~#{owner}/+archive/#{repo}" - key_id = Chef::HTTP::Simple.new(url).get("signing_key_fingerprint").delete('"') - install_key_from_keyserver(key_id, "keyserver.ubuntu.com") - rescue Net::HTTPServerException => e - raise "Could not access Launchpad ppa API: #{e.message}" - end - - def is_ppa_url?(url) - url.start_with?("ppa:") - end - - def make_ppa_url(ppa) - return unless is_ppa_url?(ppa) - owner, repo = ppa[4..-1].split("/") - repo ||= "ppa" - - install_ppa_key(owner, repo) - "http://ppa.launchpad.net/#{owner}/#{repo}/ubuntu" - end - - def build_repo(uri, distribution, components, trusted, arch, add_src = false) - uri = make_ppa_url(uri) if is_ppa_url?(uri) - - uri = '"' + uri + '"' unless uri.start_with?("'", '"') - components = Array(components).join(" ") - options = [] - options << "arch=#{arch}" if arch - options << "trusted=yes" if trusted - optstr = unless options.empty? - "[" + options.join(" ") + "]" - end - info = [ optstr, uri, distribution, components ].compact.join(" ") - repo = "deb #{info}\n" - repo << "deb-src #{info}\n" if add_src - repo - end - end - end -end - -Chef::Provider::Noop.provides :apt_repository -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_update.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_update.rb deleted file mode 100644 index 677cb577..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_update.rb +++ /dev/null @@ -1,105 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/provider/apt_update' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/provider" -require "chef_compat/copied_from_chef/chef/provider/noop" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object) - class AptUpdate < (defined?(::Chef::Provider::AptUpdate) ? ::Chef::Provider::AptUpdate : Chef::Provider) - use_inline_resources - - extend Chef::Mixin::Which - - provides :apt_update do - which("apt-get") - end - - APT_CONF_DIR = "/etc/apt/apt.conf.d" - STAMP_DIR = "/var/lib/apt/periodic" - - def whyrun_supported? - true - end - - def load_current_resource - end - - action :periodic do - if !apt_up_to_date? - converge_by "update new lists of packages" do - do_update - end - end - end - - action :update do - converge_by "force update new lists of packages" do - do_update - end - end - - private - - # Determines whether we need to run `apt-get update` - # - # @return [Boolean] - def apt_up_to_date? - ::File.exist?("#{STAMP_DIR}/update-success-stamp") && - ::File.mtime("#{STAMP_DIR}/update-success-stamp") > Time.now - new_resource.frequency - end - - def do_update - [STAMP_DIR, APT_CONF_DIR].each do |d| - declare_resource(:directory, d) do - recursive true - end - end - - declare_resource(:file, "#{APT_CONF_DIR}/15update-stamp") do - content "APT::Update::Post-Invoke-Success {\"touch #{STAMP_DIR}/update-success-stamp 2>/dev/null || true\";};\n" - action :create_if_missing - end - - declare_resource(:execute, "apt-get -q update") - end - - end - end -end - -Chef::Provider::Noop.provides :apt_update -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/noop.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/noop.rb deleted file mode 100644 index 87c34e66..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/noop.rb +++ /dev/null @@ -1,56 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/provider/noop' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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. -# - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object) - class Noop < (defined?(::Chef::Provider::Noop) ? ::Chef::Provider::Noop : Chef::Provider) - def load_current_resource; end - - def respond_to_missing?(method_sym, include_private = false) - method_sym.to_s.start_with?("action_") || super - end - - def method_missing(method_sym, *arguments, &block) - if method_sym.to_s =~ /^action_/ - Chef::Log.debug("NoOp-ing for #{method_sym}") - else - super - end - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/support/yum_repo.erb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/support/yum_repo.erb deleted file mode 100644 index 6f132557..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/support/yum_repo.erb +++ /dev/null @@ -1,132 +0,0 @@ -# This file was generated by Chef -# Do NOT modify this file by hand. - -[<%= @config.repositoryid %>] -name=<%= @config.description %> -<% if @config.baseurl %> -baseurl=<%= case @config.baseurl - when Array - @config.baseurl.join("\n") - else - @config.baseurl - end %> -<% end -%> -<% if @config.cost %> -cost=<%= @config.cost %> -<% end %> -<% if @config.enabled %> -enabled=1 -<% else %> -enabled=0 -<% end %> -<% if @config.enablegroups %> -enablegroups=1 -<% end %> -<% if @config.exclude %> -exclude=<%= @config.exclude %> -<% end %> -<% if @config.failovermethod %> -failovermethod=<%= @config.failovermethod %> -<% end %> -<% if @config.fastestmirror_enabled %> -fastestmirror_enabled=1 -<% else %> -fastestmirror_enabled=0 -<% end %> -<% if @config.gpgcheck %> -gpgcheck=1 -<% else %> -gpgcheck=0 -<% end %> -<% if @config.gpgkey %> -gpgkey=<%= case @config.gpgkey - when Array - @config.gpgkey.join("\n ") - else - @config.gpgkey - end %> -<% end -%> -<% if @config.http_caching %> -http_caching=<%= @config.http_caching %> -<% end %> -<% if @config.include_config %> -include=<%= @config.include_config %> -<% end %> -<% if @config.includepkgs %> -includepkgs=<%= @config.includepkgs %> -<% end %> -<% if @config.keepalive %> -keepalive=1 -<% end %> -<% if @config.metadata_expire %> -metadata_expire=<%= @config.metadata_expire %> -<% end %> -<% if @config.mirrorlist %> -mirrorlist=<%= @config.mirrorlist %> -<% end %> -<% if @config.mirror_expire %> -mirror_expire=<%= @config.mirror_expire %> -<% end %> -<% if @config.mirrorlist_expire %> -mirrorlist_expire=<%= @config.mirrorlist_expire %> -<% end %> -<% if @config.priority %> -priority=<%= @config.priority %> -<% end %> -<% if @config.proxy %> -proxy=<%= @config.proxy %> -<% end %> -<% if @config.proxy_username %> -proxy_username=<%= @config.proxy_username %> -<% end %> -<% if @config.proxy_password %> -proxy_password=<%= @config.proxy_password %> -<% end %> -<% if @config.username %> -username=<%= @config.username %> -<% end %> -<% if @config.password %> -password=<%= @config.password %> -<% end %> -<% if @config.repo_gpgcheck %> -repo_gpgcheck=1 -<% end %> -<% if @config.max_retries %> -retries=<%= @config.max_retries %> -<% end %> -<% if @config.report_instanceid %> -report_instanceid=<%= @config.report_instanceid %> -<% end %> -<% if @config.skip_if_unavailable %> -skip_if_unavailable=1 -<% end %> -<% if @config.sslcacert %> -sslcacert=<%= @config.sslcacert %> -<% end %> -<% if @config.sslclientcert %> -sslclientcert=<%= @config.sslclientcert %> -<% end %> -<% if @config.sslclientkey %> -sslclientkey=<%= @config.sslclientkey %> -<% end %> -<% unless @config.sslverify.nil? %> -sslverify=<%= ( @config.sslverify ) ? 'true' : 'false' %> -<% end %> -<% if @config.timeout %> -timeout=<%= @config.timeout %> -<% end %> -<% if @config.options -%> -<% @config.options.each do |key, value| -%> -<%= key %>=<%= - case value - when Array - value.join("\n ") - when TrueClass - '1' - when FalseClass - '0' - else - value - end %> -<% end -%> -<% end -%> diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/systemd_unit.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/systemd_unit.rb deleted file mode 100644 index 1024cb82..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/systemd_unit.rb +++ /dev/null @@ -1,253 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/provider/systemd_unit' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Nathan Williams () -# Copyright:: Copyright 2016, Nathan Williams -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/provider" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object) - class SystemdUnit < (defined?(::Chef::Provider::SystemdUnit) ? ::Chef::Provider::SystemdUnit : Chef::Provider) - include Chef::Mixin::Which - include Chef::Mixin::ShellOut - - provides :systemd_unit, os: "linux" - - def load_current_resource - @current_resource = Chef::Resource::SystemdUnit.new(new_resource.name) - - current_resource.content(::File.read(unit_path)) if ::File.exist?(unit_path) - current_resource.user(new_resource.user) - current_resource.enabled(enabled?) - current_resource.active(active?) - current_resource.masked(masked?) - current_resource.static(static?) - current_resource.triggers_reload(new_resource.triggers_reload) - - current_resource - end - - def define_resource_requirements - super - - requirements.assert(:create) do |a| - a.assertion { IniParse.parse(new_resource.to_ini) } - a.failure_message "Unit content is not valid INI text" - end - end - - def action_create - if current_resource.content != new_resource.to_ini - converge_by("creating unit: #{new_resource.name}") do - manage_unit_file(:create) - daemon_reload if new_resource.triggers_reload - end - end - end - - def action_delete - if ::File.exist?(unit_path) - converge_by("deleting unit: #{new_resource.name}") do - manage_unit_file(:delete) - daemon_reload if new_resource.triggers_reload - end - end - end - - def action_enable - if current_resource.static - Chef::Log.debug("#{new_resource.name} is a static unit, enabling is a NOP.") - end - - unless current_resource.enabled || current_resource.static - converge_by("enabling unit: #{new_resource.name}") do - systemctl_execute!(:enable, new_resource.name) - end - end - end - - def action_disable - if current_resource.static - Chef::Log.debug("#{new_resource.name} is a static unit, disabling is a NOP.") - end - - if current_resource.enabled && !current_resource.static - converge_by("disabling unit: #{new_resource.name}") do - systemctl_execute!(:disable, new_resource.name) - end - end - end - - def action_mask - unless current_resource.masked - converge_by("masking unit: #{new_resource.name}") do - systemctl_execute!(:mask, new_resource.name) - end - end - end - - def action_unmask - if current_resource.masked - converge_by("unmasking unit: #{new_resource.name}") do - systemctl_execute!(:unmask, new_resource.name) - end - end - end - - def action_start - unless current_resource.active - converge_by("starting unit: #{new_resource.name}") do - systemctl_execute!(:start, new_resource.name) - end - end - end - - def action_stop - if current_resource.active - converge_by("stopping unit: #{new_resource.name}") do - systemctl_execute!(:stop, new_resource.name) - end - end - end - - def action_restart - converge_by("restarting unit: #{new_resource.name}") do - systemctl_execute!(:restart, new_resource.name) - end - end - - def action_reload - if current_resource.active - converge_by("reloading unit: #{new_resource.name}") do - systemctl_execute!(:reload, new_resource.name) - end - else - Chef::Log.debug("#{new_resource.name} is not active, skipping reload.") - end - end - - def action_try_restart - converge_by("try-restarting unit: #{new_resource.name}") do - systemctl_execute!("try-restart", new_resource.name) - end - end - - def action_reload_or_restart - converge_by("reload-or-restarting unit: #{new_resource.name}") do - systemctl_execute!("reload-or-restart", new_resource.name) - end - end - - def action_reload_or_try_restart - converge_by("reload-or-try-restarting unit: #{new_resource.name}") do - systemctl_execute!("reload-or-try-restart", new_resource.name) - end - end - - def active? - systemctl_execute("is-active", new_resource.name).exitstatus == 0 - end - - def enabled? - systemctl_execute("is-enabled", new_resource.name).exitstatus == 0 - end - - def masked? - systemctl_execute(:status, new_resource.name).stdout.include?("masked") - end - - def static? - systemctl_execute("is-enabled", new_resource.name).stdout.include?("static") - end - - private - - def unit_path - if new_resource.user - "/etc/systemd/user/#{new_resource.name}" - else - "/etc/systemd/system/#{new_resource.name}" - end - end - - def manage_unit_file(action = :nothing) - Chef::Resource::File.new(unit_path, run_context).tap do |f| - f.owner "root" - f.group "root" - f.mode "0644" - f.content new_resource.to_ini - end.run_action(action) - end - - def daemon_reload - shell_out_with_systems_locale!("#{systemctl_path} daemon-reload") - end - - def systemctl_execute!(action, unit) - shell_out_with_systems_locale!("#{systemctl_cmd} #{action} #{unit}", systemctl_opts) - end - - def systemctl_execute(action, unit) - shell_out("#{systemctl_cmd} #{action} #{unit}", systemctl_opts) - end - - def systemctl_cmd - @systemctl_cmd ||= "#{systemctl_path} #{systemctl_args}" - end - - def systemctl_path - @systemctl_path ||= which("systemctl") - end - - def systemctl_args - @systemctl_args ||= new_resource.user ? "--user" : "--system" - end - - def systemctl_opts - @systemctl_opts ||= - if new_resource.user - { - :user => new_resource.user, - :environment => { - "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{node['etc']['passwd'][new_resource.user]['uid']}/bus", - }, - } - else - {} - end - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/yum_repository.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/yum_repository.rb deleted file mode 100644 index 51453d2c..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/yum_repository.rb +++ /dev/null @@ -1,136 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/provider/yum_repository' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/resource" -require "chef_compat/copied_from_chef/chef/dsl/declare_resource" -require "chef_compat/copied_from_chef/chef/provider/noop" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object) - class YumRepository < (defined?(::Chef::Provider::YumRepository) ? ::Chef::Provider::YumRepository : Chef::Provider) - use_inline_resources - - extend Chef::Mixin::Which - - provides :yum_repository do - which "yum" - end - - def whyrun_supported?; true; end - - def load_current_resource; end - - action :create do - declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do - if template_available?(new_resource.source) - source new_resource.source - else - source ::File.expand_path("../support/yum_repo.erb", __FILE__) - local true - end - sensitive new_resource.sensitive - variables(config: new_resource) - mode new_resource.mode - if new_resource.make_cache - notifies :run, "execute[yum clean metadata #{new_resource.repositoryid}]", :immediately if new_resource.clean_metadata || new_resource.clean_headers - notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately - notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately - end - end - - declare_resource(:execute, "yum clean metadata #{new_resource.repositoryid}") do - command "yum clean metadata --disablerepo=* --enablerepo=#{new_resource.repositoryid}" - action :nothing - end - - # get the metadata for this repo only - declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do - command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}" - action :nothing - only_if { new_resource.enabled } - end - - # reload internal Chef yum cache - declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do - block { Chef::Provider::Package::Yum::YumCache.instance.reload } - action :nothing - end - end - - action :delete do - # clean the repo cache first - declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do - command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}" - only_if "yum repolist all | grep -P '^#{new_resource.repositoryid}([ \t]|$)'" - end - - declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do - action :delete - notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately - end - - declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do - block { Chef::Provider::Package::Yum::YumCache.instance.reload } - action :nothing - end - end - - action :makecache do - declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do - command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}" - action :run - only_if { new_resource.enabled } - end - - declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do - block { Chef::Provider::Package::Yum::YumCache.instance.reload } - action :run - end - end - - alias_method :action_add, :action_create - alias_method :action_remove, :action_delete - - def template_available?(path) - !path.nil? && run_context.has_template_in_cookbook?(new_resource.cookbook_name, path) - end - - end - end -end - -Chef::Provider::Noop.provides :yum_repository -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource.rb deleted file mode 100644 index e5c9a146..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource.rb +++ /dev/null @@ -1,214 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -require "chef_compat/copied_from_chef/chef/resource/action_class" -require "chef_compat/copied_from_chef/chef/provider" -require "chef_compat/copied_from_chef/chef/mixin/properties" -require "chef_compat/copied_from_chef/chef/dsl/universal" -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object) - include Chef::Mixin::Properties - property :name, String, coerce: proc { |v| v.is_a?(Array) ? v.join(", ") : v.to_s }, desired_state: false - def initialize(name, run_context = nil) -super if defined?(::Chef::Resource) - name(name) unless name.nil? - @run_context = run_context - @noop = nil - @before = nil - @params = Hash.new - @provider = nil - @allowed_actions = self.class.allowed_actions.to_a - @action = self.class.default_action - @updated = false - @updated_by_last_action = false - @supports = {} - @ignore_failure = false - @retries = 0 - @retry_delay = 2 - @not_if = [] - @only_if = [] - @source_line = nil - # We would like to raise an error when the user gives us a guard - # interpreter and a ruby_block to the guard. In order to achieve this - # we need to understand when the user overrides the default guard - # interpreter. Therefore we store the default separately in a different - # attribute. - @guard_interpreter = nil - @default_guard_interpreter = :default - @elapsed_time = 0 - @sensitive = false - end - def action(arg = nil) - if arg - arg = Array(arg).map(&:to_sym) - arg.each do |action| - validate( - { action: action }, - { action: { kind_of: Symbol, equal_to: allowed_actions } } - ) - end - @action = arg - else - @action - end - end - alias_method :action=, :action - class UnresolvedSubscribes < (defined?(::Chef::Resource::UnresolvedSubscribes) ? ::Chef::Resource::UnresolvedSubscribes : self) - alias_method :to_s, :name - alias_method :declared_key, :name - end - def state_for_resource_reporter - state = {} - state_properties = self.class.state_properties - state_properties.each do |property| - if property.identity? || property.is_set?(self) - state[property.name] = property.sensitive? ? "*sensitive value suppressed*" : send(property.name) - end - end - state - end - alias_method :state, :state_for_resource_reporter - def identity - result = {} - identity_properties = self.class.identity_properties - identity_properties.each do |property| - result[property.name] = send(property.name) - end - return result.values.first if identity_properties.size == 1 - result - end - attr_reader :resource_initializing - def resource_initializing=(value) - if value - @resource_initializing = true - else - remove_instance_variable(:@resource_initializing) - end - end - def to_hash - # Grab all current state, then any other ivars (backcompat) - result = {} - self.class.state_properties.each do |p| - result[p.name] = p.get(self) - end - safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS - safe_ivars.each do |iv| - key = iv.to_s.sub(/^@/, "").to_sym - next if result.has_key?(key) - result[key] = instance_variable_get(iv) - end - result - end - def self.identity_property(name = nil) - result = identity_properties(*Array(name)) - if result.size > 1 - raise Chef::Exceptions::MultipleIdentityError, "identity_property cannot be called on an object with more than one identity property (#{result.map { |r| r.name }.join(", ")})." - end - result.first - end - attr_accessor :allowed_actions - def allowed_actions(value = NOT_PASSED) - if value != NOT_PASSED - self.allowed_actions = value - end - @allowed_actions - end - def resource_name - @resource_name || self.class.resource_name - end - def self.use_automatic_resource_name - automatic_name = convert_to_snake_case(self.name.split("::")[-1]) - resource_name automatic_name - end - def self.allowed_actions(*actions) - @allowed_actions ||= - if superclass.respond_to?(:allowed_actions) - superclass.allowed_actions.dup - else - [ :nothing ] - end - @allowed_actions |= actions.flatten - end - def self.allowed_actions=(value) - @allowed_actions = value.uniq - end - def self.default_action(action_name = NOT_PASSED) - unless action_name.equal?(NOT_PASSED) - @default_action = Array(action_name).map(&:to_sym) - self.allowed_actions |= @default_action - end - - if @default_action - @default_action - elsif superclass.respond_to?(:default_action) - superclass.default_action - else - [:nothing] - end - end - def self.default_action=(action_name) - default_action action_name - end - def self.action(action, &recipe_block) - action = action.to_sym - declare_action_class - action_class.action(action, &recipe_block) - self.allowed_actions += [ action ] - default_action action if Array(default_action) == [:nothing] - end - def self.load_current_value(&load_block) - define_method(:load_current_value!, &load_block) - end - def current_value_does_not_exist! - raise Chef::Exceptions::CurrentValueDoesNotExist - end - def self.action_class(&block) - return @action_class if @action_class && !block - # If the superclass needed one, then we need one as well. - if block || (superclass.respond_to?(:action_class) && superclass.action_class) - @action_class = declare_action_class(&block) - end - @action_class - end - def self.declare_action_class(&block) - @action_class ||= begin - if superclass.respond_to?(:action_class) - base_provider = superclass.action_class - end - base_provider ||= Chef::Provider - - resource_class = self - Class.new(base_provider) do - include ActionClass - self.resource_class = resource_class - end - end - @action_class.class_eval(&block) if block - @action_class - end - FORBIDDEN_IVARS = [:@run_context, :@not_if, :@only_if, :@enclosing_provider] - HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider] - class << self - end - @@sorted_descendants = nil - module DeprecatedLWRPClass - CopiedFromChef.extend_chef_module(::Chef::Resource::DeprecatedLWRPClass, self) if defined?(::Chef::Resource::DeprecatedLWRPClass) - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb deleted file mode 100644 index 20ff8e5c..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb +++ /dev/null @@ -1,114 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource/action_class' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: John Keiser ("} action #{action ? action.inspect : ""}" - end - - def whyrun_supported? - true - end - - # - # If load_current_value! is defined on the resource, use that. - # - def load_current_resource - if new_resource.respond_to?(:load_current_value!) - # dup the resource and then reset desired-state properties. - current_resource = new_resource.dup - - # We clear desired state in the copy, because it is supposed to be actual state. - # We keep identity properties and non-desired-state, which are assumed to be - # "control" values like `recurse: true` - current_resource.class.properties.each do |name, property| - if property.desired_state? && !property.identity? && !property.name_property? - property.reset(current_resource) - end - end - - # Call the actual load_current_value! method. If it raises - # CurrentValueDoesNotExist, set current_resource to `nil`. - begin - # If the user specifies load_current_value do |desired_resource|, we - # pass in the desired resource as well as the current one. - if current_resource.method(:load_current_value!).arity > 0 - current_resource.load_current_value!(new_resource) - else - current_resource.load_current_value! - end - rescue Chef::Exceptions::CurrentValueDoesNotExist - current_resource = nil - end - end - - @current_resource = current_resource - end - - def self.included(other) - other.extend(ClassMethods) - other.use_inline_resources - other.include_resource_dsl true - end - - module ClassMethods - CopiedFromChef.extend_chef_module(::Chef::Resource::ActionClass::ClassMethods, self) if defined?(::Chef::Resource::ActionClass::ClassMethods) - # - # The Chef::Resource class this ActionClass was declared against. - # - # @return [Class] The Chef::Resource class this ActionClass was declared against. - # - attr_accessor :resource_class - - def to_s - "#{resource_class} action provider" - end - - def inspect - to_s - end - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_repository.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_repository.rb deleted file mode 100644 index bedfd3ec..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_repository.rb +++ /dev/null @@ -1,65 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource/apt_repository' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/resource" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object) - class AptRepository < (defined?(::Chef::Resource::AptRepository) ? ::Chef::Resource::AptRepository : Chef::Resource) - resource_name :apt_repository - provides :apt_repository - - property :repo_name, String, name_property: true - property :uri, String - property :distribution, [ String, nil, false ], default: lazy { node["lsb"]["codename"] }, nillable: true, coerce: proc { |x| x ? x : nil } - property :components, Array, default: [] - property :arch, [String, nil, false], default: nil, nillable: true, coerce: proc { |x| x ? x : nil } - property :trusted, [TrueClass, FalseClass], default: false - # whether or not to add the repository as a source repo, too - property :deb_src, [TrueClass, FalseClass], default: false - property :keyserver, [String, nil, false], default: "keyserver.ubuntu.com", nillable: true, coerce: proc { |x| x ? x : nil } - property :key, [String, nil, false], default: nil, nillable: true, coerce: proc { |x| x ? x : nil } - property :key_proxy, [String, nil, false], default: nil, nillable: true, coerce: proc { |x| x ? x : nil } - - property :cookbook, [String, nil, false], default: nil, desired_state: false, nillable: true, coerce: proc { |x| x ? x : nil } - property :cache_rebuild, [TrueClass, FalseClass], default: true, desired_state: false - - default_action :add - allowed_actions :add, :remove - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_update.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_update.rb deleted file mode 100644 index 9acd9ae9..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_update.rb +++ /dev/null @@ -1,52 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource/apt_update' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/resource" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object) - class AptUpdate < (defined?(::Chef::Resource::AptUpdate) ? ::Chef::Resource::AptUpdate : Chef::Resource) - resource_name :apt_update - provides :apt_update - - property :frequency, Integer, default: 86_400 - - default_action :periodic - allowed_actions :update, :periodic - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/systemd_unit.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/systemd_unit.rb deleted file mode 100644 index 5f9f458c..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/systemd_unit.rb +++ /dev/null @@ -1,81 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource/systemd_unit' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Nathan Williams () -# Copyright:: Copyright 2016, Nathan Williams -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/resource" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object) - class SystemdUnit < (defined?(::Chef::Resource::SystemdUnit) ? ::Chef::Resource::SystemdUnit : Chef::Resource) - resource_name :systemd_unit - - default_action :nothing - allowed_actions :create, :delete, - :enable, :disable, - :mask, :unmask, - :start, :stop, - :restart, :reload, - :try_restart, :reload_or_restart, - :reload_or_try_restart - - property :enabled, [TrueClass, FalseClass] - property :active, [TrueClass, FalseClass] - property :masked, [TrueClass, FalseClass] - property :static, [TrueClass, FalseClass] - property :user, String, desired_state: false - property :content, [String, Hash] - property :triggers_reload, [TrueClass, FalseClass], - default: true, desired_state: false - - def to_ini - case content - when Hash - IniParse.gen do |doc| - content.each_pair do |sect, opts| - doc.section(sect) do |section| - opts.each_pair do |opt, val| - section.option(opt, val) - end - end - end - end.to_s - else - content.to_s - end - end - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/yum_repository.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/yum_repository.rb deleted file mode 100644 index 97cf23a5..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/yum_repository.rb +++ /dev/null @@ -1,97 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource/yum_repository' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Thom May () -# Copyright:: Copyright (c) 2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef_compat/copied_from_chef/chef/resource" - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object) - class YumRepository < (defined?(::Chef::Resource::YumRepository) ? ::Chef::Resource::YumRepository : Chef::Resource) - resource_name :yum_repository - provides :yum_repository - - # http://linux.die.net/man/5/yum.conf - property :baseurl, [String, Array], regex: /.*/ - property :cost, String, regex: /^\d+$/ - property :clean_headers, [TrueClass, FalseClass], default: false # deprecated - property :clean_metadata, [TrueClass, FalseClass], default: true - property :description, String, regex: /.*/, default: "Yum Repository" - property :enabled, [TrueClass, FalseClass], default: true - property :enablegroups, [TrueClass, FalseClass] - property :exclude, String, regex: /.*/ - property :failovermethod, String, equal_to: %w{priority roundrobin} - property :fastestmirror_enabled, [TrueClass, FalseClass] - property :gpgcheck, [TrueClass, FalseClass], default: true - property :gpgkey, [String, Array], regex: /.*/ - property :http_caching, String, equal_to: %w{packages all none} - property :include_config, String, regex: /.*/ - property :includepkgs, String, regex: /.*/ - property :keepalive, [TrueClass, FalseClass] - property :make_cache, [TrueClass, FalseClass], default: true - property :max_retries, [String, Integer] - property :metadata_expire, String, regex: [/^\d+$/, /^\d+[mhd]$/, /never/] - property :mirrorexpire, String, regex: /.*/ - property :mirrorlist, String, regex: /.*/ - property :mirror_expire, String, regex: [/^\d+$/, /^\d+[mhd]$/] - property :mirrorlist_expire, String, regex: [/^\d+$/, /^\d+[mhd]$/] - property :mode, default: "0644" - property :priority, String, regex: /^(\d?[0-9]|[0-9][0-9])$/ - property :proxy, String, regex: /.*/ - property :proxy_username, String, regex: /.*/ - property :proxy_password, String, regex: /.*/ - property :username, String, regex: /.*/ - property :password, String, regex: /.*/ - property :repo_gpgcheck, [TrueClass, FalseClass] - property :report_instanceid, [TrueClass, FalseClass] - property :repositoryid, String, regex: /.*/, name_property: true - property :skip_if_unavailable, [TrueClass, FalseClass] - property :source, String, regex: /.*/ - property :sslcacert, String, regex: /.*/ - property :sslclientcert, String, regex: /.*/ - property :sslclientkey, String, regex: /.*/ - property :sslverify, [TrueClass, FalseClass] - property :timeout, String, regex: /^\d+$/ - property :options, Hash - - default_action :create - allowed_actions :create, :remove, :makecache, :add, :delete - - # provide compatibility with the yum cookbook < 3.0 properties - alias_method :url, :baseurl - alias_method :keyurl, :gpgkey - end - end -end -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb deleted file mode 100644 index 688e856e..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +++ /dev/null @@ -1,174 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -begin - require 'chef/resource_builder' -rescue LoadError; end - -require 'chef_compat/copied_from_chef' -class Chef -module ::ChefCompat -module CopiedFromChef -# -# Author:: Lamont Granquist () -# Copyright:: Copyright 2015-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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. -# - -# NOTE: this was extracted from the Recipe DSL mixin, relevant specs are in spec/unit/recipe_spec.rb - -class Chef < (defined?(::Chef) ? ::Chef : Object) - class ResourceBuilder < (defined?(::Chef::ResourceBuilder) ? ::Chef::ResourceBuilder : Object) - attr_reader :type - attr_reader :name - attr_reader :created_at - attr_reader :params - attr_reader :run_context - attr_reader :cookbook_name - attr_reader :recipe_name - attr_reader :enclosing_provider - attr_reader :resource - - # FIXME (ruby-2.1 syntax): most of these are mandatory - def initialize(type: nil, name: nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil) -super if defined?(::Chef::ResourceBuilder) - @type = type - @name = name - @created_at = created_at - @params = params - @run_context = run_context - @cookbook_name = cookbook_name - @recipe_name = recipe_name - @enclosing_provider = enclosing_provider - end - - def build(&block) - raise ArgumentError, "You must supply a name when declaring a #{type} resource" if name.nil? - - @resource = resource_class.new(name, run_context) - if resource.resource_name.nil? - raise Chef::Exceptions::InvalidResourceSpecification, "#{resource}.resource_name is `nil`! Did you forget to put `provides :blah` or `resource_name :blah` in your resource class?" - end - resource.source_line = created_at - resource.declared_type = type - - # If we have a resource like this one, we want to steal its state - # This behavior is very counter-intuitive and should be removed. - # See CHEF-3694, https://tickets.opscode.com/browse/CHEF-3694 - # Moved to this location to resolve CHEF-5052, https://tickets.opscode.com/browse/CHEF-5052 - if prior_resource - resource.load_from(prior_resource) - end - - resource.cookbook_name = cookbook_name - resource.recipe_name = recipe_name - # Determine whether this resource is being created in the context of an enclosing Provider - resource.enclosing_provider = enclosing_provider - - # XXX: this is required for definition params inside of the scope of a - # subresource to work correctly. - resource.params = params - - # Evaluate resource attribute DSL - if block_given? - resource.resource_initializing = true - begin - resource.instance_eval(&block) - ensure - resource.resource_initializing = false - end - end - - # emit a cloned resource warning if it is warranted - if prior_resource - if is_trivial_resource?(prior_resource) && identicalish_resources?(prior_resource, resource) - emit_harmless_cloning_debug - else - emit_cloned_resource_warning - end - end - - # Run optional resource hook - resource.after_created - - resource - end - - private - - def resource_class - # Checks the new platform => short_name => resource mapping initially - # then fall back to the older approach (Chef::Resource.const_get) for - # backward compatibility - @resource_class ||= Chef::Resource.resource_for_node(type, run_context.node) - end - - def is_trivial_resource?(resource) - trivial_resource = resource_class.new(name, run_context) - # force un-lazy the name property on the created trivial resource - name_property = resource_class.properties.find { |sym, p| p.name_property? } - trivial_resource.send(name_property[0]) unless name_property.nil? - identicalish_resources?(trivial_resource, resource) - end - - # this is an equality test specific to checking for 3694 cloning warnings - def identicalish_resources?(first, second) - skipped_ivars = [ :@source_line, :@cookbook_name, :@recipe_name, :@params, :@elapsed_time, :@declared_type ] - checked_ivars = ( first.instance_variables | second.instance_variables ) - skipped_ivars - non_matching_ivars = checked_ivars.reject do |iv| - if iv == :@action && ( [first.instance_variable_get(iv)].flatten == [:nothing] || [second.instance_variable_get(iv)].flatten == [:nothing] ) - # :nothing action on either side of the comparison always matches - true - else - first.instance_variable_get(iv) == second.instance_variable_get(iv) - end - end - Chef::Log.debug("ivars which did not match with the prior resource: #{non_matching_ivars}") - non_matching_ivars.empty? - end - - def emit_cloned_resource_warning - message = "Cloning resource attributes for #{resource} from prior resource (CHEF-3694)" - message << "\nPrevious #{prior_resource}: #{prior_resource.source_line}" if prior_resource.source_line - message << "\nCurrent #{resource}: #{resource.source_line}" if resource.source_line - Chef.log_deprecation(message) - end - - def emit_harmless_cloning_debug - Chef::Log.debug("Harmless resource cloning from #{prior_resource}:#{prior_resource.source_line} to #{resource}:#{resource.source_line}") - end - - def prior_resource - @prior_resource ||= - begin - key = "#{type}[#{name}]" - run_context.resource_collection.lookup_local(key) - rescue Chef::Exceptions::ResourceNotFound - nil - end - end - - end -end - -require "chef_compat/copied_from_chef/chef/resource" -end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/mixin/properties.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/mixin/properties.rb deleted file mode 100644 index a3920d1a..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/mixin/properties.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'chef_compat/monkeypatches' -require 'chef_compat/copied_from_chef/chef/mixin/properties' - -module ChefCompat - module Mixin - Properties = ChefCompat::CopiedFromChef::Chef::Mixin::Properties - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches.rb deleted file mode 100644 index 9ac83e84..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches.rb +++ /dev/null @@ -1,41 +0,0 @@ -class Chef - class RunContext - class ChildRunContext < RunContext - # magic that lets us re-parse the ChildRunContext without erroring due to - # cheffish and chef-provisioning hooks having been loaded (on old versions of - # chef-client without the lazy hooks for those gems) - @__skip_method_checking = true - end - end -end - -# fix to quiet constant redefined warnings -if defined?(Chef::RunContext::ChildRunContext::CHILD_STATE) - Chef::RunContext::ChildRunContext.send(:remove_const, :CHILD_STATE) -end - -require 'chef_compat/monkeypatches/chef' -require 'chef_compat/monkeypatches/chef/exceptions' -require 'chef_compat/monkeypatches/chef/log' -require 'chef_compat/monkeypatches/chef/node' -require 'chef_compat/monkeypatches/chef/mixin/params_validate' -require 'chef_compat/monkeypatches/chef/property' -require 'chef_compat/monkeypatches/chef/provider' -require 'chef_compat/monkeypatches/chef/recipe' # copied from chef -require 'chef_compat/monkeypatches/chef/recipe_hook' -require 'chef_compat/monkeypatches/chef/resource' -require 'chef_compat/monkeypatches/chef/resource_builder' -require 'chef_compat/monkeypatches/chef/resource/lwrp_base' -require 'chef_compat/monkeypatches/chef/resource_collection' -require 'chef_compat/monkeypatches/chef/resource_collection/resource_list' -require 'chef_compat/monkeypatches/chef/resource_collection/resource_set' -require 'chef_compat/monkeypatches/chef/run_context' # copied from chef -require 'chef_compat/monkeypatches/chef/runner' # copied from chef - -# fix for Chef::RunContext instance that has already been created -ObjectSpace.each_object(Chef::RunContext) do |run_context| - run_context.node.run_context = run_context - run_context.instance_variable_set(:@loaded_recipes_hash, {}) - run_context.instance_variable_set(:@loaded_attributes_hash, {}) - run_context.initialize_child_state -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef.rb deleted file mode 100644 index 9669f6af..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef.rb +++ /dev/null @@ -1,33 +0,0 @@ -class Chef - NOT_PASSED = Object.new if !defined?(NOT_PASSED) - # Earlier versions of Chef didn't have this message - module ChefCompatDeprecation - def log_deprecation(message, location=nil) - if !location - # Pick the first caller that is *not* part of the Chef or ChefCompat gem, - # that's the thing the user wrote. - chef_compat_gem_path = File.expand_path("../../..", __FILE__) - chef_gem_path = File.expand_path("../..",::Chef::Resource.instance_method(:initialize).source_location[0]) - caller(0..10).each do |c| - if !c.start_with?(chef_gem_path) && !c.start_with?(chef_compat_gem_path) - location = c - break - end - end - end - - begin - super - # Bleagh. `super_method` doesn't exist on older rubies and I haven't - # figured out a way to check for its existence otherwise. - rescue NoMethodError - Chef::Log.warn(message) - end - end - end - - class<= 12.5 && Chef::VERSION.to_f <= 12.8 - require 'chef/mixin/params_validate' - class Chef - module Mixin - module ParamsValidate - class SetOrReturnProperty < Chef::Property - # 12.9 introduced a new optional parameter to `get()` to avoid a nil-set warning. - # When their method gets called with 2 args, we need to ignore and call with 1. - alias_method :_original_get2, :get - def get(resource, *args) - _original_get2(resource) - end - end - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/node.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/node.rb deleted file mode 100644 index 93379b07..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/node.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Chef - class Node - unless method_defined?(:set_cookbook_attribute) - def set_cookbook_attribute - # this implementation deliberately left blank - we don't need to do anything we just need to not fail - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb deleted file mode 100644 index 2308d329..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb +++ /dev/null @@ -1,15 +0,0 @@ -# 12.9 introduced a new optional parameter to `get()` to avoid a nil-set warning. -# We need to mimick it here. -if Chef::VERSION.to_f >= 12.5 && Chef::VERSION.to_f <= 12.8 - require 'chef/property' - class Chef - class Property - # 12.9 introduced a new optional parameter to `get()` to avoid a nil-set warning. - # When their method gets called with 2 args, we need to ignore and call with 1. - alias_method :_original_get, :get - def get(resource, *args) - _original_get(resource) - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/provider.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/provider.rb deleted file mode 100644 index 591cedb3..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/provider.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'chef/provider' -require 'chef/provider/lwrp_base' - -class Chef::Provider - if !defined?(InlineResources) - InlineResources = Chef::Provider::LWRPBase::InlineResources - end - module InlineResources - require 'chef/dsl/recipe' - require 'chef/dsl/platform_introspection' - require 'chef/dsl/data_query' - require 'chef/dsl/include_recipe' - include Chef::DSL::Recipe - include Chef::DSL::PlatformIntrospection - include Chef::DSL::DataQuery - include Chef::DSL::IncludeRecipe - - unless Chef::Provider::InlineResources::ClassMethods.instance_method(:action).source_location[0] =~ /chefspec/ - # Don't override action if chefspec is doing its thing - module ::ChefCompat - module Monkeypatches - module InlineResources - module ClassMethods - def action(name, &block) - super(name) { send("compile_action_#{name}") } - # We put the action in its own method so that super() works. - define_method("compile_action_#{name}", &block) - end - end - end - end - end - module ClassMethods - prepend ChefCompat::Monkeypatches::InlineResources::ClassMethods - end - end - end -end - - -class Chef - class Provider - class LWRPBase < Provider - if defined?(InlineResources) - module InlineResources - # since we upgrade the Chef::Runner and Chef::RunContext globally to >= 12.14 style classes, we need to also - # fix the use_inline_resources LWRPBase wrapper that creates a sub-resource collection with the ugpraded code - # from the Chef::Provider subclasses that do similar things in post-12.5 chef. - def recipe_eval_with_update_check(&block) - old_run_context = run_context - @run_context = run_context.create_child - return_value = instance_eval(&block) - Chef::Runner.new(run_context).converge - return_value - ensure - if run_context.resource_collection.any? { |r| r.updated? } - new_resource.updated_by_last_action(true) - end - @run_context = old_run_context - end - end - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe.rb deleted file mode 100644 index 7c4c8bef..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe.rb +++ /dev/null @@ -1,118 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -if Gem::Requirement.new('< 12.16.42').satisfied_by?(Gem::Version.new(Chef::VERSION)) -#-- -# Author:: Adam Jacob () -# Author:: Christopher Walters () -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef/dsl/recipe" -require "chef/mixin/from_file" -require "chef/mixin/deprecation" - -class Chef - # == Chef::Recipe - # A Recipe object is the context in which Chef recipes are evaluated. - class Recipe - attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context - - include Chef::DSL::Recipe - - include Chef::Mixin::FromFile - include Chef::Mixin::Deprecation - - # Parses a potentially fully-qualified recipe name into its - # cookbook name and recipe short name. - # - # For example: - # "aws::elastic_ip" returns [:aws, "elastic_ip"] - # "aws" returns [:aws, "default"] - # "::elastic_ip" returns [ current_cookbook, "elastic_ip" ] - #-- - # TODO: Duplicates functionality of RunListItem - def self.parse_recipe_name(recipe_name, current_cookbook: nil) - case recipe_name - when /(.+?)::(.+)/ - [ $1.to_sym, $2 ] - when /^::(.+)/ - raise "current_cookbook is nil, cannot resolve #{recipe_name}" if current_cookbook.nil? - [ current_cookbook.to_sym, $1 ] - else - [ recipe_name.to_sym, "default" ] - end - end - - def initialize(cookbook_name, recipe_name, run_context) - @cookbook_name = cookbook_name - @recipe_name = recipe_name - @run_context = run_context - # TODO: 5/19/2010 cw/tim: determine whether this can be removed - @params = Hash.new - end - - # Used in DSL mixins - def node - run_context.node - end - - # Used by the DSL to look up resources when executing in the context of a - # recipe. - def resources(*args) - run_context.resource_collection.find(*args) - end - - # This was moved to Chef::Node#tag, redirecting here for compatibility - def tag(*tags) - run_context.node.tag(*tags) - end - - # Returns true if the node is tagged with *all* of the supplied +tags+. - # - # === Parameters - # tags:: A list of tags - # - # === Returns - # true:: If all the parameters are present - # false:: If any of the parameters are missing - def tagged?(*tags) - tags.each do |tag| - return false unless run_context.node.tags.include?(tag) - end - true - end - - # Removes the list of tags from the node. - # - # === Parameters - # tags:: A list of tags - # - # === Returns - # tags:: The current list of run_context.node.tags - def untag(*tags) - tags.each do |tag| - run_context.node.tags.delete(tag) - end - end - end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe_hook.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe_hook.rb deleted file mode 100644 index 24aa20f8..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe_hook.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'chef/recipe' -require 'chef_compat/recipe' - -class Chef::Recipe - # If the cookbook depends on compat_resource, create a ChefCompat::Recipe object - # instead of Chef::Recipe, for the extra goodies. - def self.new(cookbook_name, recipe_name, run_context) - if run_context && - cookbook_name && - recipe_name && - run_context.cookbook_collection && - run_context.cookbook_collection[cookbook_name] && - run_context.cookbook_collection[cookbook_name].metadata.dependencies.has_key?('compat_resource') && - self != ::ChefCompat::Recipe - ::ChefCompat::Recipe.new(cookbook_name, recipe_name, run_context) - else - super - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource.rb deleted file mode 100644 index d61b60ba..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource.rb +++ /dev/null @@ -1,156 +0,0 @@ -# this is NOT an AUTOGENERATED file - -require 'chef/resource' - -class Chef - class Resource - - class UnresolvedSubscribes < self - # The full key ise given as the name in {Resource#subscribes} - alias_method :to_s, :name - alias_method :declared_key, :name - end - - # - # Force a delayed notification into this resource's run_context. - # - # This should most likely be paired with action :nothing - # - # @param arg [Array[Symbol], Symbol] A list of actions (e.g. `:create`) - # - def delayed_action(arg) - arg = Array(arg).map(&:to_sym) - arg.map do |action| - validate( - { action: action }, - { action: { kind_of: Symbol, equal_to: allowed_actions } } - ) - # the resource effectively sends a delayed notification to itself - run_context.add_delayed_action(Notification.new(self, action, self)) - end - end - - def subscribes(action, resources, timing = :delayed) - resources = [resources].flatten - resources.each do |resource| - if resource.is_a?(String) - resource = UnresolvedSubscribes.new(resource, run_context) - end - if resource.run_context.nil? - resource.run_context = run_context - end - resource.notifies(action, self, timing) - end - true - end - - def notifies(action, resource_spec, timing = :delayed) - # when using old-style resources(:template => "/foo.txt") style, you - # could end up with multiple resources. - validate_resource_spec!(resource_spec) - - resources = [ resource_spec ].flatten - resources.each do |resource| - - case timing.to_s - when "delayed" - notifies_delayed(action, resource) - when "immediate", "immediately" - notifies_immediately(action, resource) - when "before" - notifies_before(action, resource) - else - raise ArgumentError, "invalid timing: #{timing} for notifies(#{action}, #{resources.inspect}, #{timing}) resource #{self} "\ - "Valid timings are: :delayed, :immediate, :immediately, :before" - end - end - - true - end - - # - # Iterates over all immediate and delayed notifications, calling - # resolve_resource_reference on each in turn, causing them to - # resolve lazy/forward references. - def resolve_notification_references - run_context.before_notifications(self).each { |n| - n.resolve_resource_reference(run_context.resource_collection) - } - run_context.immediate_notifications(self).each { |n| - n.resolve_resource_reference(run_context.resource_collection) - } - run_context.delayed_notifications(self).each {|n| - n.resolve_resource_reference(run_context.resource_collection) - } - end - - # Helper for #notifies - def notifies_before(action, resource_spec) - run_context.notifies_before(Notification.new(resource_spec, action, self)) - end - - # Helper for #notifies - def notifies_immediately(action, resource_spec) - run_context.notifies_immediately(Notification.new(resource_spec, action, self)) - end - - # Helper for #notifies - def notifies_delayed(action, resource_spec) - run_context.notifies_delayed(Notification.new(resource_spec, action, self)) - end - - # - # Get the current actual value of this resource. - # - # This does not cache--a new value will be returned each time. - # - # @return A new copy of the resource, with values filled in from the actual - # current value. - # - def current_value - provider = provider_for_action(Array(action).first) - if provider.whyrun_mode? && !provider.whyrun_supported? - raise "Cannot retrieve #{self.class.current_resource} in why-run mode: #{provider} does not support why-run" - end - provider.load_current_resource - provider.current_resource - end - - # These methods are necessary for new resources to initialize old ones properly - attr_reader :resource_initializing - def resource_initializing=(value) - if value - @resource_initializing = value - else - remove_instance_variable(:@resource_initializing) - end - end - - if !respond_to?(:resource_name) - def self.resource_name(name=Chef::NOT_PASSED) - # Setter - if name != Chef::NOT_PASSED - # remove_canonical_dsl - - # Set the resource_name and call provides - if name - name = name.to_sym - # If our class is not already providing this name, provide it. - # Commented out: use of resource_name and provides will need to be - # mutually exclusive in this world, generally. - # if !Chef::ResourceResolver.includes_handler?(name, self) - provides name#, canonical: true - # end - @resource_name = name - else - @resource_name = nil - end - end - @resource_name - end - def self.resource_name=(name) - resource_name(name) - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb deleted file mode 100644 index 5f098fda..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'chef_compat/resource/lwrp_base' -require 'chef/resource/lwrp_base' - -module ChefCompat - module Monkeypatches - # - # NOTE: LOTS OF METAPROGRAMMING HERE. NOT FOR FAINT OF HEART. - # - - # Add an empty module to Class so we can temporarily override it in build_from_file - module Class - end - class<<::Class - prepend(ChefCompat::Monkeypatches::Class) - end - - module Chef - module Resource - module LWRPBase - def build_from_file(cookbook_name, filename, run_context) - # If the cookbook this LWRP is from depends on compat_resource, fix its LWRPs up real good - if run_context.cookbook_collection[cookbook_name].metadata.dependencies.has_key?('compat_resource') - # All cookbooks do Class.new(Chef::Resource::LWRPBase). Change Class.new - # temporarily to translate Chef::Resource::LWRPBase to ChefCompat::Resource - ChefCompat::Monkeypatches::Class.module_eval do - def new(*args, &block) - # Trick it! Use ChefCompat::Resource instead of Chef::Resource::LWRPBase - if args == [ ::Chef::Resource::LWRPBase ] - ChefCompat::Monkeypatches::Class.module_eval do - remove_method(:new) if method_defined?(:new) - end - args = [ ChefCompat::Resource::LWRPBase ] - end - super(*args, &block) - end - end - - begin - - # Call the actual build_from_file - super - - ensure - class<) -# Copyright:: Copyright 2015-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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. -# - -# XXX: we now have two copies of this file in the compat_resource cookbook. I'm uncertain if this is a -# bug or a feature, and I suspect it is actually a feature. The point of this file is that for all -# resources and cookbooks the global Chef::ResourceBuilder class must be upgraded to at least the -# 12.10.24 version. The point of the other copy is that for compat_resource cookbooks all their -# resources should be using the lastest version that has been sync'd. So these two files should -# diverge as times goes on. I believe that is the correct behavior and that we want to have both -# files in this cookbook. - -# NOTE: this was extracted from the Recipe DSL mixin, relevant specs are in spec/unit/recipe_spec.rb - -if Gem::Requirement.new("< 12.10.24").satisfied_by?(Gem::Version.new(Chef::VERSION)) - begin - require 'chef/resource_builder' - # we use the LoadError this creates on early 12.x to not monkeypatch chef client versions that don't have Chef::ResourceBuilder - # (it is lazily included and doesn't appear until compile time so we can't resolve the symbol during library loading) - - class Chef - class ResourceBuilder - attr_reader :type - attr_reader :name - attr_reader :created_at - attr_reader :params - attr_reader :run_context - attr_reader :cookbook_name - attr_reader :recipe_name - attr_reader :enclosing_provider - attr_reader :resource - - # FIXME (ruby-2.1 syntax): most of these are mandatory - def initialize(type:nil, name:nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil) - @type = type - @name = name - @created_at = created_at - @params = params - @run_context = run_context - @cookbook_name = cookbook_name - @recipe_name = recipe_name - @enclosing_provider = enclosing_provider - end - - def build(&block) - raise ArgumentError, "You must supply a name when declaring a #{type} resource" if name.nil? - - @resource = resource_class.new(name, run_context) - if resource.resource_name.nil? - raise Chef::Exceptions::InvalidResourceSpecification, "#{resource}.resource_name is `nil`! Did you forget to put `provides :blah` or `resource_name :blah` in your resource class?" - end - resource.source_line = created_at - resource.declared_type = type - - # If we have a resource like this one, we want to steal its state - # This behavior is very counter-intuitive and should be removed. - # See CHEF-3694, https://tickets.opscode.com/browse/CHEF-3694 - # Moved to this location to resolve CHEF-5052, https://tickets.opscode.com/browse/CHEF-5052 - if prior_resource - resource.load_from(prior_resource) - end - - resource.cookbook_name = cookbook_name - resource.recipe_name = recipe_name - # Determine whether this resource is being created in the context of an enclosing Provider - resource.enclosing_provider = enclosing_provider - - # XXX: this is required for definition params inside of the scope of a - # subresource to work correctly. - resource.params = params - - # Evaluate resource attribute DSL - if block_given? - resource.resource_initializing = true - begin - resource.instance_eval(&block) - ensure - resource.resource_initializing = false - end - end - - # emit a cloned resource warning if it is warranted - if prior_resource - if is_trivial_resource?(prior_resource) && identicalish_resources?(prior_resource, resource) - emit_harmless_cloning_debug - else - emit_cloned_resource_warning - end - end - - # Run optional resource hook - resource.after_created - - resource - end - - private - - def resource_class - # Checks the new platform => short_name => resource mapping initially - # then fall back to the older approach (Chef::Resource.const_get) for - # backward compatibility - @resource_class ||= Chef::Resource.resource_for_node(type, run_context.node) - end - - def is_trivial_resource?(resource) - identicalish_resources?(resource_class.new(name, run_context), resource) - end - - # this is an equality test specific to checking for 3694 cloning warnings - def identicalish_resources?(first, second) - skipped_ivars = [ :@source_line, :@cookbook_name, :@recipe_name, :@params, :@elapsed_time, :@declared_type ] - checked_ivars = ( first.instance_variables | second.instance_variables ) - skipped_ivars - non_matching_ivars = checked_ivars.reject do |iv| - if iv == :@action && ( [first.instance_variable_get(iv)].flatten == [:nothing] || [second.instance_variable_get(iv)].flatten == [:nothing] ) - # :nothing action on either side of the comparison always matches - true - else - first.instance_variable_get(iv) == second.instance_variable_get(iv) - end - end - Chef::Log.debug("ivars which did not match with the prior resource: #{non_matching_ivars}") - non_matching_ivars.empty? - end - - def emit_cloned_resource_warning - Chef::Log.warn("Cloning resource attributes for #{resource} from prior resource (CHEF-3694)") - Chef::Log.warn("Previous #{prior_resource}: #{prior_resource.source_line}") if prior_resource.source_line - Chef::Log.warn("Current #{resource}: #{resource.source_line}") if resource.source_line - end - - def emit_harmless_cloning_debug - Chef::Log.debug("Harmless resource cloning from #{prior_resource}:#{prior_resource.source_line} to #{resource}:#{resource.source_line}") - end - - def prior_resource - @prior_resource ||= - begin - key = "#{type}[#{name}]" - run_context.resource_collection.lookup_local(key) - rescue Chef::Exceptions::ResourceNotFound - nil - end - end - - end - end - rescue LoadError - # cool we're just on early chef 12.x, nothing to do -- we don't have to worry because there's also not parent_run_context pointer, so we don't have to - # use lookup_local to avoid resource cloning shit out of the parent run_context. the resource collection's lookup() method will always use lookup_local - # over lookup_recursive. - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection.rb deleted file mode 100644 index 4f074898..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection.rb +++ /dev/null @@ -1,103 +0,0 @@ -# -# Author:: Adam Jacob () -# Author:: Christopher Walters () -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef/resource_collection/resource_set" -require "chef/resource_collection/resource_list" -require "chef/resource_collection" -require "chef/exceptions" - -module ChefCompat - module Monkeypatches - module Chef - module ResourceCollection - module RecursiveNotificationLookup - # - # Copied verbatim from Chef 12.10.24 - # - attr_accessor :run_context - - def initialize(run_context = nil) - super() - @run_context = run_context - end - - def lookup_local(key) - resource_set.lookup(key) - end - - def find_local(*args) - resource_set.find(*args) - end - - def lookup(key) - if run_context.nil? - lookup_local(key) - else - lookup_recursive(run_context, key) - end - end - - def find(*args) - if run_context.nil? - find_local(*args) - else - find_recursive(run_context, *args) - end - end - - private - - def lookup_recursive(rc, key) - rc.resource_collection.send(:resource_set).lookup(key) - rescue ::Chef::Exceptions::ResourceNotFound - raise if !rc.respond_to?(:parent_run_context) || rc.parent_run_context.nil? - lookup_recursive(rc.parent_run_context, key) - end - - def find_recursive(rc, *args) - rc.resource_collection.send(:resource_set).find(*args) - rescue ::Chef::Exceptions::ResourceNotFound - raise if !rc.respond_to?(:parent_run_context) || rc.parent_run_context.nil? - find_recursive(rc.parent_run_context, *args) - end - end - - module DeleteResources - # - # Copied verbatim from Chef 12.10.24 - # - def delete(key) - resource_list.delete(key) - resource_set.delete(key) - end - end - end - end - end -end - - -class Chef::ResourceCollection - unless method_defined?(:lookup_local) - prepend ChefCompat::Monkeypatches::Chef::ResourceCollection::RecursiveNotificationLookup - end - unless method_defined?(:delete) - prepend ChefCompat::Monkeypatches::Chef::ResourceCollection::DeleteResources - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_list.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_list.rb deleted file mode 100644 index dfbd442d..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_list.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Author:: Tyler Ball () -# Copyright:: Copyright 2014-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef/resource_collection/resource_list" -require "chef/exceptions" - -module ChefCompat - module Monkeypatches - module Chef - module ResourceCollection - module ResourceList - module DeleteResource - # Copied verbatim from Chef 12.10.4 - def delete(key) - raise ArgumentError, "Must pass a Chef::Resource or String to delete" unless key.is_a?(String) || key.is_a?(Chef::Resource) - key = key.to_s - ret = @resources.reject! { |r| r.to_s == key } - if ret.nil? - raise ::Chef::Exceptions::ResourceNotFound, "Cannot find a resource matching #{key} (did you define it first?)" - end - ret - end - end - end - end - end - end -end - -class Chef::ResourceCollection::ResourceList - unless method_defined?(:delete) - prepend ChefCompat::Monkeypatches::Chef::ResourceCollection::ResourceList::DeleteResource - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_set.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_set.rb deleted file mode 100644 index bcead102..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_set.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Author:: Tyler Ball () -# Copyright:: Copyright 2014-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef/resource_collection/resource_list" -require "chef/exceptions" - -module ChefCompat - module Monkeypatches - module Chef - module ResourceCollection - module ResourceSet - module DeleteResource - def delete(key) - raise ArgumentError, "Must pass a Chef::Resource or String to delete" unless key.is_a?(String) || key.is_a?(Chef::Resource) - key = key.to_s - res = @resources_by_key.delete(key) - - if res == @resources_by_key.default - raise Chef::Exceptions::ResourceNotFound, "Cannot find a resource matching #{key} (did you define it first?)" - end - res - end - end - end - end - end - end -end - -class Chef::ResourceCollection::ResourceSet - unless method_defined?(:delete) - prepend ChefCompat::Monkeypatches::Chef::ResourceCollection::ResourceSet::DeleteResource - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/run_context.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/run_context.rb deleted file mode 100644 index 03c9d60e..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/run_context.rb +++ /dev/null @@ -1,691 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -if Gem::Requirement.new('< 12.16.42').satisfied_by?(Gem::Version.new(Chef::VERSION)) -# -# Author:: Adam Jacob () -# Author:: Christopher Walters () -# Author:: Tim Hinderliter () -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef/resource_collection" -require "chef/cookbook_version" -require "chef/node" -require "chef/role" -require "chef/log" -require "chef/recipe" -require "chef/run_context/cookbook_compiler" -require "chef/event_dispatch/events_output_stream" -require "forwardable" - -class Chef - - # == Chef::RunContext - # Value object that loads and tracks the context of a Chef run - class RunContext - # - # Global state - # - - # - # The node for this run - # - # @return [Chef::Node] - # - attr_reader :node - - # - # The set of cookbooks involved in this run - # - # @return [Chef::CookbookCollection] - # - attr_reader :cookbook_collection - - # - # Resource Definitions for this run. Populated when the files in - # +definitions/+ are evaluated (this is triggered by #load). - # - # @return [Array[Chef::ResourceDefinition]] - # - attr_reader :definitions - - # - # Event dispatcher for this run. - # - # @return [Chef::EventDispatch::Dispatcher] - # - attr_reader :events - - # - # Hash of factoids for a reboot request. - # - # @return [Hash] - # - attr_accessor :reboot_info - - # - # Scoped state - # - - # - # The parent run context. - # - # @return [Chef::RunContext] The parent run context, or `nil` if this is the - # root context. - # - attr_reader :parent_run_context - - # - # The root run context. - # - # @return [Chef::RunContext] The root run context. - # - def root_run_context - rc = self - rc = rc.parent_run_context until rc.parent_run_context.nil? - rc - end - - # - # The collection of resources intended to be converged (and able to be - # notified). - # - # @return [Chef::ResourceCollection] - # - # @see CookbookCompiler - # - attr_reader :resource_collection - - # - # The list of control groups to execute during the audit phase - # - attr_reader :audits - - # - # Notification handling - # - - # - # A Hash containing the before notifications triggered by resources - # during the converge phase of the chef run. - # - # @return [Hash[String, Array[Chef::Resource::Notification]]] A hash from - # => - # - attr_reader :before_notification_collection - - # - # A Hash containing the immediate notifications triggered by resources - # during the converge phase of the chef run. - # - # @return [Hash[String, Array[Chef::Resource::Notification]]] A hash from - # => - # - attr_reader :immediate_notification_collection - - # - # A Hash containing the delayed (end of run) notifications triggered by - # resources during the converge phase of the chef run. - # - # @return [Hash[String, Array[Chef::Resource::Notification]]] A hash from - # => - # - attr_reader :delayed_notification_collection - - # - # An Array containing the delayed (end of run) notifications triggered by - # resources during the converge phase of the chef run. - # - # @return [Array[Chef::Resource::Notification]] An array of notification objects - # - attr_reader :delayed_actions - - # Creates a new Chef::RunContext object and populates its fields. This object gets - # used by the Chef Server to generate a fully compiled recipe list for a node. - # - # @param node [Chef::Node] The node to run against. - # @param cookbook_collection [Chef::CookbookCollection] The cookbooks - # involved in this run. - # @param events [EventDispatch::Dispatcher] The event dispatcher for this - # run. - # - def initialize(node, cookbook_collection, events) - @node = node - @cookbook_collection = cookbook_collection - @events = events - - node.run_context = self - node.set_cookbook_attribute - - @definitions = Hash.new - @loaded_recipes_hash = {} - @loaded_attributes_hash = {} - @reboot_info = {} - @cookbook_compiler = nil - @delayed_actions = [] - - initialize_child_state - end - - # - # Triggers the compile phase of the chef run. - # - # @param run_list_expansion [Chef::RunList::RunListExpansion] The run list. - # @see Chef::RunContext::CookbookCompiler - # - def load(run_list_expansion) - @cookbook_compiler = CookbookCompiler.new(self, run_list_expansion, events) - cookbook_compiler.compile - end - - # - # Initialize state that applies to both Chef::RunContext and Chef::ChildRunContext - # - def initialize_child_state - @audits = {} - @resource_collection = Chef::ResourceCollection.new(self) - @before_notification_collection = Hash.new { |h, k| h[k] = [] } - @immediate_notification_collection = Hash.new { |h, k| h[k] = [] } - @delayed_notification_collection = Hash.new { |h, k| h[k] = [] } - @delayed_actions = [] - end - - # - # Adds an before notification to the +before_notification_collection+. - # - # @param [Chef::Resource::Notification] The notification to add. - # - def notifies_before(notification) - # Note for the future, notification.notifying_resource may be an instance - # of Chef::Resource::UnresolvedSubscribes when calling {Resource#subscribes} - # with a string value. - before_notification_collection[notification.notifying_resource.declared_key] << notification - end - - # - # Adds an immediate notification to the +immediate_notification_collection+. - # - # @param [Chef::Resource::Notification] The notification to add. - # - def notifies_immediately(notification) - # Note for the future, notification.notifying_resource may be an instance - # of Chef::Resource::UnresolvedSubscribes when calling {Resource#subscribes} - # with a string value. - immediate_notification_collection[notification.notifying_resource.declared_key] << notification - end - - # - # Adds a delayed notification to the +delayed_notification_collection+. - # - # @param [Chef::Resource::Notification] The notification to add. - # - def notifies_delayed(notification) - # Note for the future, notification.notifying_resource may be an instance - # of Chef::Resource::UnresolvedSubscribes when calling {Resource#subscribes} - # with a string value. - delayed_notification_collection[notification.notifying_resource.declared_key] << notification - end - - # - # Adds a delayed action to the +delayed_actions+. - # - def add_delayed_action(notification) - if delayed_actions.any? { |existing_notification| existing_notification.duplicates?(notification) } - Chef::Log.info( "#{notification.notifying_resource} not queuing delayed action #{notification.action} on #{notification.resource}"\ - " (delayed), as it's already been queued") - else - delayed_actions << notification - end - end - - # - # Get the list of before notifications sent by the given resource. - # - # @return [Array[Notification]] - # - def before_notifications(resource) - return before_notification_collection[resource.declared_key] - end - - # - # Get the list of immediate notifications sent by the given resource. - # - # @return [Array[Notification]] - # - def immediate_notifications(resource) - return immediate_notification_collection[resource.declared_key] - end - - # - # Get the list of delayed (end of run) notifications sent by the given - # resource. - # - # @return [Array[Notification]] - # - def delayed_notifications(resource) - return delayed_notification_collection[resource.declared_key] - end - - # - # Cookbook and recipe loading - # - - # - # Evaluates the recipes +recipe_names+. Used by DSL::IncludeRecipe - # - # @param recipe_names [Array[String]] The list of recipe names (e.g. - # 'my_cookbook' or 'my_cookbook::my_resource'). - # @param current_cookbook The cookbook we are currently running in. - # - # @see DSL::IncludeRecipe#include_recipe - # - def include_recipe(*recipe_names, current_cookbook: nil) - result_recipes = Array.new - recipe_names.flatten.each do |recipe_name| - if result = load_recipe(recipe_name, current_cookbook: current_cookbook) - result_recipes << result - end - end - result_recipes - end - - # - # Evaluates the recipe +recipe_name+. Used by DSL::IncludeRecipe - # - # TODO I am sort of confused why we have both this and include_recipe ... - # I don't see anything different beyond accepting and returning an - # array of recipes. - # - # @param recipe_names [Array[String]] The recipe name (e.g 'my_cookbook' or - # 'my_cookbook::my_resource'). - # @param current_cookbook The cookbook we are currently running in. - # - # @return A truthy value if the load occurred; `false` if already loaded. - # - # @see DSL::IncludeRecipe#load_recipe - # - def load_recipe(recipe_name, current_cookbook: nil) - Chef::Log.debug("Loading recipe #{recipe_name} via include_recipe") - - cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name, current_cookbook: current_cookbook) - - if unreachable_cookbook?(cookbook_name) # CHEF-4367 - Chef::Log.warn(<<-ERROR_MESSAGE) -MissingCookbookDependency: -Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}' -is not a dependency of any cookbook in the run_list. To load this recipe, -first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're -including it from in that cookbook's metadata. -ERROR_MESSAGE - end - - if loaded_fully_qualified_recipe?(cookbook_name, recipe_short_name) - Chef::Log.debug("I am not loading #{recipe_name}, because I have already seen it.") - false - else - loaded_recipe(cookbook_name, recipe_short_name) - node.loaded_recipe(cookbook_name, recipe_short_name) - cookbook = cookbook_collection[cookbook_name] - cookbook.load_recipe(recipe_short_name, self) - end - end - - # - # Load the given recipe from a filename. - # - # @param recipe_file [String] The recipe filename. - # - # @return [Chef::Recipe] The loaded recipe. - # - # @raise [Chef::Exceptions::RecipeNotFound] If the file does not exist. - # - def load_recipe_file(recipe_file) - if !File.exist?(recipe_file) - raise Chef::Exceptions::RecipeNotFound, "could not find recipe file #{recipe_file}" - end - - Chef::Log.debug("Loading recipe file #{recipe_file}") - recipe = Chef::Recipe.new("@recipe_files", recipe_file, self) - recipe.from_file(recipe_file) - recipe - end - - # - # Look up an attribute filename. - # - # @param cookbook_name [String] The cookbook name of the attribute file. - # @param attr_file_name [String] The attribute file's name (not path). - # - # @return [String] The filename. - # - # @see DSL::IncludeAttribute#include_attribute - # - # @raise [Chef::Exceptions::CookbookNotFound] If the cookbook could not be found. - # @raise [Chef::Exceptions::AttributeNotFound] If the attribute file could not be found. - # - def resolve_attribute(cookbook_name, attr_file_name) - cookbook = cookbook_collection[cookbook_name] - raise Chef::Exceptions::CookbookNotFound, "could not find cookbook #{cookbook_name} while loading attribute #{name}" unless cookbook - - attribute_filename = cookbook.attribute_filenames_by_short_filename[attr_file_name] - raise Chef::Exceptions::AttributeNotFound, "could not find filename for attribute #{attr_file_name} in cookbook #{cookbook_name}" unless attribute_filename - - attribute_filename - end - - # - # A list of all recipes that have been loaded. - # - # This is stored internally as a Hash, so ordering is predictable. - # - # TODO is the above statement true in a 1.9+ ruby world? Is it relevant? - # - # @return [Array[String]] A list of recipes in fully qualified form, e.g. - # the recipe "nginx" will be given as "nginx::default". - # - # @see #loaded_recipe? To determine if a particular recipe has been loaded. - # - def loaded_recipes - loaded_recipes_hash.keys - end - - # - # A list of all attributes files that have been loaded. - # - # Stored internally using a Hash, so order is predictable. - # - # TODO is the above statement true in a 1.9+ ruby world? Is it relevant? - # - # @return [Array[String]] A list of attribute file names in fully qualified - # form, e.g. the "nginx" will be given as "nginx::default". - # - def loaded_attributes - loaded_attributes_hash.keys - end - - # - # Find out if a given recipe has been loaded. - # - # @param cookbook [String] Cookbook name. - # @param recipe [String] Recipe name. - # - # @return [Boolean] `true` if the recipe has been loaded, `false` otherwise. - # - def loaded_fully_qualified_recipe?(cookbook, recipe) - loaded_recipes_hash.has_key?("#{cookbook}::#{recipe}") - end - - # - # Find out if a given recipe has been loaded. - # - # @param recipe [String] Recipe name. "nginx" and "nginx::default" yield - # the same results. - # - # @return [Boolean] `true` if the recipe has been loaded, `false` otherwise. - # - def loaded_recipe?(recipe) - cookbook, recipe_name = Chef::Recipe.parse_recipe_name(recipe) - loaded_fully_qualified_recipe?(cookbook, recipe_name) - end - - # - # Mark a given recipe as having been loaded. - # - # @param cookbook [String] Cookbook name. - # @param recipe [String] Recipe name. - # - def loaded_recipe(cookbook, recipe) - loaded_recipes_hash["#{cookbook}::#{recipe}"] = true - end - - # - # Find out if a given attribute file has been loaded. - # - # @param cookbook [String] Cookbook name. - # @param attribute_file [String] Attribute file name. - # - # @return [Boolean] `true` if the recipe has been loaded, `false` otherwise. - # - def loaded_fully_qualified_attribute?(cookbook, attribute_file) - loaded_attributes_hash.has_key?("#{cookbook}::#{attribute_file}") - end - - # - # Mark a given attribute file as having been loaded. - # - # @param cookbook [String] Cookbook name. - # @param attribute_file [String] Attribute file name. - # - def loaded_attribute(cookbook, attribute_file) - loaded_attributes_hash["#{cookbook}::#{attribute_file}"] = true - end - - ## - # Cookbook File Introspection - - # - # Find out if the cookbook has the given template. - # - # @param cookbook [String] Cookbook name. - # @param template_name [String] Template name. - # - # @return [Boolean] `true` if the template is in the cookbook, `false` - # otherwise. - # @see Chef::CookbookVersion#has_template_for_node? - # - def has_template_in_cookbook?(cookbook, template_name) - cookbook = cookbook_collection[cookbook] - cookbook.has_template_for_node?(node, template_name) - end - - # - # Find out if the cookbook has the given file. - # - # @param cookbook [String] Cookbook name. - # @param cb_file_name [String] File name. - # - # @return [Boolean] `true` if the file is in the cookbook, `false` - # otherwise. - # @see Chef::CookbookVersion#has_cookbook_file_for_node? - # - def has_cookbook_file_in_cookbook?(cookbook, cb_file_name) - cookbook = cookbook_collection[cookbook] - cookbook.has_cookbook_file_for_node?(node, cb_file_name) - end - - # - # Find out whether the given cookbook is in the cookbook dependency graph. - # - # @param cookbook_name [String] Cookbook name. - # - # @return [Boolean] `true` if the cookbook is reachable, `false` otherwise. - # - # @see Chef::CookbookCompiler#unreachable_cookbook? - def unreachable_cookbook?(cookbook_name) - cookbook_compiler.unreachable_cookbook?(cookbook_name) - end - - # - # Open a stream object that can be printed into and will dispatch to events - # - # @param name [String] The name of the stream. - # @param options [Hash] Other options for the stream. - # - # @return [EventDispatch::EventsOutputStream] The created stream. - # - # @yield If a block is passed, it will be run and the stream will be closed - # afterwards. - # @yieldparam stream [EventDispatch::EventsOutputStream] The created stream. - # - def open_stream(name: nil, **options) - stream = EventDispatch::EventsOutputStream.new(events, name: name, **options) - if block_given? - begin - yield stream - ensure - stream.close - end - else - stream - end - end - - # there are options for how to handle multiple calls to these functions: - # 1. first call always wins (never change reboot_info once set). - # 2. last call always wins (happily change reboot_info whenever). - # 3. raise an exception on the first conflict. - # 4. disable reboot after this run if anyone ever calls :cancel. - # 5. raise an exception on any second call. - # 6. ? - def request_reboot(reboot_info) - Chef::Log.info "Changing reboot status from #{self.reboot_info.inspect} to #{reboot_info.inspect}" - @reboot_info = reboot_info - end - - def cancel_reboot - Chef::Log.info "Changing reboot status from #{reboot_info.inspect} to {}" - @reboot_info = {} - end - - def reboot_requested? - reboot_info.size > 0 - end - - # - # Create a child RunContext. - # - def create_child - ChildRunContext.new(self) - end - - # @api private - attr_writer :resource_collection - - protected - - attr_reader :cookbook_compiler - attr_reader :loaded_attributes_hash - attr_reader :loaded_recipes_hash - - module Deprecated - ### - # These need to be settable so deploy can run a resource_collection - # independent of any cookbooks via +recipe_eval+ - def audits=(value) - Chef.log_deprecation("Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.") - @audits = value - end - - def immediate_notification_collection=(value) - Chef.log_deprecation("Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.") - @immediate_notification_collection = value - end - - def delayed_notification_collection=(value) - Chef.log_deprecation("Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.") - @delayed_notification_collection = value - end - end - prepend Deprecated - - # - # A child run context. Delegates all root context calls to its parent. - # - # @api private - # - class ChildRunContext < RunContext - extend Forwardable - def_delegators :parent_run_context, *%w{ - cancel_reboot - config - cookbook_collection - cookbook_compiler - definitions - events - has_cookbook_file_in_cookbook? - has_template_in_cookbook? - load - loaded_attribute - loaded_attributes - loaded_attributes_hash - loaded_fully_qualified_attribute? - loaded_fully_qualified_recipe? - loaded_recipe - loaded_recipe? - loaded_recipes - loaded_recipes_hash - node - open_stream - reboot_info - reboot_info= - reboot_requested? - request_reboot - resolve_attribute - unreachable_cookbook? - } - - def initialize(parent_run_context) - @parent_run_context = parent_run_context - - # We don't call super, because we don't bother initializing stuff we're - # going to delegate to the parent anyway. Just initialize things that - # every instance needs. - initialize_child_state - end - - CHILD_STATE = %w{ - audits - audits= - create_child - add_delayed_action - delayed_actions - delayed_notification_collection - delayed_notification_collection= - delayed_notifications - immediate_notification_collection - immediate_notification_collection= - immediate_notifications - before_notification_collection - before_notifications - include_recipe - initialize_child_state - load_recipe - load_recipe_file - notifies_before - notifies_immediately - notifies_delayed - parent_run_context - root_run_context - resource_collection - resource_collection= - }.map { |x| x.to_sym } - - # Verify that we didn't miss any methods - unless @__skip_method_checking # hook specifically for compat_resource - missing_methods = superclass.instance_methods(false) - instance_methods(false) - CHILD_STATE - if !missing_methods.empty? - raise "ERROR: not all methods of RunContext accounted for in ChildRunContext! All methods must be marked as child methods with CHILD_STATE or delegated to the parent_run_context. Missing #{missing_methods.join(", ")}." - end - end - end - end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb deleted file mode 100644 index 9add7a8b..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb +++ /dev/null @@ -1,153 +0,0 @@ -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# -# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!! -# -# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE -# - -if Gem::Requirement.new('< 12.16.42').satisfied_by?(Gem::Version.new(Chef::VERSION)) -#-- -# Author:: Adam Jacob () -# Author:: Christopher Walters () -# Author:: Tim Hinderliter () -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# 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 "chef/exceptions" -require "chef/mixin/params_validate" -require "chef/node" -require "chef/resource_collection" - -class Chef - # == Chef::Runner - # This class is responsible for executing the steps in a Chef run. - class Runner - - attr_reader :run_context - - include Chef::Mixin::ParamsValidate - - def initialize(run_context) - @run_context = run_context - end - - def delayed_actions - @run_context.delayed_actions - end - - def events - @run_context.events - end - - # Determine the appropriate provider for the given resource, then - # execute it. - def run_action(resource, action, notification_type = nil, notifying_resource = nil) - # If there are any before notifications, why-run the resource - # and notify anyone who needs notifying - before_notifications = run_context.before_notifications(resource) || [] - unless before_notifications.empty? - forced_why_run do - Chef::Log.info("#{resource} running why-run #{action} action to support before action") - resource.run_action(action, notification_type, notifying_resource) - end - - if resource.updated_by_last_action? - before_notifications.each do |notification| - Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (before)") - run_action(notification.resource, notification.action, :before, resource) - end - resource.updated_by_last_action(false) - end - end - - # Actually run the action for realsies - resource.run_action(action, notification_type, notifying_resource) - - # Execute any immediate and queue up any delayed notifications - # associated with the resource, but only if it was updated *this time* - # we ran an action on it. - if resource.updated_by_last_action? - run_context.immediate_notifications(resource).each do |notification| - Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (immediate)") - run_action(notification.resource, notification.action, :immediate, resource) - end - - run_context.delayed_notifications(resource).each do |notification| - # send the notification to the run_context of the receiving resource - notification.resource.run_context.add_delayed_action(notification) - end - end - end - - # Iterates over the +resource_collection+ in the +run_context+ calling - # +run_action+ for each resource in turn. - def converge - # Resolve all lazy/forward references in notifications - run_context.resource_collection.each do |resource| - resource.resolve_notification_references - end - - # Execute each resource. - run_context.resource_collection.execute_each_resource do |resource| - Array(resource.action).each { |action| run_action(resource, action) } - end - - rescue Exception => e - Chef::Log.info "Running queued delayed notifications before re-raising exception" - run_delayed_notifications(e) - else - run_delayed_notifications(nil) - true - end - - private - - # Run all our :delayed actions - def run_delayed_notifications(error = nil) - collected_failures = Exceptions::MultipleFailures.new - collected_failures.client_run_failure(error) unless error.nil? - delayed_actions.each do |notification| - result = run_delayed_notification(notification) - if result.kind_of?(Exception) - collected_failures.notification_failure(result) - end - end - collected_failures.raise! - end - - def run_delayed_notification(notification) - Chef::Log.info( "#{notification.notifying_resource} sending #{notification.action}"\ - " action to #{notification.resource} (delayed)") - # Struct of resource/action to call - run_action(notification.resource, notification.action, :delayed) - true - rescue Exception => e - e - end - - # helper to run a block of code with why_run forced to true and then restore it correctly - def forced_why_run - saved = Chef::Config[:why_run] - Chef::Config[:why_run] = true - yield - ensure - Chef::Config[:why_run] = saved - end - - end -end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/property.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/property.rb deleted file mode 100644 index be211135..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/property.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'chef_compat/copied_from_chef/chef/property' - -module ChefCompat - class Property < ChefCompat::CopiedFromChef::Chef::Property - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/recipe.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/recipe.rb deleted file mode 100644 index 86e39d97..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/recipe.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'chef/recipe' -require 'chef_compat/copied_from_chef/chef/dsl/recipe' - -module ChefCompat - class Recipe < Chef::Recipe - include ChefCompat::CopiedFromChef::Chef::DSL::Recipe::FullDSL - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/resource.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/resource.rb deleted file mode 100644 index bcf0fdb2..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/resource.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'chef_compat/monkeypatches' -require 'chef_compat/copied_from_chef/chef/resource' - -# We do NOT want action defined if chefspec is engaged -if Chef::Provider::InlineResources::ClassMethods.instance_method(:action).source_location[0] =~ /chefspec/ - ChefCompat::CopiedFromChef::Chef::Provider::InlineResources::ClassMethods.instance_eval do - remove_method(:action) - end -end - -module ChefCompat - class Resource < ChefCompat::CopiedFromChef::Chef::Resource - def initialize(*args, &block) - super - # @resource_name is used in earlier Chef versions - @resource_name = self.class.resource_name - end - # Things we'll need to define ourselves: - # 1. provider - # 2. resource_name - - def provider(*args, &block) - super || self.class.action_class - end - def provider=(arg) - provider(arg) - end - - if !respond_to?(:resource_name) - def self.resource_name(name=Chef::NOT_PASSED) - # Setter - if name != Chef::NOT_PASSED - # remove_canonical_dsl - - # Set the resource_name and call provides - if name - name = name.to_sym - # If our class is not already providing this name, provide it. - # Commented out: use of resource_name and provides will need to be - # mutually exclusive in this world, generally. - # if !Chef::ResourceResolver.includes_handler?(name, self) - provides name#, canonical: true - # end - @resource_name = name - else - @resource_name = nil - end - end - @resource_name - end - def self.resource_name=(name) - resource_name(name) - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/files/lib/chef_compat/resource/lwrp_base.rb b/vendor-cookbooks/compat_resource/files/lib/chef_compat/resource/lwrp_base.rb deleted file mode 100644 index 2ebb98fd..00000000 --- a/vendor-cookbooks/compat_resource/files/lib/chef_compat/resource/lwrp_base.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'chef_compat/resource' -require 'chef_compat/copied_from_chef/chef/resource' -require 'chef/mixin/convert_to_class_name' -require 'chef/mixin/from_file' - -module ChefCompat - class Resource < ChefCompat::CopiedFromChef::Chef::Resource - class LWRPBase < ChefCompat::Resource - class<= 12.0").satisfied_by?(Gem::Version.new(Chef::VERSION)) - - require 'chef_compat/resource' - require 'chef_compat/property' - require 'chef_compat/mixin/properties' - - resources_dir = File.expand_path("chef_compat/copied_from_chef/chef/resource", File.dirname(__FILE__)) - providers_dir = File.expand_path("chef_compat/copied_from_chef/chef/provider", File.dirname(__FILE__)) - Dir["#{resources_dir}/*.rb"].each {|file| require file } - Dir["#{providers_dir}/*.rb"].each {|file| require file } -else - - class Chef - class Resource - def self.property(args, &block) - raise_chef_11_error - end - - def self.resource_name(args, &block) - raise_chef_11_error - end - - def self.action(args, &block) - raise_chef_11_error - end - - def self.raise_chef_11_error - raise "This resource is written with Chef 12.5 custom resources, and requires at least Chef 12.0 used with the compat_resource cookbook, it will not work with Chef 11.x clients, and those users must pin their cookbooks to older versions or upgrade." - end - end - end - -end diff --git a/vendor-cookbooks/compat_resource/libraries/autoload.rb b/vendor-cookbooks/compat_resource/libraries/autoload.rb deleted file mode 100644 index db52cfc6..00000000 --- a/vendor-cookbooks/compat_resource/libraries/autoload.rb +++ /dev/null @@ -1,31 +0,0 @@ -unless Gem::Requirement.new(">= 12.0").satisfied_by?(Gem::Version.new(Chef::VERSION)) - raise "This resource is written with Chef 12.5 custom resources, and requires at least Chef 12.0 used with the compat_resource cookbook, it will not work with Chef 11.x clients, and those users must pin their cookbooks to older versions or upgrade." -end - -# If users are on old verisons of ChefDK which activates an (old) gem via cheffish before this cookbook loads, then -# we just try to monkeypatch over the top of a monkeypatch. Its possible that we have checks in this cookbook which -# will defeat that purpose and fail to monkeypatch on top of monkeypatches -- in which case those checks should be -# removed -- this cookbook needs to win when it gets into a fight with the old gem versions. -if Gem.loaded_specs["compat_resource"] - Chef.log_deprecation "using compat_resource as a gem is deprecated; please update cheffish and chef-provisioning gems (or use the latest Chef/ChefDK packages) or else manually pin your compat_resource cookbook version to the same version as the gem you are using to remove this warning" -end - -# we want to not pollute the libpath with our files until after we've done the version check -require_relative '../files/lib/chef_upstream_version' - -# on any chef client later than the one we were based off of we just turn into a no-op -if Gem::Requirement.new("< #{ChefCompat::CHEF_UPSTREAM_VERSION}").satisfied_by?(Gem::Version.new(Chef::VERSION)) - Chef::Log.debug "loading compat_resource based on chef-version #{ChefCompat::CHEF_UPSTREAM_VERSION} over chef version #{Gem::Version.new(Chef::VERSION)}" - $LOAD_PATH.unshift(File.expand_path("../files/lib", File.dirname(__FILE__))) - require 'compat_resource' -else - Chef::Log.debug "NOT LOADING compat_resource based on chef-version #{ChefCompat::CHEF_UPSTREAM_VERSION} over chef version #{Gem::Version.new(Chef::VERSION)}" - unless defined?(ChefCompat::Resource) && defined?(ChefCompat::Mixin::Properties) - module ChefCompat - Resource = Chef::Resource - module Mixin - Properties = Chef::Mixin::Properties - end - end - end -end diff --git a/vendor-cookbooks/compat_resource/metadata.json b/vendor-cookbooks/compat_resource/metadata.json deleted file mode 100644 index 1df2f5d5..00000000 --- a/vendor-cookbooks/compat_resource/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"compat_resource","version":"12.19.0","description":"Backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards","long_description":"# compat_resource cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/compat_resource.svg?branch=master)](https://travis-ci.org/chef-cookbooks/compat_resource) [![Cookbook Version](https://img.shields.io/cookbook/v/compat_resource.svg)](https://supermarket.chef.io/cookbooks/compat_resource)\n\nThis cookbook backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards. This includes [Custom Resource](https://docs.chef.io/custom_resources.html) functionality, notification improvements, as well as new resources added to core chef. It allows for the usage of these new resources in cookbooks without requiring the very latest Chef client release.\n\n## Backported functionality\n\n- [Custom Resources](https://docs.chef.io/custom_resources.html)\n- [apt_repository](https://docs.chef.io/resource_apt_repository.html)\n- [apt_update](https://docs.chef.io/resource_apt_update.html)\n- [systemd_unit](https://docs.chef.io/resource_systemd_unit.html)\n- [yum_repository](https://docs.chef.io/resource_yum_repository.html)\n- [:before notifications](https://docs.chef.io/resources.html#timers)\n\n## Requirements\n\n### Platforms\n\n- All platforms supported by Chef\n\n### Chef\n\n- Chef 12.1+\n\n### Cookbooks\n\n- none\n\n## Usage\n\nTo use this cookbook, put `depends 'compat_resource'` in the metadata.rb of your cookbook. Once this is done, you can use all the new custom resource features to define resources. It Just Works.\n\n## Custom Resources?\n\nCurious about how to use custom resources?\n\n- Docs: \n- Slides: \n\n## License & Authors\n\n- Author:: Lamont Granquist ([lamont@chef.io](mailto:lamont@chef.io))\n- Author:: John Keiser ([jkeiser@chef.io](mailto:jkeiser@chef.io))\n\n```text\nCopyright:: 2015-2016 Chef Software, Inc.\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":"Lamont Granquist","maintainer_email":"lamont@chef.io","license":"Apache 2.0","platforms":{},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/compat_resource","issues_url":"https://github.com/chef-cookbooks/compat_resource/issues","chef_version":[[">= 12.1"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/docker/CHANGELOG.md b/vendor-cookbooks/docker/CHANGELOG.md deleted file mode 100644 index ba322c18..00000000 --- a/vendor-cookbooks/docker/CHANGELOG.md +++ /dev/null @@ -1,1643 +0,0 @@ -# Docker Cookbook Changelog - -This file is used to list changes made in each version of the docker cookbook. - -## 2.13.10 (2017-01-13) -- #800 - fixing ubuntu startup script -- #802 - using chef_version methong only in 12.6.0 and higher - -## 2.13.9 (2016-12-29) -- 793 - Removing service restarts due to chef-client behavior changes. - -## 2.13.8 (2016-12-28) -- #794 - network mode bridge -- removing emacs package in upstart provider -- Adding dokken / travis test matrix - -## 2.13.7 (2016-12-24) -- adding additional logging drivers -- adding action :reload - -## 2.13.6 (2016-12-22) -- adding ip_address support for docker_containers -- adding volume_driver support - -## 2.13.5 (2016-12-21) -- Temporary work around for broke upstart provider in chef-client -- Fixing package name for ubuntu version later than 1.12.3 - -## 2.13.4 (2016-12-20) -- Fixing comparison operator docker daemon args for versions < 1.12 - -## 2.13.3 (2016-12-20) -- 792 - Reverting 791 fix - -## 2.13.2 (2016-12-20) -- 791 - Fix logic bug in docker_service daemon args calculation - -## 2.13.1 (2016-12-19) -- #786 - Adding options hash to docker_volume connection -- #787 - Adding wait loop to docker_service_manager_execute :stop - -## 2.13.0 (2016-11-25) -- Adding sysctl property to docker_container resource - -## 2.12.0 (2016-11-25) -- Updating compat_resource dep to 12.16.2 -- Updating docker-api gem dep 1.32.1 - -## 2.11.1 (2016-11-24) -- Fix for #701 - Revert commit that caused restart loops in systemd provider - -## 2.11.0 (2016-11-23) -- make systemd MountFlags configurable -- make running wait time configurable - -## 2.10.0 (2016-11-23) -- Implement network connect/disconnect -- Fixed dns options mutual exclusion -- Misc test harness cleanup - -## 2.9.10 (2016-11-14) --renaming systemd_conf to systemd_args due to a conflict with systemd cookbook - -## 2.9.9 (2016-11-14) --Fixing resource idempotence in labels property --Fix regression introduced by #741, breaking Debian installation --Added ro_rootfs => ReadonlyRootfs special cases mapping --Enable systemd options as a docker_service attribute - -## 2.9.8 (2016-11-08) -- Fixed a typo in an error message -- Enable tarball install through docker_service -- option log_opt is defined as --log-opt value1 --log-opt value2 instead of --log-opt=value1 --log-opt=value2 -- Depend on a working compat_resource cookbook - -## 2.9.7 (2016-10-14) -- Require the most recent compat_resource -- Get foodcritic passing -- Update the Rakefile and use cookstyle -- Use cookstyle in Travis -- Add matchers for docker_installation_tarball - -## v2.9.6 -- entrypoint not entry_point README -- dockerd binary on 1.12+ for upstart -- fix docker.socket for systemd - -## v2.9.5 -- bumping docker-api gem - -## v2.9.4 -- Switch to the dockerd binary on 1.12+ -- Add links to resources overview list - -## v2.9.3 -- add uts_mode support for docker_container provider (#730) - -## v2.9.2 -- adding feature ReadonlyRootfs -- bumping docker version to 1.11.2 -- removing etcd, fails tests for xenial and swarm will have it builtin in 1.12 - -## v2.9.1 -- implement userns_mode for containers - -## v2.9.0 -- Feature - docker_installation_tarball resource -- Patch - Adding missing http_proxy support to rhel/sysvinit -- Patch #705 - Avoid installing docker-api gem in ChefSpec - -## v2.8.0 -- Feature - User namespace configuration capability for docker_service - -## v2.7.1 - -- Updated test matrix in the readme to reflect reality - -## v2.7.0 - -- Initial support for Ubuntu 16.04 -- Initial support for Fedora 22 / 23 - -## v2.6.8 - -- notifies need to restart service immediately to prevent containers from stopping -- bumping docker-api version 1.28.0 -- adding tests for image load - -## v2.6.7 - -- only wait for running state if detached -- updating systemd template and bugfix for socket - -## v2.6.6 - -- refactor of docker-wait-ready - -## v2.6.5 - -- need a guard around docker_socket incase it isn't set - -## v2.6.4 - -- passing parsed socket file to init script -- removing unused action remove_link - -## v2.6.3 - -- Implements load action for images - -## v2.6.2 - -- Include init support for oracle platform - -## v2.6.1 - -- Add support for docker_container image property with custom repository port -- Resolve restarting container races -- New resource docker_exec - -## v2.6.0 - -- :insecure_registry in the docker_service provider can now be a string or array -- scientific and oracle have been added to the metadata as supported platforms -- The effect of -1 on memory_swap has been clarified in the readme -- Tests have been updated to run faster using trap vs. nc -- Checksums for new Docker releases have been added - -## v2.5.9 - -- Depend on compat_resource >= 12.9.0 - -## v2.5.8 - -- Setting desired_state: true for volumes / binds properties -- Now redeploy container on volume change. -- Change :restart action behavior to :run containers if they don't exist yet. - -## v2.5.7 - -- Remove vendored gems in favor of chef_gem install -- Extending available log_driver options - -## v2.5.6 - -- Adding no_proxy to Upstart defaults template - -## v2.5.5 - -- Fixing up various default: nil warnings - -## v2.5.4 - -- Allowing nil as type possibility for docker_service :package_options -- property - -## v2.5.3 - -- Adding ChefSpec.define_matcher for all resources - -## v2.5.2 - -- Setting log_driver and log_opts to desired_state: false - -## v2.5.1 - -- package_options property to pass options to underlying package resource - -## v2.5.0 - -- Defaulting installation version to 1.10.0 -- Documenting docker_network resource in README -- Documenting docker_volume resource in README - -## v2.4.26 - -- Adding docker_volume resource - -## v2.4.25 - -- Various fixes to docker_network around subsequent runs -- Utilizing property coersion and converge_if_changed - -## v2.4.24 - -- Avoiding restart loops in chef-client 12.4.3 -- Using delayed notifications for service restarts - -## v2.4.23 - -- Getting rid of Chef 13 deprecation warning -- returning nil in default_tls_cert_path - -## v2.4.22 - -- Revamped systemd resources to use package native unit files -- Using /etc/systemd/system to override settings - -## v2.4.21 - -- Revamped sysvinit resources to use package native scripts.a -- Using /etc/sysconfig on rhel and /etc/default on Debian -- Ubuntu 12.04 now uses Upstart -- Debian Wheezy support -- Fixed install_method validation - -## v2.4.20 - -- Temporarily disabling validate_install_method - -## v2.4.19 - -- Adding docker_tag force property - -## v2.4.18 - -- Fixing broken version / install_method validation check - -## v2.4.17 - -- Re-doing service_manager_upstart implementation -- Using package native init config and utilizing /etc/default - -## v2.4.16 - -- Adding validation proc for docker_service.version to throw error -- when specifying version with script installations - -## v2.4.15 - -- fixing raiseure -> failure typo in docker_container validation -- Patching vendored docker-api-1.26.0 -- - -## v2.4.14 - -- Updating .gitignore and re-adding vendored docker-api gem - -## v2.4.13 - -- stricter conditionals on container validation -- updating vendored docker-api gem to 1.26.0 -- setting default Docker installation version to 1.9.1 -- updating inspec for service-execute -- updating inspec for service-sysvinit -- updating inspec for service-upstart -- updating inspec for service-systemd -- removing unused serverspec suites - -## v2.4.12 - -- Set default docker_container.exposed_port to empty Hash - -## v2.4.11 - -- Updating metadata to use compat_resource ~> 12.7.1 - -## v2.4.10 - -- (re)adding host property to docker_network - -## v2.4.9 - -- using require_relative to load files -- specifying resource_name instead of use_automatic_resource_name - -## v2.4.8 - -- removing duplicate :tls properties -- removing instances of 'default: nil' -- depending on 'compat_resource', '~> 12.5.26' - -## v2.4.7 - -- Using Gem::Version to handle semantic verisoning and be compatible for ≥ 1.10 -- v2.4.6 - --------------------------------------------------------------------------------- - -- 613 - Fix docker_container redeploys with bad link array ordering - -## v2.4.5 - -- Fix coerce_volumes in case current value is a Chef::Node::ImmutableArray -- Adding tests for binds alias to volumes - -## v2.4.4 - -- Updating vendored docker-api to 1.25.0 -- Adding experimental docker_network resource - -## v2.4.3 - -- Setting docker_container property defaults to match Docker CLI -- Reverting image-id hack -- Adding disable-legacy-registry - -## v2.4.2 - -- Unifying volumes and binds properties on docker_container resource -- Should use "volumes" everywhere now. Aliased method for backward compatibility. - -## v2.4.1 - -- Various fixes in wait-ready loops: -- 598 - systemd manager return value check for docker-wait-ready -- 600 - execute manager last iteration check fix. - -## v2.4.0 - -- Adding support for pid_mode and ipc_mode to docker_container - -## v2.3.23 - -- Changing bridge property validation to String - -## v2.3.22 - -- using parsed_hostname to force nil value to Docker API when -- network_mode is host - -## v2.3.21 - -- reverting hostname coerce - -## v2.3.20 - -- adding coerce_hostname -- Fixing github issues #542 and #572 - -## v2.3.19 - -switching systemd unit MountFlags from slave to private - -## v2.3.18 - -- removing detach/autoremove conflict check - -## v2.3.17 - -- Reverting gem loading trickery. Reverting to LOAD_PATH.push - -## v2.3.16 - -- Adding validation checking for detach / autoremove property -- conflicts - -## v2.3.15 - -- Loading vendored gems the same way chef_gem would. -- Resolving Chef provisioning conflicts - -## v2.3.14 - -- Supporting Upstart for Linux Mint - -## v2.3.13 - -- Updating compat_resource dep to >=12.5.23 - -## v2.3.12 - -- Pinning compat_resource version to 12.5.14 to avoid warning - -## v2.3.11 - -- Using LOAD_PATH.push instead of LOAD_PATH.unshift for vendored gems - -## v2.3.10 - -- Fix method name for pidfile in docker_service_manager_execute - -## v2.3.9 - -- Adding Linux Mint to helpers_installation_package - -## v2.3.8 - -- 582 using symbols in excon opts -- Resolves 458 - -## v2.3.7 - -- 574 - updating docker to 1.9.1 -- 575 - remove nil values from container create hash -- 576 - updating centos to 7.1 -- 577 - check for conflicting properties -- 578 - Update docker_container library documentation on timeouts -- 579 - suggest adding kill_after on a failed action stop - -## v2.3.6 - -- 573 adding support for port range - -## v2.3.5 - -- fixing desired_state on docker_container force property - -## v2.3.4 - -- Fixing up ports logic -- Supporting multiple ip/ports - -## v2.3.3 - -- vendoring docker-api-1.24.1 - -## v2.3.2 - -- vendoring docker-api-1.24.0 -- setting desired_state:false for tls properties - -## v2.3.1 - -- Support for multiple docker_service instances with docker_service_manager_upstart -- Support for multiple docker_service instances with docker_service_manager_systemd - -## v2.3.0 - -- Support for multiple docker_service instances with docker_service_manager_sysvinit - -## v2.2.11 - -- Support for multiple docker_service instances with docker_service_manager_execute - -## v2.2.10 - -- 565 - Add support for --exec-opt to docker daemon -- 566 - Rename cluster-opts to cluster-opt - -## v2.2.9 - -- 560 - Add cluster-store options to docker daemon - -## v2.2.8 - -- 559 - setting tls and tls_verify should to nil by default - -## v2.2.7 - -- Supporting Docker ENV variables without explicitly setting -- per-resource host TLS information -- Serverspec -> inspec fixes - -## v2.2.6 - -- Docker 1.9 support -- Updates to pull_image id checking -- Updates default_network_mode calculation - -## v2.2.5 - -- Updating metadata to depend on compat_resource >= 12.5.14 - -## v2.2.4 - -- More minor fixes to Upstart script template - -## v2.2.3 - -- Minor fix to Upstart script template - -## v2.2.2 - -- Upstart script now waits for all filesystems instead of just local-filesystems - -## v2.2.1 - -- marking attach_ properties desired_state: false - -## v2.2.0 - -- Switching docker_installation method to auto -- Cleaning up some old Chef::Provider namespace cruft - -## v2.1.23 - -- Adding docker_service auto_restart property. Defaulting to false. - -## v2.1.22 - -- Updating README with docker_installation and docker_service_manager resources -- Adding "desired_state: false" to docker_installation properties - -## v2.1.21 - -- Refactoring docker_service into docker_service_manager_whatever -- Fixing bug in coerce_daemon_labels -- Fixes to resources-171 suite serverspec - -## v2.1.20 - -- Fixing docker_installation_script resource - -## v2.1.19 - -- Various cruft cleanup in service templates. -- Explicitly enabling ipv4 forwarding in execute provider -- docker_service_sysvinit test suite -- docker_service_upstart test suite -- docker_service_systemd test suite - -## v2.1.18 - -- Kitchen refactoring -- docker_service_execute bug fixes - -## v2.1.17 - -- Fixing merge meant for v2.1.16 - -## v2.1.16 - -- Adding install_method property to select docker_installation resource -- Using docker_installation_binary by default -- Fixing up serverspec for pre-182 resource test recipes - -## v2.1.15 - -- Updates to README around kill_after property on :stop action -- Updates to various test containers to handle SIGKILL properly - -## v2.1.14 - -- Fixing missing property regression in docker_service - -## v2.1.13 - -- Fixing up independent of docker_installation_binary resource, adding -- kitchen suites and serverspec tests - -## v2.1.12 - -- 531 - Bugfix for invalid parameters in docker_container :stop -- action - -## v2.1.11 - -- Fixing LocalJumpError in docker_container - -## v2.1.10 - -- Adding 'desired_state: false' to various timeouts - -## v2.1.9 - -- Refactoring: Moving remote file installation method into -- docker_installation_binary resource - -## v2.1.8 - -- Refactoring: Removing classes from the Chef::Resource namespace - -## v2.1.7 - -- Fixing connection information in docker_container and helpers_base -- Refactoring .kitchen.yml tests - -## v2.1.6 - -- Enabling TLS options for docker_container and docker_image -- Various test fixes - -## v2.1.5 - -- 528 - Don't enable https connection scheme if not using TLS - -## v2.1.4 - -- 517 - Disallowing nil value for Docker command - -## v2.1.3 - -- 514 - Fixing coerce and comparison logic in exposed_ports and -- volumes to prevent unwanted restarts - -## v2.1.2 - -- Adding why_run support - -## v2.1.1 - -- 511 - fix container wait state checking -- 512 - wait for registry ports to be open in test recipe -- 519 - updating README to include labels#511 - fix container - -## v2.1.0 - -- Changing docker_container default action to :run from -- :run_if_missing. - -## v2.0.4 - -- 504 - stop and start should wait for the container to complete -- 506 - restart to use the api endpoint - -## v2.0.3 - -- Allowing nil for docker_registry properties - -## v2.0.2 - -- Fixing LocalJumpError caused by next instead of return helper methods - -## v2.0.1 - -- 491 - Return best host for docker to connect -- 495 - iptables opts shouldn't be forced to true/false -- 497 - Removing property_is_set so timeout pick up defaults - -## v2.0.0 - -- Converted resources from LWRP to Chef 12.5 Custom Resources -- Added dependency on compat_resource cookbook, works back to 12.0.0 -- Various fixes around sysvinit scripts in docker_service -- Total backwards compatibility with recipes written for chef-docker 1.x - -## v1.0.49 - -- Handling NilClass error on docker_image default creds handling - -## v1.0.48 - -- Adding a 20 try timeout to the docker_wait_ready block - -## v1.0.47 - -- 484 - Fall back to creds for index.docker.io on image pull - -## v1.0.46 - -- 438 - Adding per-resource host property to docker_image and -- docker_container - -## v1.0.45 - -- Allow :redeploy on missing containers -- TLS fixes -- Updating sysvinit script to use docker_opts - -## v1.0.44 - -- Adding Label support for docker_container - -## v1.0.43 - -- Switching docker_service sysvinit provider from ::Insserv to ::Debian - -## v1.0.42 - -- Fix for docker_service to allow setting icc to false -- Get chefspec happy on latest nightly chefdk again -- Accepting both String and Array for default_ulimit - -## v1.0.41 - -- Refactoring broken sysvinit scripts -- 421 - Adding docker-wait-ready blocks -- Discovered TLS verification is broken. Disabling for now. - -## v1.0.40 - -- Fixing broken Chef::Provider::DockerService::Execute - -## v1.0.39 - -- Various fixes around sysvinit - -## v1.0.38 - -- docker_container - enabling Docker CLI syntax for ulimits - -## v1.0.37 - -- Adding tests for #416 - -## v1.0.36 - -- Replacing docker_log helper function with docker_service.logfile - -## v1.0.35 - -- Creating DockerHelpers::Service namespace and moving appropriate methods into it. -- Start of load_current_resource implementation for docker_service for #423 - -## v1.0.34 - -- notifying new_resource to restart when updating docker_bin - -## v1.0.33 - -- Registry authentication fixes and slight docker_image refactor -- Updates for foodcritic and travis - -## v1.0.32 - -- 451 Changed default docker_container memory_swap to prevent unwanted redeploys. - -## v1.0.31 - -- 447 - Fix for log-config driver type -- 448 - Fix unwanted redeploys due to calculation of exposed_port changes. -- 450 - Treat docker_container volumes attribute as unmanaged to prevent redeploys - -## v1.0.30 - -- 427 - Qualify port bindings with protocol even when implicitly tcp. -- 443 - Added docker_container log_driver and log_opts attributes. -- Changing docker_image read_timeout default to 60 -- Misc cleanup for README and Gemfile - -## v1.0.29 - -- 432 Fixing :redeploy so it returns the container the correct state -- (create vs run) -- Fixing blank variable interpolation in tmpfiles.d/docker.conf - -## v1.0.28 - -- Adding journald gelf and fluentd to logging driver whitelist -- Allow specifying multiple DNS servers for docker_service - -## v1.0.27 - -- Cleaning up code duplication across docker_service init templates - -## v1.0.26 - -- switching from get.docker.io to get.docker.com - -## v1.0.25 - -- Updating checksum in specs for 1.8.2 -- Downloading over https -- Removing nonexistent action :enable from docker_service - -## v1.0.24 - -- 410 - Fixing Dockerfile override behavior for hostname and ulimits -- on api 1.9 -- Upgrading to Docker 1.8.2 for default version - -## v1.0.23 - -- Fixing Dockerfile / resource override behavior for working_dir - -## v1.0.22 - -- Removed patch authentication header to bundled docker-api gem -- Moved credential reset logic into image provider - -## v1.0.21 - -- 379 and #356 - patching vendored docker-api gem authentication headers - -## v1.0.20 - -- Handling the situation where USER COMMAND ENV and ENTRYPOINT are set in -- an image build, but not in a docker_container resource - -## v1.0.19 - -- Raising error on authentication error in docker_registry -- Allowing an array for storage_opts in docker_service -- Fixing parsed_checksum in docker_service -- Fixing entrypoint parsing in docker_container - -## v1.0.18 - -- Removing leftover log resources used for debugging in development - -## v1.0.17 - -- Fixing up regressions in older Docker API versions introduced in cookbook release 1.0.15 -- _ Adding @api_version instance variable -- Adding serialized_log_config -- Adding parsed_network_mode - -## v1.0.16 - -- Adding CIDR support for docker_service bip property - -## v1.0.15 - -- 309 - Adding bits to enable container re-deployment when properties change - -## v1.0.14 - -- Adding api read and write timeouts - -## v1.0.13 - -- Fixing docker_service CLI argument generation for log-driver mtu and pidfile - -## v1.0.12 - -- Fixing platform_family string (redhat -> rhel) in docker_service sysvinit provider - -## v1.0.11 - -- Renaming retries to api_retries to not conflict with Chef::Resource - -## v1.0.10 - -- Accepting userland-proxy flag -- Fix bug in parsed_storage_driver method -- Correcting usage of ip_forwarding flag -- Let Docker pick --log-level instead of defaulting to :info - -## v1.0.9 - -- Fixing Upstart respawn limit - -## v1.0.8 - -- 382 - Fixing docker_service to accept an array for storage_opt - -## v1.0.7 - -- 381 - Removing prepended whitespace in DOCKER_OPTS - -## v1.0.6 - -- 369 - Fixing up HostConfig.NetworkMode to work as expected - -## v1.0.5 - -- 241 - Only updating docker_image resource on :pull if new bits were pulled -- on tag (useful for latest) -- Changing docker_image default action to :pull - -## v1.0.4 - -- 368 - Fixing port property to be kind_of [String, Array] -- Adding missing detach property. Defaulting to false. - -## v1.0.3 - -- 366 - Using docker_kernel instead of docker_arch in parsed_checksum - -## v1.0.2 - -- 365 - Fix logic for parsing an array of hosts -- 363 - Allow an array for port property - -## v1.0.1 - -- Switching docker_service default TLS setting to false to it works -- out of the box - -## v1.0.0 - -- vendoring the docker-api rubygem -- docker_image and docker_container resources now use speak to the -- Docker Remote API instead of shelling out -- docker_containers must now have unique names -- "volumes" property now acts like the VOLUMES directive in a Dockerfile -- added "binds" property for local mounting -- standardizing on "repo" and "tag" as components of an image -- identifier - -## v0.43.0 (2015-07-28) - -- Updating README to reflect docker_image and docker_tag reality -- Implementing rm, noprune, nocache and force on docker_image - -## v0.42.0 (2015-07-28) - -- removing docker_image :load and :tag action -- adding docker_tag resource -- renaming docker_tag image_name property to :repo; creating alias -- implementing docker_image :push action - -## v0.41.0 (2015-07-26) - -- vendoring docker-api rubygem -- beginning work to convert docker_image to use native API instead of shelling out -- changing docker_image default action to :pull_if_missing -- removing some deprecated interfaces - -## v0.40.3 (2015-07-14) - -- remove --no-trunc from docker container status in sysvinit script -- 334 - docker_container tag property (issue 320) -- 331 - docker_container ulimit property -- 328 - Upstart job respawn status detection -- 326 - Upstart job restart behavior fix sysvinit script examples -- 236 - README#324 - Reference DOCKER_OPTS Amazon Linux#325 - -## v0.40.2 (2015-07-14) - -- Support for older Chef versions - -## v0.40.1 (2015-07-08) - -- Changing host property to kind_of Array - -## v0.40.0 (2015-06-29) - -Important changes with this release: - -- MAJOR INTERFACE CHANGE -- Recipes replaced with docker_service resource* -- Removing a ton of dependencies -- Storage backends, kernel module loading, etc should now be handled externally -- Updating for Docker 1.6.2 -- Preferring binary install method to OS packages - -IMPORTANT - -- attributes/ will be removed in the next release. -- most are currently non-functional -- All options will be driven through resource properties - -## v0.37.0 - -Please note some important changes with this release: - -- The sysconfig DOCKER_OPTS improvement in [#250] can potentially change the behavior of that environment variable as it now allows shell interpolation of any embedded variables. This should not affect most environments. If your DOCKER_OPTS does contains any expected `$`, please escape via `\$` for previous behavior or be sure it will behave as expected before upgrading. -- The daemon restart option (which is deprecated) has been defaulted to `nil` instead of `false` when `node['docker']['container_init_type']` is set to prevent issues with container restart policies. If you're dependent on the daemon option, please be sure to update your `node['docker']['restart']` appropriately. -- This release also defaults systemd docker host to `fd://` to match upstream, enabling socket activation properly. Adjust `node['docker']['host']` if necessary. -- Bugfix: [#239]: Upstart: install inotify tools only once (avoid CHEF-3694 warning) (thanks jperville) -- Bugfix: [#240]: Fixed dead service containers not being restarted on docker_container :run (thanks jperville) -- Bugfix: [#244]: Made docker_container action :remove remove the actual upstart service file (thanks jperville) -- Bugfix: [#246]: Lengthen shell_out timeout as workaround for slow docker_container action stop (thanks jperville) -- Bugfix: [#258]: Fix checking docker container status on debian (thanks fxposter) -- Bugfix: [#260]: Fix accidental port changing when using systemd templates (thanks fxposter) -- Bugfix: [#266]: Get tests working on master (thanks tduffield) -- Bugfix: [#267]: Replace outdated testcontainerd (thanks tduffield) -- Bugfix: [#269]: Fix tests on Travis by following Rubocop style guidelines (container LWRP) (thanks fxposter) -- Bugfix: [#280] / [#281]: Fix port handling when omitted in container LWRP (thanks databus23) -- Bugfix: [#284] / [#285]: runit finish script to stop a container (thanks xmik) -- Bugfix: [#288][]: Fix docker.socket unit for RHEL7 (thanks databus23) -- Bugfix: [#292]: readme formatting fix (thanks wormzer) -- Improvement: [#208]: Add CentOS/RHEL 7 support (thanks dermusikman and intoximeters) -- Improvement: [#232]: Added support for insecure-registry docker daemon option (thanks jperville) -- Improvement: [#233] / [#234]: Added support for registry-mirror docker daemon option (thanks jperville and tarnfeld) -- Improvement: [#237]: Deprecate the restart daemon option (thanks jperville) -- Improvement: [#238]: Added docker_container restart attribute (thanks jperville) -- Improvement: [#242]: Added docker_container action :create (thanks jperville) -- Improvement: [#245]: Add a Gitter chat badge to README.md (thanks tduffield) -- Improvement: [#250]: Use double-quotes for DOCKER_OPTS (thanks rchekaluk) -- Improvement: [#259]: Use registry on image inspection (thanks fxposter) -- Improvement: [#263]: Add additional_host attribute to container resource (thanks fxposter) -- Improvement: [#264] / [#265]: Access keyserver.ubuntu.com on port 80 (thanks sauraus) -- Improvement: [#268]: Updated the /etc/init/docker.conf template (thanks jperville) -- Improvement: [#276]: Added support for docker options device and cap-add (thanks hvolkmer) -- Improvement: [#279]: Allow docker_container memory to have String value (eg. memory='1G') (thanks jperville) -- Improvement: [#287]: redhat 7 does not need the epel repository (thanks databus23) -- Improvement: [#289]: Update systemd service/socket files (from upstream) (thanks databus23) -- Improvement: [#296]: Default systemd to fd:// as well as use upstream MountFlags=slave and LimitCORE=infinity -- Improvement: [#297]: Update docker daemon SysV init scripts with upstream improvements -- Improvement: [#298]: Further deprecate daemon restart flag by default, which interferes with restart policies - -# 0.36.0 - -- Bugfix: [#181]: Fixed remove_link action (thanks jperville). -- Bugfix: [#185]: Fix for non idempotent run action on docker_container (thanks bplunkert). -- Bugfix: [#188]: Applied temporary workaround to address the libcgmanager error to users running LXC on Ubuntu 14.04. -- Bugfix: [#196]: Address Helpers module naming conflict (thanks sethrosenblum). -- Bugfix: [#200]: Fix how service actions are handled by docker_container resource (thanks brianhartsock). -- Bugfix: [#202]: Correctly check for the kernel.release version on Debian (thanks Tritlo, paweloczadly). -- Bugfix: [#203]: Fix pull notifications for tagged images (thanks hobofan). -- Bugfix: [#205]: Fix current_resource.name assignments in docker_container provider (thanks jperville). -- Bugfix: [#206]: Fixes to container name detection (thanks jperville). -- Enhancement: [#217]: Explicitly set key and keyserver for docker apt repository (thanks sethrosenblum). -- Improvement: Pull in init script changes from upstream for sysv and systemd. -- Bugfix: [#219]: Explicitly set Upstart provider for Ubuntu 14.04 and 14.10 (thanks methodx). -- Improvement: [#220]: Create graph directory if it is specified (thanks jontg). -- Bugfix: [#224]: Fix runit container template to properly use exec (thanks waisbrot). -- Bugfix: Appropriately check for LXC when using the binary recipe on Fedora. -- Bugfix: Implement workaround for docker/docker#2702 on Ubuntu 14.10. -- Enhancement: [#221]: Added NO_PROXY support (thanks jperville). -- Various Test Suite Modifications - - - Enhancement: [#192]: Allow image tags in serverspec matching (thanks bplunkert). - - Bugfix: [#223]: Convert a few occurrences of old 'should' rspec syntax to 'expect' (thanks jperville). - - Disable a few platforms that are experiencing bugs unrelated to core functionality. - - Address ChefSpec 4.1 deprecation warnings. - - Update Berksfile to reference supermarket.getchef.com instead of api.berkshelf.com - -# 0.35.2 - -- Bugfix: [#171]: Default Ubuntu 14.04 to Docker PPA -- Bugfix: [#175]: Do not set --selinux-enabled in opts unless explicitly defined for older versions -- Bugfix: [#176]: Use docker host attribute in docker_container Upstart inotifywait - -# 0.35.1 - -- Bugfix: [#172]: Generate no cidfile by default, even when deploying as service -- Bugfix: [#173]: Updated docker upstart script (should fix service docker restart) - -# 0.35.0 - -After a long personal hiatus (sorry!), this is the last minor release before 1.0 of the cookbook. If you can handle the Docker port number change and don't use anything deprecated, upgrading to 1.0.X from 0.35.X of the cookbook should be very easy. - -This release has a bunch of changes and hasn't been fully tested yet. Wanted to get it out there for broad testing. Please use caution! - -Major kudos to @tduffield for the [#147] PR, which includes: - -- Binary Installation - - - Added missing dependency resolution for using the binary. - -- Dependency Checks - - - Added `docker::dep_check` that will take an action if certain dependencies are not met. - - - `node[docker][alert_on_error_action] = :fatal` will kill the chef run and print the error message. - - `node[docker][alert_on_error_action] = :warn` will print the error message but continue with the chef run. There is no guarantee that it will succeed though. - -- KitchenCI - - - Copied MiniTests to ServerSpec Tests - - Added new platforms (Debian 7.4) - - Changed provisioner from chef-solo to chef-zero - - Removed Ubuntu 12.10 because it is not supported by Docker and the Kernel is bad and fails all the tests. - - Removed tests for the source recipe. The dotcloud/docker repo actually doesn't build any Go deliverables. - - - I think that the source recipe needs to be completely refactored. - -Other awesome work merged: - -- [#142]: Bugfix: Redeploy breaks when a link is present -- [#139]/[#153]/[#154]/[#156]/[#157]: Bugfix: container/image ID given as nil, fixes deprecated -notrunc -- [#164]: Bugfix: Removing a container should also remove its cidfile -- [#166]: Bugfix: Fix docker_inspect_id for Docker 1.0+ -- [#158]/[#160]/[#165]: Bugfix: Fix NameError when displaying error messages for timed-out commands -- [#169]: Bugfix: Specify Upstart as service provider for cgroup on Ubuntu 14.04 (workaround for CHEF-5276, fixed in Chef 11.14) -- [#137]/[#138]: Enhancement: Experimental Ubuntu 14.04 LTS support -- [#144]: Enhancement: Experimental Amazon linux support -- [#150]/[#152]: Enhancement: Add net attribute, deprecate networking -- [#168]: Enhancement: Allow override of package name -- [#161]: Enhancement: Add minitest case for SysV service -- [#149]: Enhancement: Add --selinux-enabled daemon flag -- Enhancement: container LWRP remove_link and remove_volume actions -- Enhancement: Add storage-opt daemon flag -- Enhancement: Add Docker 0.11.0, 0.11.1, 0.12.0, 1.0.0, 1.0.1 binary checksums - -# 0.34.2 - -- [#141]: Bugfix/Enhancement: Fix and enhance docker_image pull/push behavior with Docker 0.10 - - - Removes deprecated --registry and --tag CLI args from docker_image pull - - Adds support for registry attribute usage in docker_image pull and push - - Adds support for tag attribute usage in docker_image push - -# 0.34.1 - -- [#134]: Bugfix: Fix docker_registry login handling, fixes #114 - -# 0.34.0 - -Attributes now available for all docker daemon flags as well as system IP forwarding. - -- REMOVED: container_dns_ attributes (use replacement dns_ attributes on daemon for all containers or docker_container dns* attributes instead) -- DEPRECATED: bind_* attributes to match docker terminology (use host attribute instead) -- Bugfix: [#132]: Do Not Explicitly Set storage_driver Attribute -- Bugfix: [#133]: Remove explicit false defaults in resources -- Bugfix: [#114]: Error executing action login on resource docker_registry -- Enhancement: [#115]: Add IP forwarding attributes -- Enhancement: [#116]: Docker 0.10.0: Add --no-prune to docker rmi -- Enhancement: [#117]: Docker 0.10.0: Add --output flag to docker save (as well as tag support) -- Enhancement: [#118]: Docker 0.10.0: Add --input flag to docker load -- Enhancement: [#119]: Docker 0.10.0: Add support for --env-file to load environment variables from files -- Enhancement: [#120]: Docker 0.10.0: Deprecate docker insert -- Enhancement: [#123]: Add docker kill --signal -- Enhancement: [#124]: Add all docker daemon options as attributes -- Enhancement: [#125]: Use dns* attributes to set docker daemon options, not defaults per-container -- Enhancement: [#128]: Add checksum attribute for binary downloads -- Enhancement: [#126]: Set long option names for specified docker daemon options -- Enhancement: [#127]: Use a helper function to specify single line docker daemon options - -# 0.33.1 - -- Bugfix: [#112]: Defines runner methods for ChefSpec matchers -- Bugfix: [#113]: [D-15] Fedora 19 installs Docker 0.8.1, does not have the -G or -e flag - -# 0.33.0 - -This release deprecates AUFS/device-mapper handling from chef-docker, but provides backwards compatibility by still including the default recipe of the new cookbooks. Please update your dependencies, Github watching/issues, and recipes to reflect the two new community cookbooks: - -- aufs: [aufs on community site](http://community.opscode.com/cookbooks/aufs) / [chef-aufs on Github](https://github.com/bflad/chef-aufs) -- device-mapper: [device-mapper on community site](http://community.opscode.com/cookbooks/device-mapper) / [chef-device-mapper on Github](https://github.com/bflad/chef-device-mapper) -- Bugfix: [#109]: Remove on lxc-net start from docker Upstart -- Enhancement: [#88]: Migrate AUFS logic to separate cookbook -- Enhancement: [#90]: Migrate device-mapper logic to separate cookbook -- Enhancement: [#110]: Add docker Upstart pre-start script and limits configuration -- Enhancement: [#105]: Add --label for docker run -- Enhancement: [#106]: Add --opt for docker run -- Enhancement: [#107]: Add --networking for docker run -- Enhancement: [#108]: Add --dns-search for docker run -- Enhancement: [#104]: Add TMPDIR -- Enhancement: [#111]: Add DOCKER_LOGFILE configuration -- Enhancement: container_dns* attributes to set --dns and --dns-search for all containers - -# 0.32.2 - -- Bugfix: [#101]: Explicitly install lxc on Ubuntu (when lxc is exec_driver; continue to fully support LXC as a default installation path since its been since Docker 0.1) -- Bugfix: [#103]: Fix host argument (in docker run) - -# 0.32.1 - -- Bugfix: [#98]: Ensure Ruby 1.8 syntax is supported -- Bugfix: Skip empty Array values in cli_args helper - -# 0.32.0 - -_If you're using CentOS/RHEL with EPEL, upcoming docker-io 0.9.0 package upgrade can be tracked at [Bugzilla 1074880](https://bugzilla.redhat.com/show_bug.cgi?id=1074880)_ - -This release includes Docker 0.9.0 changes and defaults, such as setting exec_driver to libcontainer ("native"), setting -rm on docker build, double dash arguments on the CLI, additional flags, etc. - -- DEPRECATED: Rename storage_type attribute to storage_driver to [match Docker terminology](http://docs.docker.io/en/latest/reference/commandline/cli/#daemon) (storage_type will be removed in chef-docker 1.0) -- DEPRECATED: Rename virtualization_type attribute to exec_driver to [match Docker terminology](http://docs.docker.io/en/latest/reference/commandline/cli/#daemon) (virtualization_type will be removed in chef-docker 1.0) -- Bugfix: [#80]: Use double dashed arguments on CLI -- Bugfix: Surround String values on CLI with quotes -- Enhancement: [#77]: Improved docker ps handling -- Enhancement: [#78]: Docker 0.9.0: Make --rm the default for docker build -- Enhancement: [#81]: Docker 0.9.0: Add a -G option to specify the group which unix sockets belong -- Enhancement: [#82]: Docker 0.9.0: Add -f flag to docker rm to force removal of running containers -- Enhancement: Add -f flag for docker rmi to force removal of images -- Enhancement: [#83]: Docker 0.9.0: Add DOCKER_RAMDISK environment variable to make Docker work when the root is on a ramdisk -- Enhancement: [#84]: Docker 0.9.0: Add -e flag for execution driver -- Enhancement: [#85]: Docker 0.9.0: Default to libcontainer -- Enhancement: [#86]: Add Chefspec LWRP matchers - -# 0.31.0 - -Lots of init love this release. Now supporting runit. - -Please note change of storage_type attribute from devmapper to devicemapper (and associated recipe name change) to match docker's name for the driver. - -Cookbook now automatically adds -s option to init configurations if storage_type is defined, which is it by default. If you were specifying -s in the options attribute, you no longer need to do so. In my quick testing, docker daemon doesn't seem to mind if -s is specified twice on startup, although you'll probably want to get rid of the extra specification. - -I've also dropped the LANG= and LC_ALL= locale environment settings from the Upstart job configuration. Its not specified in the default docker job. Please open an issue in docker project and here if for some reason this is actually necessary. - -- Bugfix: Match devicemapper storage_type attribute to match docker driver name (along with recipe name) -- Enhancement: [#72]: Add initial runit init_type -- Enhancement: [#60]: Automatically set docker -d -s from storage_type attribute -- Enhancement: Simplify default/sysconfig file into one template (docker.sysconfig.erb) and source into SysV/Upstart init configurations -- Enhancement: Add Debian docker daemon SysV init template - -# 0.30.2 - -- Bugfix: [#68]: Fix CommandTimeout handling in LWRPs -- Bugfix: [#67]: Fix argument order to pull when tag specified - -# 0.30.1 - -Public or private registry login should now correctly occur and login once per credentials change. - -- Bugfix: [#64]: Correct CLI ordering of registry login -- Bugfix: [#65]: login command skipped in registry provider -- Enhancement: registry provider current resource attributes loaded from .dockercfg - -# 0.30.0 - -Awesome work by [@jcrobak] to close out two issues ([#49] and [#52]) with [#62]. Note change below in image build action. - -- Bugfix: [#52]: return codes of docker commands not verified -- Bugfix: Add missing pull_if_missing action to image resource -- Enhancement: [#56]: Switch build action to build_if_missing, build action now builds each run (be careful with image growth!) -- Enhancement: [#59]: Add Mac OS X installation support -- Enhancement: [#49]: Add docker_cmd_timeout attribute and daemon verification -- Enhancement: [#58]: Add container redeploy action -- Enhancement: [#63]: Add group_members attribute and group recipe to manage docker group - -# 0.29.0 - -- Enhancement: [#57]: Implement id checking when determining current_resource - - - Added to both container and image LWRPs - -- Enhancement: Set created and status attributes for current container resources (for handlers, wrappers, etc.) - -- Enhancement: Set created and virtual_size attributes for image resource (for handlers, wrappers, etc.) - -# 0.28.0 - -- Enhancement: [#55]: image LWRP pull action now attempts pull every run (use pull_if_missing action for old behavior) - -# 0.27.1 - -- Bugfix: [#51]: container LWRP current_resource attribute matching should also depend on container_name - -# 0.27.0 - -- Enhancement: [#48]: Accept FalseClass CLI arguments (also explicitly declare =true for TrueClass CLI arguments) - -# 0.26.0 - -- Bugfix: Add SysV init script for binary installs -- Enhancement: Add storage_type and virtualization_type attributes -- Enhancement: Initial devmapper support for binary installs on CentOS/Ubuntu -- Enhancement: [#47] Debian-specific container SysV init script -- Enhancement: [#46] Add rm attribute for build action on image LWRP -- Enhancement: Add no_cache attribute for build action on image LWRP - -# 0.25.1 - -- Bugfix: [#44] Add missing run attribute for commit action on container LWRP - -# 0.25.0 - -- DEPRECATED: image LWRP dockerfile, image_url, and path attributes (replaced with source attribute) -- Bugfix: Use docker_cmd for container LWRP remove and restart actions -- Enhancement: Add registry LWRP with login action -- Enhancement: Standardize on "smart" and reusable destination and source attributes for container and image LWRPs to define paths/URLs for various operations -- Enhancement: Add commit, cp, export, and kill actions to container LWRP -- Enhancement: Add insert, load, push, save, and tag actions to image LWRP -- Enhancement: Add local file and directory support to import action of image LWRP -- Enhancement: Add Array support to container LWRP link attribute -- Enhancement: Cleaned up LWRP documentation - -# 0.24.2 - -- Bugfix: [#43] Better formatting for container LWRP debug logging - -# 0.24.1 - -- Bugfix: Explicitly declare depends and supports in metadata -- Bugfix: Handle container run action if container exists but isn't running - -# 0.24.0 - -- Bugfix: [#42] fix(upstart): Install inotify-tools if using upstart -- Enhancement: [#38] Allow a user to specify a custom template for their container init configuration - -# 0.23.1 - -- Bugfix: [#39] Fix NoMethodError bugs in docker::aufs recipe - -# 0.23.0 - -- Bugfix: Default oracle init_type to sysv -- Enhancement: Experimental Debian 7 package support -- Enhancement: Use new yum-epel cookbook instead of yum::epel recipe -- Enhancement: Use `value_for_platform` where applicable in attributes, requires Chef 11 - -# 0.22.0 - -- Enhancement: [#35] Use kernel release for package name on saucy and newer -- Enhancement: [#37] dont include aufs recipe on ubuntu 13.10 and up; don't require docker::lxc for package installs - -# 0.21.0 - -- Enhancement: [#31] More helpful cmd_timeout error messages and catchable exceptions for container (`Chef::Provider::Docker::Container::CommandTimeout`) and image (`Chef::Provider::Docker::Image::CommandTimeout`) LWRPs - -# 0.20.0 - -- Enhancement: Default to package install_type only on distros with known packages -- Enhancement: Initial Oracle 6 platform support via binary install_type - - - - - - -- Enhancement: Split out lxc recipe for default platform lxc handling - -- Enhancement: Create cgroups recipe for default platform cgroups handling - -# 0.19.1 - -- Bugfix: [#30] apt-get throws exit code 100 when upgrading docker - -# 0.19.0 - -- Enhancement: Add `node['docker']['version']` attribute to handle version for all install_type (recommended you switch to this) -- Enhancement: `default['docker']['binary']['version']` attribute uses `node['docker']['version']` if set -- Enhancement: Add version handling to package recipe - -# 0.18.1 - -- Bugfix: Remove ExecStartPost from systemd service to match change in docker-io-0.7.0-13 - -# 0.18.0 - -- Enhancement: CentOS/RHEL 6 package support via EPEL repository -- Enhancement: Fedora 19/20 package support now in updates (stable) repository -- Enhancement: sysv recipe and init_type - -# 0.17.0 - -- Removed: configuration recipe (see bugfix below) -- Removed: config_dir attribute (see bugfix below) -- Bugfix: Revert back to specifying HTTP_PROXY and "DOCKER_OPTS" natively in systemd/Upstart (mostly to fix up systemd support) -- Bugfix: Add systemctl --system daemon-reload handling to systemd service template -- Bugfix: Add || true to container systemd/Upstart pre-start in case already running -- Bugfix: Locale environment already handled automatically by systemd -- Enhancement: Switch Fedora package installation from goldmann-docker to Fedora updates-testing repository -- Enhancement: Switch container LWRPs to named containers on Fedora since now supported -- Enhancement: Update docker systemd service contents from docker-io-0.7.0-12.fc20 - - - Add: Wants/After firewalld.service - - Add: ExecStartPost firewall-cmd - - Remove: ExecStartPost iptables commands - -# 0.16.0 - -- Bugfix: Remove protocol from docker systemd ListenStreams -- Bugfix: Lengthen shell_out timeout for stop action in container LWRP to workaround Fedora being slow -- Enhancement: Add service creation to container LWRP by default - - - Please thoroughly test before putting into production! - - `set['docker']['container_init_type'] = false` or add `init_type false` for the LWRP to disable this behavior - -- Enhancement: Add configuration recipe with template - -- Enhancement: Add container_cmd_timeout attribute to easily set global container LWRP cmd_timeout default - -- Enhancement: Add image_cmd_timeout attribute to easily set global image LWRP cmd_timeout default - -- Enhancement: Add cookbook attribute to container LWRP - -- Enhancement: Add init_type attribute to container LWRP - -- Enhancement: Add locale support for Fedora - -- Enhancement: Fail Chef run if `docker run` command errors - -# 0.15.0 - -- Enhancement: Fedora 19/20 package support via [Goldmann docker repo](http://goldmann.fedorapeople.org/repos/docker/) -- Enhancement: docker.service / docker.socket systemd support -- Enhancement: Add `node['docker']['init_type']` attribute for controlling init system - -# 0.14.0 - -- Bugfix: [#27] Only use command to determine running container if provided -- Bugfix: [#28] Upstart requires full stop and start of service instead of restart if job configuration changes while already running. Note even `initctl reload-configuration` isn't working as expected from -- Enhancement: [#26] Add ability to set package action - -# 0.13.0 - -- Bugfix: Move LWRP updated_on_last_action(true) calls so only triggered when something actually gets updated -- Enhancement: Add container LWRP wait action -- Enhancement: Add attach and stdin args to container LWRP start action -- Enhancement: Add link arg to container LWRP remove action -- Enhancement: Use cmd_timeout in container LWRP stop action arguments - -# 0.12.0 - -- Bugfix: Add default bind_uri (nil) to default attributes -- Enhancement: [#24] bind_socket attribute added - -# 0.11.0 - -- DEPRACATION: container LWRP Fixnum port attribute: use full String notation from Docker documentation in port attribute instead -- DEPRACATION: container LWRP public_port attribute: use port attribute instead -- Enhancement: Additional container LWRP attributes: - - - cidfile - - container_name - - cpu_shares - - dns - - expose - - link - - lxc_conf - - publish_exposed_ports - - remove_automatically - - volumes_from - -- Enhancement: Support Array in container LWRP attributes: - - - env - - port - - volume - -# 0.10.1 - -- Bugfix: Set default cmd_timeout in image LWRP to 300 instead of 60 because downloading images can take awhile -- Enhancement: Change docker_test Dockerfile FROM to already downloaded busybox image instead of ubuntu -- Enhancement: Add vagrant-cachier to Vagrantfile - -Other behind the scenes changes: - -- Made cookbook code Rubocop compliant -- Move licensing information to LICENSE file -- Updated .travis.yml and Gemfile - -# 0.10.0 - -- Enhancement: [#22] cmd_timeout, path (image LWRP), working_directory (container LWRP) LWRP attributes -- Bugfix: [#25] Install Go environment only when installing from source - -# 0.9.1 - -- Fix to upstart recipe to not restart service constantly (only on initial install and changes) - -# 0.9.0 - -- image LWRP now supports non-stdin build and import actions (thanks [@wingrunr21]!) - -# 0.8.1 - -- Fix in aufs recipe for FC048 Prefer Mixlib::ShellOut - -# 0.8.0 - -Lots of community contributions this release -- thanks! - -- image LWRP now supports builds via Dockerfile -- Additional privileged, public_port, and stdin parameters for container LWRP -- Support specifying binary version for installation -- Fix upstart configuration customization when installing via Apt packages -- Default to Golang 1.1 - -# 0.7.1 - -- Use HTTPS for Apt repository - -# 0.7.0 - -- Update APT repository information for Docker 0.6+ - -# 0.6.2 - -- Change Upstart config to start on runlevels [2345] instead of just 3 - -# 0.6.1 - -- Change env HTTP_PROXY to export HTTP_PROXY in Upstart configuration - -# 0.6.0 - -- Add bind_uri and options attributes - -# 0.5.0 - -- Add http_proxy attribute - -# 0.4.0 - -- Docker now provides precise/quantal/raring distributions for their PPA -- Tested Ubuntu 13.04 support - -# 0.3.0 - -- Initial `container` LWRP - -# 0.2.0 - -- Initial `image` LWRP - -# 0.1.0 - -- Initial release - -[#22]: https://github.com/bflad/chef-docker/issues/22 -[#24]: https://github.com/bflad/chef-docker/issues/24 -[#25]: https://github.com/bflad/chef-docker/issues/25 -[#26]: https://github.com/bflad/chef-docker/issues/26 -[#27]: https://github.com/bflad/chef-docker/issues/27 -[#28]: https://github.com/bflad/chef-docker/issues/28 -[#30]: https://github.com/bflad/chef-docker/issues/30 -[#31]: https://github.com/bflad/chef-docker/issues/31 -[#35]: https://github.com/bflad/chef-docker/issues/35 -[#37]: https://github.com/bflad/chef-docker/issues/37 -[#38]: https://github.com/bflad/chef-docker/issues/38 -[#39]: https://github.com/bflad/chef-docker/issues/39 -[#42]: https://github.com/bflad/chef-docker/issues/42 -[#43]: https://github.com/bflad/chef-docker/issues/43 -[#44]: https://github.com/bflad/chef-docker/issues/44 -[#46]: https://github.com/bflad/chef-docker/issues/46 -[#47]: https://github.com/bflad/chef-docker/issues/47 -[#48]: https://github.com/bflad/chef-docker/issues/48 -[#49]: https://github.com/bflad/chef-docker/issues/49 -[#51]: https://github.com/bflad/chef-docker/issues/51 -[#52]: https://github.com/bflad/chef-docker/issues/52 -[#55]: https://github.com/bflad/chef-docker/issues/55 -[#56]: https://github.com/bflad/chef-docker/issues/56 -[#57]: https://github.com/bflad/chef-docker/issues/57 -[#58]: https://github.com/bflad/chef-docker/issues/58 -[#59]: https://github.com/bflad/chef-docker/issues/59 -[#60]: https://github.com/bflad/chef-docker/issues/60 -[#62]: https://github.com/bflad/chef-docker/issues/62 -[#63]: https://github.com/bflad/chef-docker/issues/63 -[#64]: https://github.com/bflad/chef-docker/issues/64 -[#65]: https://github.com/bflad/chef-docker/issues/65 -[#67]: https://github.com/bflad/chef-docker/issues/67 -[#68]: https://github.com/bflad/chef-docker/issues/68 -[#72]: https://github.com/bflad/chef-docker/issues/72 -[#77]: https://github.com/bflad/chef-docker/issues/77 -[#78]: https://github.com/bflad/chef-docker/issues/78 -[#80]: https://github.com/bflad/chef-docker/issues/80 -[#81]: https://github.com/bflad/chef-docker/issues/81 -[#82]: https://github.com/bflad/chef-docker/issues/82 -[#83]: https://github.com/bflad/chef-docker/issues/83 -[#84]: https://github.com/bflad/chef-docker/issues/84 -[#85]: https://github.com/bflad/chef-docker/issues/85 -[#86]: https://github.com/bflad/chef-docker/issues/86 -[#88]: https://github.com/bflad/chef-docker/issues/88 -[#89]: https://github.com/bflad/chef-docker/issues/89 -[#90]: https://github.com/bflad/chef-docker/issues/90 -[#91]: https://github.com/bflad/chef-docker/issues/91 -[#98]: https://github.com/bflad/chef-docker/issues/98 -[#101]: https://github.com/bflad/chef-docker/issues/101 -[#103]: https://github.com/bflad/chef-docker/issues/103 -[#104]: https://github.com/bflad/chef-docker/issues/104 -[#105]: https://github.com/bflad/chef-docker/issues/105 -[#106]: https://github.com/bflad/chef-docker/issues/106 -[#107]: https://github.com/bflad/chef-docker/issues/107 -[#108]: https://github.com/bflad/chef-docker/issues/108 -[#109]: https://github.com/bflad/chef-docker/issues/109 -[#110]: https://github.com/bflad/chef-docker/issues/110 -[#111]: https://github.com/bflad/chef-docker/issues/111 -[#112]: https://github.com/bflad/chef-docker/issues/112 -[#113]: https://github.com/bflad/chef-docker/issues/113 -[#114]: https://github.com/bflad/chef-docker/issues/114 -[#115]: https://github.com/bflad/chef-docker/issues/115 -[#116]: https://github.com/bflad/chef-docker/issues/116 -[#117]: https://github.com/bflad/chef-docker/issues/117 -[#118]: https://github.com/bflad/chef-docker/issues/118 -[#119]: https://github.com/bflad/chef-docker/issues/119 -[#120]: https://github.com/bflad/chef-docker/issues/120 -[#123]: https://github.com/bflad/chef-docker/issues/123 -[#124]: https://github.com/bflad/chef-docker/issues/124 -[#125]: https://github.com/bflad/chef-docker/issues/125 -[#126]: https://github.com/bflad/chef-docker/issues/126 -[#127]: https://github.com/bflad/chef-docker/issues/127 -[#128]: https://github.com/bflad/chef-docker/issues/128 -[#132]: https://github.com/bflad/chef-docker/issues/132 -[#133]: https://github.com/bflad/chef-docker/issues/133 -[#134]: https://github.com/bflad/chef-docker/issues/134 -[#137]: https://github.com/bflad/chef-docker/issues/137 -[#138]: https://github.com/bflad/chef-docker/issues/138 -[#139]: https://github.com/bflad/chef-docker/issues/139 -[#141]: https://github.com/bflad/chef-docker/issues/141 -[#142]: https://github.com/bflad/chef-docker/issues/142 -[#144]: https://github.com/bflad/chef-docker/issues/144 -[#147]: https://github.com/bflad/chef-docker/issues/147 -[#149]: https://github.com/bflad/chef-docker/issues/149 -[#150]: https://github.com/bflad/chef-docker/issues/150 -[#152]: https://github.com/bflad/chef-docker/issues/152 -[#153]: https://github.com/bflad/chef-docker/issues/153 -[#154]: https://github.com/bflad/chef-docker/issues/154 -[#156]: https://github.com/bflad/chef-docker/issues/156 -[#157]: https://github.com/bflad/chef-docker/issues/157 -[#158]: https://github.com/bflad/chef-docker/issues/158 -[#160]: https://github.com/bflad/chef-docker/issues/160 -[#161]: https://github.com/bflad/chef-docker/issues/161 -[#164]: https://github.com/bflad/chef-docker/issues/164 -[#165]: https://github.com/bflad/chef-docker/issues/165 -[#166]: https://github.com/bflad/chef-docker/issues/166 -[#168]: https://github.com/bflad/chef-docker/issues/168 -[#169]: https://github.com/bflad/chef-docker/issues/169 -[#171]: https://github.com/bflad/chef-docker/issues/171 -[#172]: https://github.com/bflad/chef-docker/issues/172 -[#173]: https://github.com/bflad/chef-docker/issues/173 -[#175]: https://github.com/bflad/chef-docker/issues/175 -[#176]: https://github.com/bflad/chef-docker/issues/176 -[#181]: https://github.com/bflad/chef-docker/issues/181 -[#185]: https://github.com/bflad/chef-docker/issues/185 -[#188]: https://github.com/bflad/chef-docker/issues/188 -[#192]: https://github.com/bflad/chef-docker/issues/192 -[#196]: https://github.com/bflad/chef-docker/issues/196 -[#200]: https://github.com/bflad/chef-docker/issues/200 -[#202]: https://github.com/bflad/chef-docker/issues/202 -[#203]: https://github.com/bflad/chef-docker/issues/203 -[#205]: https://github.com/bflad/chef-docker/issues/205 -[#206]: https://github.com/bflad/chef-docker/issues/206 -[#208]: https://github.com/bflad/chef-docker/issues/208 -[#217]: https://github.com/bflad/chef-docker/issues/217 -[#219]: https://github.com/bflad/chef-docker/issues/219 -[#220]: https://github.com/bflad/chef-docker/issues/220 -[#221]: https://github.com/bflad/chef-docker/issues/221 -[#223]: https://github.com/bflad/chef-docker/issues/223 -[#224]: https://github.com/bflad/chef-docker/issues/224 -[#232]: https://github.com/bflad/chef-docker/issues/232 -[#233]: https://github.com/bflad/chef-docker/issues/233 -[#234]: https://github.com/bflad/chef-docker/issues/234 -[#237]: https://github.com/bflad/chef-docker/issues/237 -[#238]: https://github.com/bflad/chef-docker/issues/238 -[#239]: https://github.com/bflad/chef-docker/issues/239 -[#240]: https://github.com/bflad/chef-docker/issues/240 -[#242]: https://github.com/bflad/chef-docker/issues/242 -[#244]: https://github.com/bflad/chef-docker/issues/244 -[#245]: https://github.com/bflad/chef-docker/issues/245 -[#246]: https://github.com/bflad/chef-docker/issues/246 -[#250]: https://github.com/bflad/chef-docker/issues/250 -[#258]: https://github.com/bflad/chef-docker/issues/258 -[#259]: https://github.com/bflad/chef-docker/issues/259 -[#260]: https://github.com/bflad/chef-docker/issues/260 -[#263]: https://github.com/bflad/chef-docker/issues/263 -[#264]: https://github.com/bflad/chef-docker/issues/264 -[#265]: https://github.com/bflad/chef-docker/issues/265 -[#266]: https://github.com/bflad/chef-docker/issues/266 -[#267]: https://github.com/bflad/chef-docker/issues/267 -[#268]: https://github.com/bflad/chef-docker/issues/268 -[#269]: https://github.com/bflad/chef-docker/issues/269 -[#276]: https://github.com/bflad/chef-docker/issues/276 -[#279]: https://github.com/bflad/chef-docker/issues/279 -[#280]: https://github.com/bflad/chef-docker/issues/280 -[#281]: https://github.com/bflad/chef-docker/issues/281 -[#284]: https://github.com/bflad/chef-docker/issues/284 -[#285]: https://github.com/bflad/chef-docker/issues/285 -[#287]: https://github.com/bflad/chef-docker/issues/287 -[#289]: https://github.com/bflad/chef-docker/issues/289 -[#292]: https://github.com/bflad/chef-docker/issues/292 -[#296]: https://github.com/bflad/chef-docker/issues/296 -[#297]: https://github.com/bflad/chef-docker/issues/297 -[#298]: https://github.com/bflad/chef-docker/issues/298 -[@jcrobak]: https://github.com/jcrobak -[@wingrunr21]: https://github.com/wingrunr21 diff --git a/vendor-cookbooks/docker/CONTRIBUTING.md b/vendor-cookbooks/docker/CONTRIBUTING.md deleted file mode 100644 index ef2f2b80..00000000 --- a/vendor-cookbooks/docker/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/docker/MAINTAINERS.md b/vendor-cookbooks/docker/MAINTAINERS.md deleted file mode 100644 index a7645b90..00000000 --- a/vendor-cookbooks/docker/MAINTAINERS.md +++ /dev/null @@ -1,20 +0,0 @@ - - -# Maintainers - -This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead. - -# Project Maintainer -* [Sean OMeara](https://github.com/someara) - -# Maintainers -* [Jennifer Davis](https://github.com/sigje) -* [Sean OMeara](https://github.com/someara) -* [Tim Smith](https://github.com/tas50) -* [Thom May](https://github.com/thommay) -* [Anthony Scalisi](https://github.com/scalp42) -* [Chase Bolt](https://github.com/chasebolt) -* [Brian Flad](https://github.com/bflad) -* [Tom Duffield](https://github.com/tduffield) diff --git a/vendor-cookbooks/docker/README.md b/vendor-cookbooks/docker/README.md deleted file mode 100644 index 2fa48a04..00000000 --- a/vendor-cookbooks/docker/README.md +++ /dev/null @@ -1,1436 +0,0 @@ -# Docker Cookbook - -[![Build Status](https://travis-ci.org/chef-cookbooks/docker.svg?branch=master)](https://travis-ci.org/chef-cookbooks/docker) -[![Cookbook Version](https://img.shields.io/cookbook/v/docker.svg)](https://supermarket.chef.io/cookbooks/docker) -[![Gitter](https://badges.gitter.im/Join -Chat.svg)](https://gitter.im/someara/chef-docker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -The Docker Cookbook is a library cookbook that provides custom -resources for use in recipes. - -## Scope - -This cookbook is concerned with the [Docker](http://docker.io) -container engine as distributed by Docker, Inc. It does not address -Docker ecosystem tooling or prerequisite technology such as cgroups or -aufs. - - -## Requirements - -- Chef 12.5.x or higher. Chef 11 is NOT SUPPORTED, please do not open issues about it. -- Ruby 2.1 or higher (preferably, the Chef full-stack installer) -- Network accessible web server hosting the docker binary. -- SELinux permissive/disabled if CentOS [Docker Issue #15498](https://github.com/docker/docker/issues/15498) - -## Platform Support - -The following platforms have been tested with Test Kitchen: You may be -able to get it working on other platforms, with appropriate -configuration of cgroups and storage back ends. - -| | 1.7.1 | 1.8.3 | 1.9.1 | 1.10.3 | 1.11.1 | 1.12.3 | -|--------------|:-----:|:------|:-----:|:------:|:------:|:------:| -| debian-7 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| debian-8 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| centos-7 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| fedora | | | ✔ | ✔ | ✔ | ✔ | -| ubuntu-12.04 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| ubuntu-14.04 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| ubuntu-16.04 | | | | | ✔ | ✔ | - - -## Cookbook Dependencies - -- [compat_resource](https://supermarket.chef.io/cookbooks/compat_resource) - -## Usage - -- Add `depends 'docker', '~> 2.0'` to your cookbook's metadata.rb -- Use the resources shipped in cookbook in a recipe, the same way - you'd use core Chef resources (file, template, directory, package, - etc). - -```ruby -docker_service 'default' do - action [:create, :start] -end - -docker_image 'busybox' do - action :pull -end - -docker_container 'an-echo-server' do - repo 'busybox' - port '1234:1234' - command "nc -ll -p 1234 -e /bin/cat" -end -``` - -## Test Cookbooks as Examples - -The cookbooks ran under test-kitchen make excellent usage examples. - -The test recipes are found at: - -```ruby -test/cookbooks/docker_test/ -``` - -## Cgroups, Execution and Storage drivers - -Beginning in chef-docker 1.0, support for LXC execution driver has -been removed in favor of native. Cgroups and storage drivers are now -loosely coupled dependencies and should be configured using other -cookbooks if needed. - -Storage drivers can be selected with the `storage_driver` property on -the `docker_service` resource like this: - -```ruby -docker_service 'default' do - storage_driver 'zfs' -end -``` - -Configuration of the backing storage driver, including kernel module loading, is out of scope for this cookbook. - -## Resources Overview - -- [docker_service](#docker_service): composite resource that uses - docker_installation and docker_service_manager -- [docker_installation](#docker_installation): automatically select an - installation method -- [docker_service_manager](#docker_service_manager): automatically - selects a service manager -- [docker_installation_binary](#docker_installation_binary): copies a - pre-compiled docker binary onto disk -- [docker_installation_script](#docker_installation_script): curl | bash -- [docker_installation_package](#docker_installation_package): package - 'docker-engine' -- [docker_service_manager_execute](#docker_service_manager_execute): - manage docker daemon with Chef -- [docker_service_manager_sysvinit](#docker_service_manager_sysvinit): - manage docker daemon with a sysvinit script -- [docker_service_manager_upstart](#docker_service_manager_upstart): - manage docker daemon with upstart script -- [docker_service_manager_systemd](#docker_service_manager_systemd): - manage docker daemon with systemd unit files -- [docker_image](#docker_image): image/repository operations -- [docker_container](#docker_container): container operations -- [docker_tag](#docker_tag): image tagging operations -- [docker_registry](#docker_registry): registry operations -- [docker_network](#docker_network): network operations -- [docker_volume](#docker_volume): volume operations - -## Getting Started - -Here's a quick example of pulling the latest image and running a -container with exposed ports. - -```ruby -# Pull latest image -docker_image 'nginx' do - tag 'latest' - action :pull - notifies :redeploy, 'docker_container[my_nginx]' -end - -# Run container exposing ports -docker_container 'my_nginx' do - repo 'nginx' - tag 'latest' - port '80:80' - host_name 'www' - domain_name 'computers.biz' - env 'FOO=bar' - volumes [ '/some/local/files/:/etc/nginx/conf.d' ] -end -``` - -You might run a private registry and multiple Docker hosts. - -```ruby -# Login to private registry -docker_registry 'https://registry.computers.biz/' do - username 'shipper' - password 'iloveshipping' - email 'shipper@computers.biz' -end - -# Pull tagged image -docker_image 'registry.computers.biz:443/my_project/my_container' do - tag 'latest' - action :pull - host 'tcp://host-1.computers.biz:2376' -end - -# Run container -docker_container 'crowsnest' do - repo 'registry.computers.biz:443/my_project/my_container' - tag 'latest' - host 'tcp://host-2.computers.biz:2376' - tls_verify true - tls_ca_cert "/path/to/ca.pem" - tls_client_cert "/path/to/cert.pem" - tls_client_key "/path/to/key.pem" - action :run -end -``` - -You can manipulate Docker volumes and networks - -```ruby -docker_network 'my_network' do - subnet '10.9.8.0/24' - gateway '10.9.8.1' -end - -docker_volume 'my_volume' do - action :create -end - -docker_container 'my_container' do - repo 'alpine' - tag '3.1' - command "nc -ll -p 1234 -e /bin/cat" - volumes 'my_volume:/my_data' - network_mode 'my_network' - action :run -end -``` - -See full documentation for each resource and action below for more information. - -## Resources Details -## docker_installation - -The `docker_installation` resource auto-selects one of the below -resources with the provider resolution system. - -### Example - -```ruby -docker_installation 'default' do - repo 'test' - action :create -end -``` - -## docker_installation_binary - -The `docker_installation_binary` resource copies the precompiled Go -binary onto the disk. It exists to help run older Docker versions. It -should not be used in production, especially with devicemapper. - -### Example - -```ruby -docker_installation_binary 'default' do - version '1.8.2' - source 'https://my.computers.biz/dist/docker' - checksum '97a3f5924b0b831a310efa8bf0a4c91956cd6387c4a8667d27e2b2dd3da67e4d' - action :create -end -``` - -### Properties - -- `version` - The desired version of docker. Used to calculate source. -- `source` - Path to network accessible Docker binary. Ignores version -- `checksum` - SHA-256 - -## docker_installation_tarball - -The `docker_installation_tarball` resource copies the precompiled Go -binary tarball onto the disk. It exists to help run newer Docker -versions from 1.11.0 onwards. It should not be used in production, -especially with devicemapper. - -### Example - -```ruby -docker_installation_tarball 'default' do - version '1.11.0' - source 'https://my.computers.biz/dist/docker.tgz' - checksum '97a3f5924b0b831a310efa8bf0a4c91956cd6387c4a8667d27e2b2dd3da67e4d' - action :create -end -``` - -### Properties - -- `version` - The desired version of docker. Used to calculate source. -- `source` - Path to network accessible Docker binary tarball. Ignores - version -- `checksum` - SHA-256 - -## docker_installation_script - -The `docker_installation_script` resource runs the script hosted by -Docker, Inc at . It configures package -repositories and installs a dynamically compiled binary. - -### Example - -```ruby -docker_installation_script 'default' do - repo 'main' - script_url 'https://my.computers.biz/dist/scripts/docker.sh' - action :create -end -``` - -### Properties - -- `repo` - One of 'main', 'test', or 'experimental'. Used to calculate - script_url in its absense. Defaults to 'main' -- `script_url` - 'URL of script to pipe into /bin/sh as root. - -## docker_installation_package - -The `docker_installation_package` resource uses the system package -manager to install Docker. It relies on the pre-configuration of the -system's package repositories. The `chef-yum-docker` and -`chef-apt-docker` Supermarket cookbooks are used to do this in -test-kitchen. - -This is the recommended production installation method. - -### Example - -```ruby -docker_installation_package 'default' do - version '1.8.3' - action :create - package_options %q|--force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-all'| # if Ubuntu for example -end -``` - -### Properties - -- `version` - Used to calculate package_version string -- `package_version` - Manually specify the package version string -- `package_name` - Name of package to install. Defaults to - 'docker-engine' -- `package_options` - Manually specify additional options, like - apt-get directives for example - -## docker_service_manager - -The `docker_service_manager` resource auto-selects a strategy from the -`docker_service_manager_*` group of resources based on platform and -version. The `docker_service` family share a common set of properties. - -### Example - -```ruby -docker_service_manager 'default' do - action :start -end -``` - -## docker_service_manager_execute - -### Example - -```ruby -docker_service_manager_execute 'default' do - action :start -end -``` - -## docker_service_manager_sysvinit - -### Example - -```ruby -docker_service_manager_sysvinit 'default' do - host 'unix:///var/run/docker.sock' - action :stop -end -``` - -## docker_service_manager_upstart - -### Example - -```ruby -docker_service_manager_upstart 'default' do - host ['unix:///var/run/docker.sock', 'tcp://127.0.0.1:2376'] - action :start -end -``` - -## docker_service_manager_systemd - -### Example - -```ruby -docker_service_manager_systemd 'default' do - host ['unix:///var/run/docker.sock', 'tcp://127.0.0.1:2376'] - tls_verify true - tls_ca_cert "/path/to/ca.pem" - tls_server_cert "/path/to/server.pem" - tls_server_key "/path/to/server-key.pem" - tls_client_cert "/path/to/cert.pem" - tls_client_key "/path/to/key.pem" - systemd_opts ["TasksMax=infinity","MountFlags=private"] - action :start -end -``` - -## docker_service - -The `docker_service`: resource is a composite resource that uses -`docker_installation` and `docker_service_manager` resources. - -- The `:create` action uses a `docker_installation` -- The `:delete` action uses a `docker_installation` -- The `:start` action uses a `docker_service_manager` -- The `:stop` action uses a `docker_service_manager` - -The service management strategy for the host platform is dynamically -chosen based on platform, but can be overridden. - -### Example - -```ruby -docker_service 'tls_test:2376' do - host [ "tcp://#{node['ipaddress']}:2376", 'unix:///var/run/docker.sock' ] - tls_verify true - tls_ca_cert '/path/to/ca.pem' - tls_server_cert '/path/to/server.pem' - tls_server_key '/path/to/server-key.pem' - tls_client_cert '/path/to/client.pem' - tls_client_key '/path/to/client-key.pem' - action [:create, :start] -end -``` - -WARNING - When creating multiple `docker_service` resources on the -same machine, you will need to specify unique graph properties to -avoid unexpected behavior and possible data corruption. - -### Properties - -The `docker_service` resource property list mostly corresponds to the -options found in the -[Docker Command Line Reference](https://docs.docker.com/reference/commandline/cli/) - -- `source` - URL to the pre-compiled Docker binary used for - installation. Defaults to a calculated URL based on kernel version, - Docker version, and platform arch. By default, this will try to get - to "". -- `version` - Docker version to install -- `checksum` - sha256 checksum of Docker binary -- `instance` - Identity for `docker_service` resource. Defaults to - name. Mostly unimportant for the 1.0 version because of its - singleton status. | String | nil -- `api_cors_header` - Set CORS headers in the remote API -- `bridge` - Attach containers to a network bridge -- `bip` - Specify network bridge IP -- `debug` - Enable debug mode -- `cluster_store` - Cluster store to use -- `cluster_advertise` - IP and port that this daemon should advertise - to the cluster -- `cluster_store_opts` - Cluster store options -- `daemon` - Enable daemon mode -- `dns` - DNS server(s) to use -- `dns_search` - DNS search domains to use -- `exec_driver` - Exec driver to use -- `fixed_cidr` - IPv4 subnet for fixed IPs -- `fixed_cidr_v6` - IPv6 subnet for fixed IPs -- `group` - Posix group for the unix socket -- `graph` - Root of the Docker runtime - Effectively, the "data - directory" -- `host` - Daemon socket(s) to connect to - `tcp://host:port`, - `unix:///path/to/socket`, `fd://*` or `fd://socketfd` -- `icc` - Enable inter-container communication -- `insecure_registry` - Enable insecure registry communication -- `ip` - Default IP when binding container ports -- `ip_forward` - Enable ip forwarding -- `ipv4_forward` - Enable net.ipv4.ip_forward -- `ipv6_forward` - Enable net.ipv6.ip_forward -- `ip_masq` - Enable IP masquerading -- `iptables` - Enable addition of iptables rules -- `ipv6` - Enable IPv6 networking -- `log_level` - Set the logging level -<<<<<<< HEAD -- `labels` A string or array to set metadata on the daemon in the form - ['foo:bar', 'hello:world']` -- `log_driver` - Container's logging driver - (json-file/syslog/journald/gelf/fluentd/none) -======= -- `labels` A string or array to set metadata on the daemon in the form ['foo:bar', 'hello:world']` -- `log_driver` - Container's logging driver (json-file/syslog/journald/gelf/fluentd/awslogs/splunk/etwlogs/gcplogs/none) ->>>>>>> log_drivers -- `log_opts` - Container's logging driver options (driver-specific) -- `mtu` - Set the containers network MTU -- `pidfile` - Path to use for daemon PID file -- `registry_mirror` - Preferred Docker registry mirror -- `storage_driver` - Storage driver to use -- `selinux_enabled` - Enable selinux support -- `storage_opts` - Set storage driver options -- `tls` - Use TLS; implied by --tlsverify. Defaults to - ENV['DOCKER_TLS'] if set -- `tls_verify` - Use TLS and verify the remote. Defaults to - ENV['DOCKER_TLS_VERIFY'] if set -- `tls_ca_cert` - Trust certs signed only by this CA. Defaults to - ENV['DOCKER_CERT_PATH'] if set -- `tls_server_cert` - Path to TLS certificate file for docker service -- `tls_server_key` - Path to TLS key file for docker service -- `tls_client_cert` - Path to TLS certificate file for docker - cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_key` - Path to TLS key file for docker cli. Defaults to - ENV['DOCKER_CERT_PATH'] if set -- `default_ulimit` - Set default ulimit settings for containers -- `http_proxy` - ENV variable set before for Docker daemon starts -- `https_proxy` - ENV variable set before for Docker daemon starts -- `no_proxy` - ENV variable set before for Docker daemon starts -- `tmpdir` - ENV variable set before for Docker daemon starts -- `logfile` - Location of Docker daemon log file -- `userland_proxy`- Enables or disables docker-proxy -- `disable_legacy_registry` - Do not contact legacy registries -- `userns_remap` - Enable user namespace remapping options - - `default`, `uid`, `uid:gid`, `username`, `username:groupname` (see: - [Docker User Namespaces](see: - https://docs.docker.com/v1.10/engine/reference/commandline/daemon/#daemon-user-namespace-options)) -- `mount_flags` - Set the systemd mount propagation flag. Defaults to slave. - -#### Miscellaneous Options - -- `misc_opts` - Pass the docker daemon any other options bypassing - flag validation, supplied as `--flag=value` - -#### Systemd-specific Options - -- `systemd_opts` - An array of strings that will be included as - individual lines in the systemd service unit for Docker. *Note*: - This option is only relevant for systems where systemd is the - default service manager or where systemd is specified explicitly as - the service manager. - -### Actions - -- `:create` - Lays the Docker bits out on disk -- `:delete` - Removes the Docker bits from the disk -- `:start` - Makes sure the service provider is set up properly and start it -- `:stop` - Stops the service -- `:restart` - Restarts the service - -### `docker_service` implementations - -- `docker_service_execute` - The simplest docker_service. Just starts - a process. Fire and forget. -- `docker_service_sysvinit` - Uses a SystemV init script to manage the - service state. -- `docker_service_upstart` - Uses an Upstart script to manage the - service state. -- `docker_service_systemd` - Uses an Systemd unit file to manage the - service state. NOTE: This does NOT enable systemd socket activation. - -## docker_image - -The `docker_image` is responsible for managing Docker image pulls, -builds, and deletions. It speaks directly to the -[Docker remote API](https://docs.docker.com/reference/api/docker_remote_api_v1.20/). - -### Examples - -- default action, default properties - -```ruby -docker_image 'hello-world' -``` - -- non-default name attribute - -```ruby -docker_image "Tom's container" do - repo 'tduffield/testcontainerd' - action :pull -end -``` - -- pull every time - -```ruby -docker_image 'busybox' do - action :pull -end -``` - -- specify a tag - -```ruby -docker_image 'alpine' do - tag '3.1' -end -``` - -- specify read/write timeouts - -```ruby -docker_image 'alpine' do - read_timeout 60 - write_timeout 60 -end -``` - -```ruby -docker_image 'vbatts/slackware' do - action :remove -end -``` - -- save - -```ruby -docker_image 'save hello-world' do - repo 'hello-world' - destination '/tmp/hello-world.tar' - not_if { ::File.exist?('/tmp/hello-world.tar') } - action :save -end -``` - -- build from a Dockerfile on every chef-client run - -```ruby -docker_image 'image_1' do - tag 'v0.1.0' - source '/src/myproject/container1/Dockerfile' - action :build -end -``` - -- build from a directory, only if image is missing - -```ruby -docker_image 'image_2' do - tag 'v0.1.0' - source '/src/myproject/container2' - action :build_if_missing -end -``` - -- build from a tarball NOTE: this is not an "export" tarball generated - from an an image save. The contents should be a Dockerfile, and - anything it references to COPY or ADD - -```ruby -docker_image 'image_3' do - tag 'v0.1.0' - source '/tmp/image_3.tar' - action :build -end -``` - -```ruby -docker_image 'hello-again' do - tag 'v0.1.0' - source '/tmp/hello-world.tar' - action :import -end -``` - -- push - -```ruby -docker_image 'my.computers.biz:5043/someara/hello-again' do - action :push -end - ``` - -- Connect to an external docker daemon and pull an image - -```ruby -docker_image 'alpine' do - host 'tcp://127.0.0.1:2376' - tag '2.7' -end -``` - -### Properties - -The `docker_image` resource properties mostly corresponds to the -[Docker Remote API](https://docs.docker.com/reference/api/docker_remote_api_v1.20/#2-2-images) -as driven by the -[Swipley docker-api Ruby gem](https://github.com/swipely/docker-api) - - -A `docker_image`'s full identifier is a string in the form -"\:\". There is some nuance around naming using the -public - -registry vs a private one. - -- `repo` - aka `image_name` - The first half of a Docker image's - identity. This is a string in the form: - `registry:port/owner/image_name`. If the `registry:port` portion is - left off, Docker will implicitly use the Docker public - registry. "Official Images" omit the owner part. This means a repo - id can look as short as `busybox`, `alpine`, or `centos`, to refer - to official images on the public registry, and as long as - `my.computers.biz:5043/what/ever` to refer to custom images on an - private registry. Often you'll see something like `someara/chef` to - refer to private images on the public registry. - Defaults to - resource name. -- `tag` - The second half of a Docker image's identity. - Defaults to - `latest` -- `source` - Path to input for the `:import`, `:build` and - `:build_if_missing` actions. For building, this can be a Dockerfile, - a tarball containing a Dockerfile in its root, or a directory - containing a Dockerfile. For import, this should be a tarball - containing Docker formatted image, as generated with `:save`. -- `destination` - Path for output from the `:save` action. -- `force` - A force boolean used in various actions - Defaults to - false -- `nocache` - Used in `:build` operations. - Defaults to false -- `noprune` - Used in `:remove` operations - Defaults to false -- `rm` - Remove intermediate containers after a successful build - (default behavior) - Defaults to `true` -- `read_timeout` - May need to increase for long image builds/pulls -- `write_timeout` - May need to increase for long image builds/pulls -- `host` - A string containing the host the API should communicate - with. Defaults to ENV['DOCKER_HOST'] if set -- `tls` - Use TLS; implied by --tlsverify. Defaults to - ENV['DOCKER_TLS'] if set -- `tls_verify` - Use TLS and verify the remote. Defaults to - ENV['DOCKER_TLS_VERIFY'] if set -- `tls_ca_cert` - Trust certs signed only by this CA. Defaults to - ENV['DOCKER_CERT_PATH'] if set -- `tls_client_cert` - Path to TLS certificate file for docker - cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_key` - Path to TLS key file for docker cli. Defaults to - ENV['DOCKER_CERT_PATH'] if set - -### Actions - -The following actions are available for a `docker_image` -resource. Defaults to `pull_if_missing` - -- `:pull` - Pulls an image from the registry -- `:pull_if_missing` - Pulls an image from the registry, only if it missing -- `:build` - Builds an image from a Dockerfile, directory, or tarball -- `:build_if_missing` - Same build, but only if it is missing -- `:save` - Exports an image to a tarball at `destination` -- `:import` - Imports an image from a tarball at `destination` -- `:remove` - Removes (untags) an image -- `:push` - Pushes an image to the registry - -## docker_tag - -Docker tags work very much like hard links in a Unix filesystem. They -are just references to an existing image. Therefore, the docker_tag -resource has taken inspiration from the Chef `link` resource. - -### Examples - -```ruby -docker_tag 'private repo tag for hello-again:1.0.1' do - target_repo 'hello-again' - target_tag 'v0.1.0' - to_repo 'localhost:5043/someara/hello-again' - to_tag 'latest' - action :tag -end -``` - -### Properties - -- `target_repo` - The repo half of the source image identifier. -- `target_tag` - The tag half of the source image identifier. -- `to_repo` - The repo half of the new image identifier -- `to_tag`- The tag half of the new image identifier - -### Actions - -- `:tag` - Tags the image - -## docker_container - -The `docker_container` is responsible for managing Docker container -actions. It speaks directly to the -[Docker remote API](https://docs.docker.com/reference/api/docker_remote_api_v1.20/). - - -Containers are process oriented, and move through an event -cycle. Thanks to [Glider Labs](http://gliderlabs.com/) for this -excellent -diagram. ![alt tag](http://gliderlabs.com/images/docker_events.png) - - -### Examples - -- Create a container without starting it. - -```ruby -docker_container 'hello-world' do - command '/hello' - action :create -end -``` - -- This command will exit succesfully. This will happen on every chef-client run. - -```ruby -docker_container 'busybox_ls' do - repo 'busybox' - command 'ls -la /' - action :run -end -``` - -- The :run action contains both :create and :start the container in one action. Redeploys the container on resource change. It is the default action. - -```ruby -docker_container 'alpine_ls' do - repo 'alpine' - tag '3.1' - command 'ls -la /' - action :run -end -``` - -- Set environment variables in a container - -```ruby -docker_container 'env' do - repo 'debian' - env ['PATH=/usr/bin', 'FOO=bar'] - command 'env' - action :run -end -``` - -- This process remains running between chef-client runs, :run will do nothing on subsequent converges. - -```ruby -docker_container 'an_echo_server' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 7 -e /bin/cat' - port '7:7' - action :run -end -``` - -- Let docker pick the host port - -```ruby -docker_container 'another_echo_server' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 7 -e /bin/cat' - port '7' - action :run -end -``` - -- Specify the udp protocol - -```ruby -docker_container 'an_udp_echo_server' do - repo 'alpine' - tag '3.1' - command 'nc -ul -p 7 -e /bin/cat' - port '5007:7/udp' - action :run -end -``` - -- Kill a container - -```ruby -docker_container 'bill' do - action :kill -end -``` - -- Stop a container - -```ruby -docker_container 'hammer_time' do - action :stop -end -``` - -- Force-stop a container after 30 seconds - -```ruby -docker_container 'hammer_time' do - kill_after 30 - action :stop -end -``` - -- Pause a container - -```ruby -docker_container 'red_light' do - action :pause -end -``` - -- Unpause a container - -```ruby -docker_container 'green_light' do - action :unpause -end -``` - -- Restart a container - -```ruby -docker_container 'restarter' do - action :restart -end -``` - -- Delete a container - -```ruby -docker_container 'deleteme' do - remove_volumes true - action :delete -end -``` - -- Redeploy a container - -```ruby -docker_container 'redeployer' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 7777 -e /bin/cat' - port '7' - action :run -end - -execute 'redeploy redeployer' do - notifies :redeploy, 'docker_container[redeployer]', :immediately - action :run -end -``` - -- Bind mount local directories - -```ruby -docker_container 'bind_mounter' do - repo 'busybox' - command 'ls -la /bits /more-bits' - volumes ['/hostbits:/bits', '/more-hostbits:/more-bits'] - action :run_if_missing -end -``` - -- Mount volumes from another container - -```ruby -docker_container 'chef_container' do - command 'true' - volumes '/opt/chef' - action :create -end - -docker_container 'ohai_debian' do - command '/opt/chef/embedded/bin/ohai platform' - repo 'debian' - volumes_from 'chef_container' -end -``` - -- Set a container's entrypoint - -```ruby -docker_container 'ohai_again_debian' do - repo 'debian' - volumes_from 'chef_container' - entrypoint '/opt/chef/embedded/bin/ohai' - command 'platform' - action :run_if_missing -end -``` - -- Automatically remove a container after it exits - -```ruby -docker_container 'sean_was_here' do - command "touch /opt/chef/sean_was_here-#{Time.new.strftime('%Y%m%d%H%M')}" - repo 'debian' - volumes_from 'chef_container' - autoremove true - action :run -end -``` - -- Grant NET_ADMIN rights to a container - -```ruby -docker_container 'cap_add_net_admin' do - repo 'debian' - command 'bash -c "ip addr add 10.9.8.7/24 brd + dev eth0 label eth0:0 ; ip addr list"' - cap_add 'NET_ADMIN' - action :run_if_missing -end -``` - -- Revoke MKNOD rights to a container - -```ruby -docker_container 'cap_drop_mknod' do - repo 'debian' - command 'bash -c "mknod -m 444 /dev/urandom2 c 1 9 ; ls -la /dev/urandom2"' - cap_drop 'MKNOD' - action :run_if_missing -end -``` - -- Set a container's hostname and domainname - -```ruby -docker_container 'fqdn' do - repo 'debian' - command 'hostname -f' - host_name 'computers' - domain_name 'biz' - action :run_if_missing -end -``` - -- Set a container's DNS resolution - -```ruby -docker_container 'dns' do - repo 'debian' - command 'cat /etc/resolv.conf' - host_name 'computers' - dns ['4.3.2.1', '1.2.3.4'] - dns_search ['computers.biz', 'chef.io'] - action :run_if_missing -end -``` - -- Add extra hosts to a container's `/etc/hosts` - -```ruby -docker_container 'extra_hosts' do - repo 'debian' - command 'cat /etc/hosts' - extra_hosts ['east:4.3.2.1', 'west:1.2.3.4'] - action :run_if_missing -end -``` - -- Manage container's restart_policy - -```ruby -docker_container 'try_try_again' do - repo 'alpine' - tag '3.1' - command 'grep asdasdasd /etc/passwd' - restart_policy 'on-failure' - restart_maximum_retry_count 2 - action :run_if_missing -end - -docker_container 'reboot_survivor' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 123 -e /bin/cat' - port '123' - restart_policy 'always' - action :run_if_missing -end -``` - -- Manage container links - -```ruby -docker_container 'link_source' do - repo 'alpine' - tag '3.1' - env ['FOO=bar', 'BIZ=baz'] - command 'nc -ll -p 321 -e /bin/cat' - port '321' - action :run_if_missing -end - -docker_container 'link_target_1' do - repo 'alpine' - tag '3.1' - env ['ASD=asd'] - command 'ping -c 1 hello' - links ['link_source:hello'] - action :run_if_missing -end - -docker_container 'link_target_2' do - repo 'alpine' - tag '3.1' - command 'env' - links ['link_source:hello'] - action :run_if_missing -end - -execute 'redeploy_link_source' do - command 'touch /marker_container_redeploy_link_source' - creates '/marker_container_redeploy_link_source' - notifies :redeploy, 'docker_container[link_source]', :immediately - notifies :redeploy, 'docker_container[link_target_1]', :immediately - notifies :redeploy, 'docker_container[link_target_2]', :immediately - action :run -end -``` - -- Mutate a container between chef-client runs - -```ruby -docker_tag 'mutator_from_busybox' do - target_repo 'busybox' - target_tag 'latest' - to_repo 'someara/mutator' - target_tag 'latest' -end - -docker_container 'mutator' do - repo 'someara/mutator' - tag 'latest' - command "sh -c 'touch /mutator-`date +\"%Y-%m-%d_%H-%M-%S\"`'" - outfile '/mutator.tar' - force true - action :run_if_missing -end - -execute 'commit mutator' do - command 'true' - notifies :commit, 'docker_container[mutator]', :immediately - notifies :export, 'docker_container[mutator]', :immediately - notifies :redeploy, 'docker_container[mutator]', :immediately - action :run -end -``` - -- Specify read/write timeouts - -```ruby -docker_container 'api_timeouts' do - repo 'alpine' - read_timeout 60 - write_timeout 60 -end -``` - -- Specify a custom logging driver and its options - -```ruby -docker_container 'syslogger' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 780 -e /bin/cat' - log_driver 'syslog' - log_opts 'syslog-tag=container-syslogger' -end -``` - -- Connect to an external docker daemon and create a container - -```ruby -docker_container 'external_daemon' do - repo 'alpine' - host 'tcp://1.2.3.4:2376' - action :create -end -``` - -### Properties - -Most `docker_container` properties are the `snake_case` version of the `CamelCase` keys found in the [Docker Remote Api](https://docs.docker.com/reference/api/docker_remote_api_v1.20/) - -- `container_name` - The name of the container. Defaults to the name of the `docker_container` resource. -- `repo` - aka `image_name`. The first half of a the complete identifier for a Docker Image. -- `tag` - The second half of a Docker image's identity. - Defaults to `latest`. -- `command` - The command to run when starting the container. -- `autoremove` - Boolean - Automatically delete a container when it's command exits. Defaults to `false`. -- `volumes` - An array of volume bindings for this container. Each volume binding is a string in one of these forms: `container_path` to create a new volume for the container. `host_path:container_path` to bind-mount a host path into the container. `host_path:container_path:ro` to make the bind-mount read-only inside the container. -- `cap_add` - An array Linux Capabilities (`man 7 capabilities`) to add to grant the container beyond what it normally gets. -- `cap_drop` - An array Linux Capabilities (`man 7 capabilities`) to revoke that the container normally has. -- `cpu_shares` - An integer value containing the CPU Shares for the container. -- `devices` - A Hash of devices to add to the container. -- `dns` - An array of DNS servers the container will use for name resolution. -- `dns_search` - An array of domains the container will search for name resolution. -- `domain_name` - Set's the container's dnsdomainname as returned by the `dnsdomainname` command. -- `entrypoint` - Set the entry point for the container as a string or an array of strings. -- `env` - Set environment variables in the container in the form `['FOO=bar', 'BIZ=baz']` -- `extra_hosts` - An array of hosts to add to the container's `/etc/hosts` in the form `['host_a:10.9.8.7', 'host_b:10.9.8.6']` -- `force` - A boolean to use in container operations that support a `force` option. Defaults to `false` -- `host` - A string containing the host the API should communicate with. Defaults to ENV['DOCKER_HOST'] if set -- `host_name` - The hostname for the container. -- `labels` A string, array, or hash to set metadata on the container in the form ['foo:bar', 'hello:world']` -- `links` - An array of source container/alias pairs to link the container to in the form `[container_a:www', container_b:db']` -- `log_driver` - Sets a custom logging driver for the container (json-file/syslog/journald/gelf/fluentd/none). -- `log_opts` - Configures the above logging driver options (driver-specific). -- `ip_address` - Container IPv4 address (e.g. 172.30.100.104) -- `mac_address` - The mac address for the container to use. -- `memory` - Memory limit in bytes. -- `memory_swap` - Total memory limit (memory + swap); set `-1` to disable swap limit (unlimited). You must use this with memory and make the swap value larger than memory. -- `network_disabled` - Boolean to disable networking. Defaults to `false`. -- `network_mode` - Sets the networking mode for the container. One of `bridge`, `host`, `container`. -- `open_stdin` - Boolean value, opens stdin. Defaults to `false`. -- `outfile` - The path to write the file when using `:export` action. -- `port` - The port configuration to use in the container. Matches the syntax used by the `docker` CLI tool. -- `privileged` - Boolean to start the container in privileged more. Defaults to `false` -- `publish_all_ports` - Allocates a random host port for all of a container's exposed ports. -- `remove_volumes` - A boolean to clean up "dangling" volumes when removing the last container with a reference to it. Default to `false` to match the Docker CLI behavior. -- `restart_policy` - One of `no`, `on-failure`, `unless-stopped`, or `always`. Use `always` if you want a service container to survive a Dockerhost reboot. Defaults to `no`. -- `restart_maximum_retry_count` - Maximum number of restarts to try when `restart_policy` is `on-failure`. Defaults to an ever increasing delay (double the previous delay, starting at 100mS), to prevent flooding the server. -- `running_wait_time` - Amount of seconds `docker_container` wait to determine if a process is running.` -- `security_opts` - A list of string values to customize labels for MLS systems, such as SELinux. -- `signal` - The signal to send when using the `:kill` action. Defaults to `SIGTERM`. -- `sysctls` - A hash of sysctls to set on the container. Defaults to `{}`. -- `tty` - Boolean value to allocate a pseudo-TTY. Defaults to `false`. -- `user` - A string value specifying the user inside the container. -- `volumes` - An Array of paths inside the container to expose. Does the same thing as the `VOLUME` directive in a Dockerfile, but works on container creation. -- `volumes_from` - A list of volumes to inherit from another container. Specified in the form `[:]` -- `volume_driver` - Driver that this container users to mount volumes. -- `working_dir` - A string specifying the working directory for commands to run in. -- `read_timeout` - May need to increase for commits or exports that are slow -- `write_timeout` - May need to increase for commits or exports that are slow -- `kill_after` - Number of seconds to wait before killing the container. Defaults to wait indefinitely; eventually will hit read_timeout limit. -- `timeout` - Seconds to wait for an attached container to return -- `tls` - Use TLS; implied by --tlsverify. Defaults to ENV['DOCKER_TLS'] if set -- `tls_verify` - Use TLS and verify the remote. Defaults to ENV['DOCKER_TLS_VERIFY'] if set -- `tls_ca_cert` - Trust certs signed only by this CA. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_cert` - Path to TLS certificate file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_key` - Path to TLS key file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `userns_mode` - Modify the user namespace mode - Defaults to `nil`, example option: `host` -- `pid_mode` - Set the PID (Process) Namespace mode for the container. `host`: use the host's PID namespace inside the container. -- `ipc_mode` - Set the IPC mode for the container - Defaults to `nil`, example option: `host` -- `uts_mode` - Set the UTS namespace mode for the container. The UTS namespace is for setting the hostname and the domain that is visible to running processes in that namespace. By default, all containers, including those with `--network=host`, have their own UTS namespace. The host setting will result in the container using the same UTS namespace as the host. Note that --hostname is invalid in host UTS mode. -- `ro_rootfs` - Mount the container's root filesystem as read only. Defaults to `false` - -### Actions - -- `:create` - Creates the container but does not start it. Useful for Volume containers. -- `:start` - Starts the container. Useful for containers that run jobs.. command that exit. -- `:run` - The default action. Both `:create` and `:start` the container in one action. Redeploys the container on resource change. -- `:run_if_missing` - Runs a container only once. -- `:stop` - Stops the container. -- `:restart` - Stops the starts the container. -- `:kill` - Send a signal to the container process. Defaults to `SIGKILL`. -- `:pause` - Pauses the container. -- `:unpause` - Unpauses the container. -- `:delete` - Deletes the container. -- `:redeploy` - Deletes and runs the container. -- `:reload` - Sends SIGHUP to pid 1 in the container - -## docker_registry - -The `docker_registry` resource is responsible for managing the -connection auth information to a Docker registry. - -### docker_registry action :login - -- Log into or register with public registry: - -```ruby -docker_registry 'https://index.docker.io/v1/' do - username 'publicme' - password 'hope_this_is_in_encrypted_databag' - email 'publicme@computers.biz' -end -``` - -Log into private registry with optional port: - -```ruby -docker_registry 'my local registry' do - serveraddress 'https://registry.computers.biz:8443/' - username 'privateme' - password 'still_hope_this_is_in_encrypted_databag' - email 'privateme@computers.biz' -end -``` - -## docker_network - -The `docker_network` resource is responsible for managing Docker named -networks. Usage of `overlay` driver requires the `docker_service` to -be configured to use a distributed key/value store like `etcd`, -`consul`, or `zookeeper`. - -### docker_network action :create - -```ruby -docker_network 'my_network' do - subnet '192.168.88.0/24' - gateway '192.168.88.1' - action :create -end - -docker_container 'echo-base' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 1337 -e /bin/cat' - port '1337' - network_mode 'my_network' - action :run -end -``` - -### Properties - -- `driver` - The network driver to use. Defaults to `bridge`, other - options include `overlay`. -- `subnet` - Specify the subnet(s) for the network. Ex: - `192.168.0.0/16` -- `gateway` - Specify the gateway(s) for the network. Ex: - `192.168.0.1` -- `ip_range` - Specify a range of IPs to allocate for containers. Ex: - `192.168.1.0/24` -- `aux_address` - Auxillary addresses for the network. Ex: - `['a=192.168.1.5', 'b=192.168.1.6']` -- `container` - Container-id/name to be connected/disconnected to/from - the network. Used only by `:connect` and `:disconnect` actions - - -### Example - -```ruby -docker_network 'network_g' do - driver 'overlay' - subnet ['192.168.0.0/16', '192.170.0.0/16'] - gateway ['192.168.0.100', '192.170.0.100'] - ip_range '192.168.1.0/24' - aux_address ['a=192.168.1.5', 'b=192.168.1.6', 'a=192.170.1.5', 'b=192.170.1.6'] -end -``` - -Connect to multiple networks - -```ruby -docker_network 'network_h1' do - action :create -end - -docker_network 'network_h2' do - action :create -end - -docker_container 'echo-base-networks_h' do - repo 'alpine' - tag '3.1' - command 'nc -ll -p 1337 -e /bin/cat' - port '1337' - network_mode 'network_h1' - action :run -end - -docker_network 'network_h2' do - container 'echo-base-networks_h' - action :connect -end -``` - -### Actions - -- `:create` - create a network -- `:delete` - delete a network -- `:connect` - connect a container to a network -- `:disconnect` - disconnect a container from a network - -## docker_volume - -The `docker_volume` resource is responsible for managing Docker named -volumes. - -### docker_volume action :create - -```ruby -docker_volume 'hello' do - action :create -end - -docker_container 'file_writer' do - repo 'alpine' - tag '3.1' - volumes 'hello:/hello' - command 'touch /hello/sean_was_here' - action :run_if_missing -end -``` - -### Actions - -- `:create` - create a volume -- `:remove` - remove a volume - -## docker_execute - -The `docker_execute` resource allows you to execute commands inside of -a running container. - -### Examples - -```ruby -docker_exec 'touch_it' do - container 'busybox_exec' - command ['touch', '/tmp/onefile'] -end -``` - -### Properties - -- `host` - Daemon socket(s) to connect to - `tcp://host:port`, - `unix:///path/to/socket`, `fd://*` or `fd://socketfd`. -- `command` - A command structured as an Array similar to `CMD` in a - Dockerfile. -- `container` - Name of the container to execute the command in. -- `timeout`- Seconds to wait for an attached container to - return. Defaults to 60 seconds. - -### Actions - -- `:run` - Runs the command - -## Testing and Development - -- Full development and testing workflow with Test Kitchen and friends: - - - - -## Contributing - -Please see contributing information in: - - - - -## Maintainers - -- Sean OMeara ([sean@sean.io](mailto:sean@sean.io)) -- Brian Flad ([bflad417@gmail.com](mailto:bflad417@gmail.com)) -- Tom Duffield () -- Fletcher Nichol ([fnichol@nichol.ca](mailto:fnichol@nichol.ca)) -- Chase Bolt ([chase.bolt@gmail.com](mailto:chase.bolt@gmail.com)) - -## License - -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. diff --git a/vendor-cookbooks/docker/libraries/_autoload.rb b/vendor-cookbooks/docker/libraries/_autoload.rb deleted file mode 100644 index d072d9de..00000000 --- a/vendor-cookbooks/docker/libraries/_autoload.rb +++ /dev/null @@ -1,13 +0,0 @@ -begin - gem 'docker-api', '= 1.33.0' -rescue LoadError - unless defined?(ChefSpec) - run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) - - require 'chef/resource/chef_gem' - - docker = Chef::Resource::ChefGem.new('docker-api', run_context) - docker.version '= 1.33.0' - docker.run_action(:install) - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_base.rb b/vendor-cookbooks/docker/libraries/docker_base.rb deleted file mode 100644 index 6677d0b0..00000000 --- a/vendor-cookbooks/docker/libraries/docker_base.rb +++ /dev/null @@ -1,90 +0,0 @@ -module DockerCookbook - class DockerBase < ChefCompat::Resource - require_relative 'helpers_auth' - require_relative 'helpers_base' - - include DockerHelpers::Base - - ######### - # Classes - ######### - - class UnorderedArray < Array - def ==(other) - # If I (desired env) am a subset of the current env, let == return true - other.is_a?(Array) && all? { |val| other.include?(val) } - end - end - - class ShellCommandString < String - def ==(other) - other.is_a?(String) && Shellwords.shellwords(self) == Shellwords.shellwords(other) - end - end - - class PartialHash < Hash - def ==(other) - other.is_a?(Hash) && all? { |key, val| other.key?(key) && other[key] == val } - end - end - - ################ - # Type Constants - # - # These will be used when declaring resource property types in the - # docker_service, docker_container, and docker_image resource. - # - ################ - - ArrayType = property_type( - is: [Array, nil], - coerce: proc { |v| v.nil? ? nil : Array(v) } - ) unless defined?(ArrayType) - - Boolean = property_type( - is: [true, false], - default: false - ) unless defined?(Boolean) - - NonEmptyArray = property_type( - is: [Array, nil], - coerce: proc { |v| Array(v).empty? ? nil : Array(v) } - ) unless defined?(NonEmptyArray) - - ShellCommand = property_type( - is: [String], - coerce: proc { |v| coerce_shell_command(v) } - ) unless defined?(ShellCommand) - - UnorderedArrayType = property_type( - is: [UnorderedArray, nil], - coerce: proc { |v| v.nil? ? nil : UnorderedArray.new(Array(v)) } - ) unless defined?(UnorderedArrayType) - - PartialHashType = property_type( - is: [PartialHash, nil], - coerce: proc { |v| v.nil? ? nil : PartialHash[v] } - ) unless defined?(PartialHashType) - - ##################### - # Resource properties - ##################### - - property :api_retries, Integer, default: 3, desired_state: false - property :read_timeout, [Integer, nil], default: 60, desired_state: false - property :write_timeout, [Integer, nil], desired_state: false - property :running_wait_time, [Integer, nil], default: 20, desired_state: false - - property :tls, [Boolean, nil], default: lazy { default_tls }, desired_state: false - property :tls_verify, [Boolean, nil], default: lazy { default_tls_verify }, desired_state: false - property :tls_ca_cert, [String, nil], default: lazy { default_tls_cert_path('ca') }, desired_state: false - property :tls_server_cert, [String, nil], desired_state: false - property :tls_server_key, [String, nil], desired_state: false - property :tls_client_cert, [String, nil], default: lazy { default_tls_cert_path('cert') }, desired_state: false - property :tls_client_key, [String, nil], default: lazy { default_tls_cert_path('key') }, desired_state: false - - declare_action_class.class_eval do - include DockerHelpers::Authentication - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_container.rb b/vendor-cookbooks/docker/libraries/docker_container.rb deleted file mode 100644 index 1c357433..00000000 --- a/vendor-cookbooks/docker/libraries/docker_container.rb +++ /dev/null @@ -1,437 +0,0 @@ -module DockerCookbook - class DockerContainer < DockerBase - require 'docker' - require 'shellwords' - require_relative 'helpers_container' - - include DockerHelpers::Container - - resource_name :docker_container - - ########################################################### - # In Chef 12.5 and later, we no longer have to use separate - # classes for resource and providers. Instead, we have - # everything in a single class. - # - # For the purposes of my own sanity, I'm going to place all the - # "resource" related bits at the top of the files, and the - # providerish bits at the bottom. - # - # - # Methods for default values and coersion are found in - # helpers_container.rb - ########################################################### - - # ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ - # Begin classic Chef "resource" section - # ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ - - # The non-standard types Boolean, ArrayType, ShellCommand, etc - # are found in the DockerBase class. - property :container_name, String, name_property: true - property :repo, String, default: lazy { container_name } - property :tag, String, default: 'latest' - property :command, ShellCommand - property :attach_stderr, Boolean, default: false, desired_state: false - property :attach_stdin, Boolean, default: false, desired_state: false - property :attach_stdout, Boolean, default: false, desired_state: false - property :autoremove, Boolean, desired_state: false - property :cap_add, NonEmptyArray - property :cap_drop, NonEmptyArray - property :cgroup_parent, String, default: '' - property :cpu_shares, [Integer, nil], default: 0 - property :cpuset_cpus, String, default: '' - property :detach, Boolean, default: true, desired_state: false - property :devices, Array, default: [] - property :dns, Array, default: [] - property :dns_search, Array, default: [] - property :domain_name, String, default: '' - property :entrypoint, ShellCommand - property :env, UnorderedArrayType, default: [] - property :extra_hosts, NonEmptyArray - property :exposed_ports, PartialHashType, default: {} - property :force, Boolean, desired_state: false - property :host, [String, nil], default: lazy { default_host }, desired_state: false - property :hostname, String - property :ipc_mode, String, default: '' - property :labels, [String, Array, Hash], default: {}, coerce: proc { |v| coerce_labels(v) } - property :links, UnorderedArrayType, coerce: proc { |v| coerce_links(v) } - property :log_driver, %w( json-file syslog journald gelf fluentd awslogs splunk etwlogs gcplogs none ), default: 'json-file', desired_state: false - property :log_opts, [Hash, nil], coerce: proc { |v| coerce_log_opts(v) }, desired_state: false - property :ip_address, String - property :mac_address, String - property :memory, Integer, default: 0 - property :memory_swap, Integer, default: 0 - property :network_disabled, Boolean, default: false - property :network_mode, [String, NilClass], default: 'bridge' - property :open_stdin, Boolean, default: false, desired_state: false - property :outfile, [String, NilClass] - property :port_bindings, PartialHashType, default: {} - property :pid_mode, String, default: '' - property :privileged, Boolean, default: false - property :publish_all_ports, Boolean, default: false - property :remove_volumes, Boolean - property :restart_maximum_retry_count, Integer, default: 0 - property :restart_policy, String, default: 'no' - property :ro_rootfs, Boolean, default: false - property :security_opts, [String, ArrayType] - property :signal, String, default: 'SIGTERM' - property :stdin_once, Boolean, default: false, desired_state: false - property :sysctls, Hash, default: {} - property :timeout, [Integer, nil], desired_state: false - property :tty, Boolean, default: false - property :ulimits, [Array, nil], coerce: proc { |v| coerce_ulimits(v) } - property :user, String, default: '' - property :userns_mode, String, default: '' - property :uts_mode, String, default: '' - property :volumes, PartialHashType, default: {}, coerce: proc { |v| coerce_volumes(v) } - property :volumes_from, ArrayType - property :volume_driver, String - property :working_dir, [String, NilClass], default: '' - - # Used to store the bind property since binds is an alias to volumes - property :volumes_binds, Array - - # Used to store the state of the Docker container - property :container, Docker::Container, desired_state: false - - # Used by :stop action. If the container takes longer than this - # many seconds to stop, kill itinstead. -1 (the default) means - # never kill the container. - property :kill_after, Numeric, default: -1, desired_state: false - - alias cmd command - alias additional_host extra_hosts - alias rm autoremove - alias remove_automatically autoremove - alias host_name hostname - alias domainname domain_name - alias dnssearch dns_search - alias restart_maximum_retries restart_maximum_retry_count - alias volume volumes - alias binds volumes - alias volume_from volumes_from - alias destination outfile - alias workdir working_dir - - # ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ - # Begin classic Chef "provider" section - # ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ - - ######################################################## - # Load Current Value - ######################################################## - - load_current_value do - # Grab the container and assign the container property - begin - with_retries { container Docker::Container.get(container_name, {}, connection) } - rescue Docker::Error::NotFoundError - current_value_does_not_exist! - end - - # Go through everything in the container and set corresponding properties: - # c.info['Config']['ExposedPorts'] -> exposed_ports - (container.info['Config'].to_a + container.info['HostConfig'].to_a).each do |key, value| - next if value.nil? || key == 'RestartPolicy' || key == 'Binds' || key == 'ReadonlyRootfs' - - # Image => image - # Set exposed_ports = ExposedPorts (etc.) - property_name = to_snake_case(key) - public_send(property_name, value) if respond_to?(property_name) - end - - # load container specific labels (without engine/image ones) - load_container_labels - - # these are a special case for us because our names differ from theirs - restart_policy container.info['HostConfig']['RestartPolicy']['Name'] - restart_maximum_retry_count container.info['HostConfig']['RestartPolicy']['MaximumRetryCount'] - volumes_binds container.info['HostConfig']['Binds'] - ro_rootfs container.info['HostConfig']['ReadonlyRootfs'] - end - - ######### - # Actions - ######### - - # Super handy visual reference! - # http://gliderlabs.com/images/docker_events.png - - default_action :run - - declare_action_class.class_eval do - def whyrun_supported? - true - end - - def call_action(action) - send("action_#{action}") - load_current_resource - end - - def state - current_resource ? current_resource.state : {} - end - end - - # Loads container specific labels excluding those of engine or image. - # This insures idempotency. - def load_container_labels - image_labels = Docker::Image.get(container.info['Image'], {}, connection).info['Config']['Labels'] || {} - engine_labels = Docker.info(connection)['Labels'] || {} - - labels = (container.info['Config']['Labels'] || {}).reject do |key, val| - image_labels.any? { |k, v| k == key && v == val } || - engine_labels.any? { |k, v| k == key && v == val } - end - - public_send(:labels, labels) - end - - def validate_container_create - if property_is_set?(:restart_policy) && - restart_policy != 'no' && - restart_policy != 'always' && - restart_policy != 'unless-stopped' && - restart_policy != 'on-failure' - raise Chef::Exceptions::ValidationFailed, 'restart_policy must be either no, always, unless-stopped, or on-failure.' - end - - if autoremove == true && (property_is_set?(:restart_policy) && restart_policy != 'no') - raise Chef::Exceptions::ValidationFailed, 'Conflicting options restart_policy and autoremove.' - end - - if detach == true && - ( - attach_stderr == true || - attach_stdin == true || - attach_stdout == true || - stdin_once == true - ) - raise Chef::Exceptions::ValidationFailed, 'Conflicting options detach, attach_stderr, attach_stdin, attach_stdout, stdin_once.' - end - - if network_mode == 'host' && - ( - !(hostname.nil? || hostname.empty?) || - !(mac_address.nil? || mac_address.empty?) - ) - raise Chef::Exceptions::ValidationFailed, 'Cannot specify hostname or mac_address when network_mode is host.' - end - - if network_mode == 'container' && - ( - !(hostname.nil? || hostname.empty?) || - !(dns.nil? || dns.empty?) || - !(dns_search.nil? || dns_search.empty?) || - !(mac_address.nil? || mac_address.empty?) || - !(extra_hosts.nil? || extra_hosts.empty?) || - !(exposed_ports.nil? || exposed_ports.empty?) || - !(port_bindings.nil? || port_bindings.empty?) || - !(publish_all_ports.nil? || publish_all_ports.empty?) || - !port.nil? - ) - raise Chef::Exceptions::ValidationFailed, 'Cannot specify hostname, dns, dns_search, mac_address, extra_hosts, exposed_ports, port_bindings, publish_all_ports, port when network_mode is container.' - end - end - - def parsed_hostname - return nil if network_mode == 'host' - hostname - end - - action :create do - validate_container_create - - converge_if_changed do - action_delete - - with_retries do - config = { - 'name' => container_name, - 'Image' => "#{repo}:#{tag}", - 'Labels' => labels, - 'Cmd' => to_shellwords(command), - 'AttachStderr' => attach_stderr, - 'AttachStdin' => attach_stdin, - 'AttachStdout' => attach_stdout, - 'Domainname' => domain_name, - 'Entrypoint' => to_shellwords(entrypoint), - 'Env' => env, - 'ExposedPorts' => exposed_ports, - 'Hostname' => parsed_hostname, - 'MacAddress' => mac_address, - 'NetworkDisabled' => network_disabled, - 'OpenStdin' => open_stdin, - 'StdinOnce' => stdin_once, - 'Tty' => tty, - 'User' => user, - 'Volumes' => volumes, - 'WorkingDir' => working_dir, - 'HostConfig' => { - 'Binds' => volumes_binds, - 'CapAdd' => cap_add, - 'CapDrop' => cap_drop, - 'CgroupParent' => cgroup_parent, - 'CpuShares' => cpu_shares, - 'CpusetCpus' => cpuset_cpus, - 'Devices' => devices, - 'Dns' => dns, - 'DnsSearch' => dns_search, - 'ExtraHosts' => extra_hosts, - 'IpcMode' => ipc_mode, - 'Links' => links, - 'LogConfig' => log_config, - 'Memory' => memory, - 'MemorySwap' => memory_swap, - 'NetworkMode' => network_mode, - 'Privileged' => privileged, - 'PidMode' => pid_mode, - 'PortBindings' => port_bindings, - 'PublishAllPorts' => publish_all_ports, - 'RestartPolicy' => { - 'Name' => restart_policy, - 'MaximumRetryCount' => restart_maximum_retry_count, - }, - 'ReadonlyRootfs' => ro_rootfs, - 'Sysctls' => sysctls, - 'Ulimits' => ulimits_to_hash, - 'UsernsMode' => userns_mode, - 'UTSMode' => uts_mode, - 'VolumesFrom' => volumes_from, - 'VolumeDriver' => volume_driver, - }, - } - net_config = { - 'NetworkingConfig' => { - 'EndpointsConfig' => { - network_mode => { - 'IPAMConfig' => { - 'IPv4Address' => ip_address, - }, - }, - }, - }, - } if network_mode - config.merge! net_config - - Docker::Container.create(config, connection) - end - end - end - - action :start do - return if state['Restarting'] - return if state['Running'] - converge_by "starting #{container_name}" do - with_retries do - container.start - timeout ? container.wait(timeout) : container.wait unless detach - end - wait_running_state(true) if detach - end - end - - action :stop do - return unless state['Running'] - kill_after_str = " (will kill after #{kill_after}s)" if kill_after != -1 - converge_by "stopping #{container_name} #{kill_after_str}" do - begin - with_retries do - container.stop!('timeout' => kill_after) - wait_running_state(false) - end - rescue Docker::Error::TimeoutError - raise Docker::Error::TimeoutError, "Container failed to stop, consider adding kill_after to the container #{container_name}" - end - end - end - - action :kill do - return unless state['Running'] - converge_by "killing #{container_name}" do - with_retries { container.kill(signal: signal) } - end - end - - action :run do - validate_container_create - call_action(:create) - call_action(:start) - call_action(:delete) if autoremove - end - - action :run_if_missing do - return if current_resource - call_action(:run) - end - - action :pause do - return if state['Paused'] - converge_by "pausing #{container_name}" do - with_retries { container.pause } - end - end - - action :unpause do - return if current_resource && !state['Paused'] - converge_by "unpausing #{container_name}" do - with_retries { container.unpause } - end - end - - action :restart do - kill_after_str = " (will kill after #{kill_after}s)" if kill_after != -1 - converge_by "restarting #{container_name} #{kill_after_str}" do - current_resource ? container.restart('timeout' => kill_after) : call_action(:run) - end - end - - action :reload do - converge_by "reloading #{container_name}" do - with_retries { container.kill(signal: 'SIGHUP') } - end - end - - action :redeploy do - validate_container_create - - # never start containers resulting from a previous action :create #432 - should_create = state['Running'] == false && state['StartedAt'] == '0001-01-01T00:00:00Z' - call_action(:delete) - call_action(should_create ? :create : :run) - end - - action :delete do - return unless current_resource - call_action(:unpause) - call_action(:stop) - converge_by "deleting #{container_name}" do - with_retries { container.delete(force: force, v: remove_volumes) } - end - end - - action :remove do - call_action(:delete) - end - - action :commit do - converge_by "committing #{container_name}" do - with_retries do - new_image = container.commit - new_image.tag('repo' => repo, 'tag' => tag, 'force' => force) - end - end - end - - action :export do - raise "Please set outfile property on #{container_name}" if outfile.nil? - converge_by "exporting #{container_name}" do - with_retries do - ::File.open(outfile, 'w') { |f| container.export { |chunk| f.write(chunk) } } - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_exec.rb b/vendor-cookbooks/docker/libraries/docker_exec.rb deleted file mode 100644 index 0491d0dc..00000000 --- a/vendor-cookbooks/docker/libraries/docker_exec.rb +++ /dev/null @@ -1,21 +0,0 @@ -module DockerCookbook - class DockerExec < DockerBase - resource_name :docker_exec - - property :host, [String, nil], default: lazy { default_host } - property :command, Array - property :container, String - property :timeout, Numeric, default: 60 - - property :container_obj, Docker::Container, desired_state: false - - alias cmd command - - action :run do - converge_by "executing #{command} on #{container}" do - with_retries { container_obj Docker::Container.get(container, {}, connection) } - container_obj.exec(command, wait: timeout) - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_image.rb b/vendor-cookbooks/docker/libraries/docker_image.rb deleted file mode 100644 index 84551943..00000000 --- a/vendor-cookbooks/docker/libraries/docker_image.rb +++ /dev/null @@ -1,94 +0,0 @@ -module DockerCookbook - class DockerImage < DockerBase - require 'docker' - require_relative 'helpers_image' - - resource_name :docker_image - - # Modify the default of read_timeout from 60 to 120 - property :read_timeout, default: 120, desired_state: false - - # https://docs.docker.com/reference/api/docker_remote_api_v1.20/ - property :destination, [String, nil] - property :force, Boolean, default: false - property :host, [String, nil], default: lazy { default_host }, desired_state: false - property :nocache, Boolean, default: false - property :noprune, Boolean, default: false - property :repo, String, name_property: true - property :rm, Boolean, default: true - property :source, String - property :tag, String, default: 'latest' - - alias image repo - alias image_name repo - alias no_cache nocache - alias no_prune noprune - - ######### - # Actions - ######### - - default_action :pull - - declare_action_class.class_eval do - include DockerHelpers::Image - def whyrun_supported? - true - end - end - - action :build do - converge_by "Build image #{image_identifier}" do - build_image - end - end - - action :build_if_missing do - return if Docker::Image.exist?(image_identifier, {}, connection) - action_build - end - - action :import do - return if Docker::Image.exist?(image_identifier, {}, connection) - converge_by "Import image #{image_identifier}" do - import_image - end - end - - action :pull do - # We already did the work, but we need to report what we did! - converge_by "Pull image #{image_identifier}" do - end if pull_image - end - - action :pull_if_missing do - return if Docker::Image.exist?(image_identifier, {}, connection) - action_pull - end - - action :push do - converge_by "Push image #{image_identifier}" do - push_image - end - end - - action :remove do - return unless Docker::Image.exist?(image_identifier, {}, connection) - converge_by "Remove image #{image_identifier}" do - remove_image - end - end - - action :save do - converge_by "Save image #{image_identifier}" do - save_image - end - end - - action :load do - converge_by "load image #{image_identifier}" do - load_image - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_installation_binary.rb b/vendor-cookbooks/docker/libraries/docker_installation_binary.rb deleted file mode 100644 index 041dab42..00000000 --- a/vendor-cookbooks/docker/libraries/docker_installation_binary.rb +++ /dev/null @@ -1,40 +0,0 @@ -module DockerCookbook - class DockerInstallationBinary < DockerBase - require_relative 'helpers_installation_binary' - - include DockerHelpers::InstallationBinary - - ##################### - # Resource properties - ##################### - resource_name :docker_installation_binary - - property :checksum, String, default: lazy { default_checksum }, desired_state: false - property :source, String, default: lazy { default_source }, desired_state: false - property :version, String, default: lazy { default_version }, desired_state: false - - default_action :create - - ######### - # Actions - ######### - - action :create do - # Pull a precompiled binary off the network - remote_file docker_bin do - source new_resource.source - checksum new_resource.checksum - owner 'root' - group 'root' - mode '0755' - action :create - end - end - - action :delete do - file docker_bin do - action :delete - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_installation_package.rb b/vendor-cookbooks/docker/libraries/docker_installation_package.rb deleted file mode 100644 index 254c7da9..00000000 --- a/vendor-cookbooks/docker/libraries/docker_installation_package.rb +++ /dev/null @@ -1,30 +0,0 @@ -module DockerCookbook - class DockerInstallationPackage < DockerBase - require_relative 'helpers_installation_package' - - include DockerHelpers::InstallationPackage - - # Resource properties - resource_name :docker_installation_package - - property :package_name, String, default: 'docker-engine', desired_state: false - property :package_version, String, default: lazy { version_string(version) }, desired_state: false - property :version, String, default: lazy { default_docker_version }, desired_state: false - property :package_options, String, desired_state: false - - # Actions - action :create do - package package_name do - version package_version - options package_options - action :install - end - end - - action :delete do - package package_name do - action :remove - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_installation_script.rb b/vendor-cookbooks/docker/libraries/docker_installation_script.rb deleted file mode 100644 index 305031a6..00000000 --- a/vendor-cookbooks/docker/libraries/docker_installation_script.rb +++ /dev/null @@ -1,51 +0,0 @@ -module DockerCookbook - class DockerInstallationScript < DockerBase - ##################### - # Resource properties - ##################### - resource_name :docker_installation_script - - provides :docker_installation, os: 'linux' - - property :repo, %w(main test experimental), default: 'main', desired_state: false - property :script_url, String, default: lazy { default_script_url }, desired_state: false - - default_action :create - - ################ - # helper methods - ################ - - def default_script_url - case repo - when 'main' - 'https://get.docker.com/' - when 'test' - 'https://test.docker.com/' - when 'experimental' - 'https://experimental.docker.com/' - end - end - - ######### - # Actions - ######### - - action :create do - package 'curl' do - action :install - end - - execute 'install docker' do - command "curl -sSL #{script_url} | sh" - creates '/usr/bin/docker' - end - end - - action :delete do - package 'docker-engine' do - action :remove - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_installation_tarball.rb b/vendor-cookbooks/docker/libraries/docker_installation_tarball.rb deleted file mode 100644 index d9b1d315..00000000 --- a/vendor-cookbooks/docker/libraries/docker_installation_tarball.rb +++ /dev/null @@ -1,47 +0,0 @@ -module DockerCookbook - class DockerInstallationTarball < DockerBase - require_relative 'helpers_installation_tarball' - - include DockerHelpers::InstallationTarball - - ##################### - # Resource properties - ##################### - resource_name :docker_installation_tarball - - property :checksum, String, default: lazy { default_checksum }, desired_state: false - property :source, String, default: lazy { default_source }, desired_state: false - property :version, String, default: lazy { default_version }, desired_state: false - - default_action :create - - ######### - # Actions - ######### - - action :create do - # Pull a precompiled binary off the network - remote_file docker_tarball do - source new_resource.source - checksum new_resource.checksum - owner 'root' - group 'root' - mode '0755' - action :create - notifies :run, 'execute[extract tarball]', :immediately - end - - execute 'extract tarball' do - action :nothing - command "tar -xzf #{docker_tarball} --strip-components=1 -C #{docker_bin_prefix}" - creates docker_bin - end - end - - action :delete do - file docker_bin do - action :delete - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_network.rb b/vendor-cookbooks/docker/libraries/docker_network.rb deleted file mode 100644 index 050db8a5..00000000 --- a/vendor-cookbooks/docker/libraries/docker_network.rb +++ /dev/null @@ -1,127 +0,0 @@ -module DockerCookbook - class DockerNetwork < DockerBase - require 'docker' - require_relative 'helpers_network' - include DockerHelpers::Network - - resource_name :docker_network - - property :auxiliary_addresses, [String, Array, nil], coerce: proc { |v| coerce_auxiliary_addresses(v) } - property :container, String, desired_state: false - property :driver, String - property :driver_opts, PartialHashType - property :gateway, [String, Array, nil], coerce: proc { |v| coerce_gateway(v) } - property :host, [String, nil], default: lazy { default_host }, desired_state: false - property :id, String - property :ip_range, [String, Array, nil], coerce: proc { |v| coerce_ip_range(v) } - property :ipam_driver, String - property :network, Docker::Network, desired_state: false - property :network_name, String, name_property: true - property :subnet, [String, Array, nil], coerce: proc { |v| coerce_subnet(v) } - - alias aux_address auxiliary_addresses - - load_current_value do - begin - with_retries { network Docker::Network.get(network_name, {}, connection) } - rescue Docker::Error::NotFoundError - current_value_does_not_exist! - end - - aux_addr_ray = [] - gateway_ray = [] - ip_range_ray = [] - subnet_ray = [] - - network.info['IPAM']['Config'].to_a.each do |conf| - conf.each do |key, value| - case key - when 'AuxiliaryAddresses' - aux_addr_ray << value - when 'Gateway' - gateway_ray << value - when 'IPRange' - ip_range_ray << value - when 'Subnet' - subnet_ray << value - end - end - end - - auxiliary_addresses aux_addr_ray - gateway gateway_ray - ip_range ip_range_ray - subnet subnet_ray - - driver network.info['Driver'] - driver_opts network.info['Options'] - end - - action :create do - converge_if_changed do - action_delete - - with_retries do - options = {} - options['Driver'] = driver if driver - options['Options'] = driver_opts if driver_opts - ipam_options = consolidate_ipam(subnet, ip_range, gateway, aux_address) - options['IPAM'] = { 'Config' => ipam_options } unless ipam_options.empty? - options['IPAM']['Driver'] = ipam_driver if ipam_driver - Docker::Network.create(network_name, options) - end - end - end - - action :delete do - return unless current_resource - converge_by "deleting #{network_name}" do - with_retries do - network.delete - end - end - end - - action :remove do - action_delete - end - - action :connect do - unless container - raise Chef::Exceptions::ValidationFailed, 'Container id or name is required for action :connect' - end - - if current_resource - container_index = network.info['Containers'].values.index { |c| c['Name'] == container } - if container_index.nil? - converge_by("connect #{container}") do - with_retries do - network.connect(container) - end - end - end - else - Chef::Log.warn("Cannot connect to #{network_name}: network does not exist") - end - end - - action :disconnect do - unless container - raise Chef::Exceptions::ValidationFailed, 'Container id or name is required for action :disconnect' - end - - if current_resource - container_index = network.info['Containers'].values.index { |c| c['Name'] == container } - unless container_index.nil? - converge_by("disconnect #{container}") do - with_retries do - network.disconnect(container) - end - end - end - else - Chef::Log.warn("Cannot disconnect from #{network_name}: network does not exist") - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_registry.rb b/vendor-cookbooks/docker/libraries/docker_registry.rb deleted file mode 100644 index f6b2e7ce..00000000 --- a/vendor-cookbooks/docker/libraries/docker_registry.rb +++ /dev/null @@ -1,38 +0,0 @@ -module DockerCookbook - class DockerRegistry < DockerBase - require 'docker' - require_relative 'helpers_auth' - - resource_name :docker_registry - - property :email, [String, nil] - property :password, [String, nil] - property :serveraddress, [String, nil], name_property: true - property :username, [String, nil] - - action :login do - tries = api_retries - - registry_host = parse_registry_host(serveraddress) - - (node.run_state['docker_auth'] ||= {})[registry_host] = { - 'serveraddress' => registry_host, - 'username' => username, - 'password' => password, - 'email' => email, - } - - begin - Docker.connection.post( - '/auth', {}, - body: node.run_state['docker_auth'][registry_host].to_json - ) - rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError - raise Docker::Error::AuthenticationError, "#{username} failed to authenticate with #{serveraddress}" if (tries -= 1).zero? - retry - end - - true - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service.rb b/vendor-cookbooks/docker/libraries/docker_service.rb deleted file mode 100644 index 12b26f9c..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service.rb +++ /dev/null @@ -1,128 +0,0 @@ -module DockerCookbook - require_relative 'docker_service_base' - - class DockerService < DockerServiceBase - resource_name :docker_service - - # register with the resource resolution system - provides :docker_service - - # installation type and service_manager - property :install_method, %w(binary script package tarball none auto), default: 'auto', desired_state: false - property :service_manager, %w(execute sysvinit upstart systemd auto), default: 'auto', desired_state: false - - # docker_installation_script - property :repo, desired_state: false - property :script_url, String, desired_state: false - - # docker_installation_binary and tarball - property :checksum, String, desired_state: false - property :docker_bin, String, desired_state: false - property :source, String, desired_state: false - - # docker_installation_package - property :package_version, String, desired_state: false - - # binary, package and tarball - property :version, String, desired_state: false - property :package_options, [String, nil], desired_state: false - - ################ - # Helper Methods - ################ - def validate_install_method - if property_is_set?(:version) && - install_method != 'binary' && - install_method != 'package' && - install_method != 'tarball' - raise Chef::Exceptions::ValidationFailed, 'Version property only supported for binary, package and tarball installation methods' - end - end - - def copy_properties_to(to, *properties) - properties = self.class.properties.keys if properties.empty? - properties.each do |p| - # If the property is set on from, and exists on to, set the - # property on to - if to.class.properties.include?(p) && property_is_set?(p) - to.send(p, send(p)) - end - end - end - - action_class.class_eval do - def installation(&block) - case install_method - when 'auto' - install = docker_installation(name, &block) - when 'binary' - install = docker_installation_binary(name, &block) - when 'script' - install = docker_installation_script(name, &block) - when 'package' - install = docker_installation_package(name, &block) - when 'tarball' - install = docker_installation_tarball(name, &block) - when 'none' - Chef::Log.info('Skipping Docker installation. Assuming it was handled previously.') - return - end - copy_properties_to(install) - install - end - - def svc_manager(&block) - case service_manager - when 'auto' - svc = docker_service_manager(name, &block) - when 'execute' - svc = docker_service_manager_execute(name, &block) - when 'sysvinit' - svc = docker_service_manager_sysvinit(name, &block) - when 'upstart' - svc = docker_service_manager_upstart(name, &block) - when 'systemd' - svc = docker_service_manager_systemd(name, &block) - end - copy_properties_to(svc) - svc - end - end - - ######### - # Actions - ######### - - action :create do - validate_install_method - - installation do - action :create - end - end - - action :delete do - installation do - action :delete - end - end - - action :start do - svc_manager do - action :start - end - end - - action :stop do - svc_manager do - action :stop - end - end - - action :restart do - svc_manager do - action :restart - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service_base.rb b/vendor-cookbooks/docker/libraries/docker_service_base.rb deleted file mode 100644 index fa2393e5..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service_base.rb +++ /dev/null @@ -1,123 +0,0 @@ -module DockerCookbook - class DockerServiceBase < DockerBase - ################ - # Helper Methods - ################ - require 'docker' - require_relative 'helpers_service' - include DockerHelpers::Service - - ##################### - # resource properties - ##################### - - resource_name :docker_service_base - - # register with the resource resolution system - provides :docker_service_manager - - # daemon management - property :instance, String, name_property: true, required: true, desired_state: false - property :auto_restart, Boolean, default: false - property :api_cors_header, [String, nil] - property :bridge, [String, nil] - property :bip, [IPV4_ADDR, IPV4_CIDR, IPV6_ADDR, IPV6_CIDR, nil] - property :cluster_store, [String, nil] - property :cluster_advertise, [String, nil] - property :cluster_store_opts, ArrayType - property :debug, [Boolean, nil] - property :daemon, Boolean, default: true - property :dns, ArrayType - property :dns_search, [Array, nil] - property :exec_driver, ['native', 'lxc', nil] - property :exec_opts, ArrayType - property :fixed_cidr, [String, nil] - property :fixed_cidr_v6, [String, nil] - property :group, [String, nil] - property :graph, [String, nil] - property :host, [String, Array], coerce: proc { |v| coerce_host(v) } - property :icc, [Boolean, nil] - property :insecure_registry, [Array, String, nil], coerce: proc { |v| coerce_insecure_registry(v) } - property :ip, [IPV4_ADDR, IPV6_ADDR, nil] - property :ip_forward, [Boolean, nil] - property :ipv4_forward, Boolean, default: true - property :ipv6_forward, Boolean, default: true - property :ip_masq, [Boolean, nil] - property :iptables, [Boolean, nil] - property :ipv6, [Boolean, nil] - property :log_level, [:debug, :info, :warn, :error, :fatal, nil] - property :labels, [String, Array], coerce: proc { |v| coerce_daemon_labels(v) }, desired_state: false - property :log_driver, %w( json-file syslog journald gelf fluentd awslogs splunk none ) - property :log_opts, ArrayType - property :mount_flags, String, default: 'slave' - property :mtu, [String, nil] - property :pidfile, String, default: lazy { "/var/run/#{docker_name}.pid" } - property :registry_mirror, [String, nil] - property :storage_driver, ArrayType - property :selinux_enabled, [Boolean, nil] - property :storage_opts, ArrayType - property :default_ulimit, ArrayType - property :userland_proxy, [Boolean, nil] - property :disable_legacy_registry, [Boolean, nil] - property :userns_remap, [String, nil] - - # These are options specific to systemd configuration such as - # LimitNOFILE or TasksMax that you may wannt to use to customize - # the environment in which Docker runs. - property :systemd_opts, ArrayType - - # These are unvalidated daemon arguments passed in as a string. - property :misc_opts, [String, nil] - - # environment variables to set before running daemon - property :http_proxy, [String, nil] - property :https_proxy, [String, nil] - property :no_proxy, [String, nil] - property :tmpdir, [String, nil] - - # logging - property :logfile, String, default: '/var/log/docker.log' - - # docker-wait-ready timeout - property :service_timeout, Integer, default: 20 - - allowed_actions :start, :stop, :restart - - alias label labels - alias tlscacert tls_ca_cert - alias tlscert tls_server_cert - alias tlskey tls_server_key - alias tlsverify tls_verify - alias run_group group - - declare_action_class.class_eval do - def libexec_dir - return '/usr/libexec/docker' if node['platform_family'] == 'rhel' - '/usr/lib/docker' - end - - def create_docker_wait_ready - directory libexec_dir do - owner 'root' - group 'root' - mode '0755' - action :create - end - - template "#{libexec_dir}/#{docker_name}-wait-ready" do - source 'default/docker-wait-ready.erb' - owner 'root' - group 'root' - mode '0755' - variables( - docker_cmd: docker_cmd, - libexec_dir: libexec_dir, - service_timeout: service_timeout - ) - cookbook 'docker' - action :create - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service_manager_execute.rb b/vendor-cookbooks/docker/libraries/docker_service_manager_execute.rb deleted file mode 100644 index 01dc20e3..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service_manager_execute.rb +++ /dev/null @@ -1,56 +0,0 @@ -module DockerCookbook - class DockerServiceManagerExecute < DockerServiceBase - resource_name :docker_service_manager_execute - - provides :docker_service_manager, os: 'linux' - - # Start the service - action :start do - # enable ipv4 forwarding - execute 'enable net.ipv4.conf.all.forwarding' do - command '/sbin/sysctl net.ipv4.conf.all.forwarding=1' - not_if '/sbin/sysctl -q -n net.ipv4.conf.all.forwarding | grep ^1$' - action :run - end - - # enable ipv6 forwarding - execute 'enable net.ipv6.conf.all.forwarding' do - command '/sbin/sysctl net.ipv6.conf.all.forwarding=1' - not_if '/sbin/sysctl -q -n net.ipv6.conf.all.forwarding | grep ^1$' - action :run - end - - # Go doesn't support detaching processes natively, so we have - # to manually fork it from the shell with & - # https://github.com/docker/docker/issues/2758 - bash "start docker #{name}" do - code "#{docker_daemon_cmd} >> #{logfile} 2>&1 &" - environment 'HTTP_PROXY' => http_proxy, - 'HTTPS_PROXY' => https_proxy, - 'NO_PROXY' => no_proxy, - 'TMPDIR' => tmpdir - not_if "ps -ef | grep -v grep | grep #{Shellwords.escape(docker_daemon_cmd)}" - action :run - end - - create_docker_wait_ready - - execute 'docker-wait-ready' do - command "#{libexec_dir}/#{docker_name}-wait-ready" - end - end - - action :stop do - execute "stop docker #{name}" do - command "kill `cat #{pidfile}` && while [ -e #{pidfile} ]; do sleep 1; done" - timeout 10 - only_if "#{docker_cmd} ps | head -n 1 | grep ^CONTAINER" - end - end - - action :restart do - action_stop - action_start - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service_manager_systemd.rb b/vendor-cookbooks/docker/libraries/docker_service_manager_systemd.rb deleted file mode 100644 index f26994ca..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service_manager_systemd.rb +++ /dev/null @@ -1,116 +0,0 @@ -module DockerCookbook - class DockerServiceManagerSystemd < DockerServiceBase - resource_name :docker_service_manager_systemd - - provides :docker_service_manager, platform: 'fedora' - - provides :docker_service_manager, platform: %w(redhat centos scientific oracle) do |node| # ~FC005 - node['platform_version'].to_f >= 7.0 - end - - provides :docker_service_manager, platform: 'debian' do |node| - node['platform_version'].to_f >= 8.0 - end - - provides :docker_service_manager, platform: 'ubuntu' do |node| - node['platform_version'].to_f >= 15.04 - end - - action :start do - create_docker_wait_ready - - # stock systemd unit file - template "/lib/systemd/system/#{docker_name}.service" do - source 'systemd/docker.service.erb' - owner 'root' - group 'root' - mode '0644' - variables( - docker_name: docker_name, - docker_socket: connect_socket.sub(%r{unix://|fd://}, ''), - docker_mount_flags: mount_flags - ) - cookbook 'docker' - action :create - not_if { docker_name == 'default' && ::File.exist?('/lib/systemd/system/docker.service') } - end - - # stock systemd socket file - template "/lib/systemd/system/#{docker_name}.socket" do - source 'systemd/docker.socket.erb' - owner 'root' - group 'root' - mode '0644' - variables( - docker_name: docker_name, - docker_socket: connect_socket.sub(%r{unix://|fd://}, '') - ) - cookbook 'docker' - action :create - not_if { docker_name == 'default' && ::File.exist?('/lib/systemd/system/docker.socket') } - end - - template "/etc/systemd/system/#{docker_name}.service" do - source 'systemd/docker.service-override.erb' - owner 'root' - group 'root' - mode '0644' - variables( - config: new_resource, - docker_daemon_cmd: docker_daemon_cmd, - systemd_args: systemd_args, - docker_wait_ready: "#{libexec_dir}/#{docker_name}-wait-ready", - docker_mount_flags: mount_flags - ) - cookbook 'docker' - notifies :run, 'execute[systemctl daemon-reload]', :immediately - action :create - end - - # this overrides the main systemd socket - template "/etc/systemd/system/#{docker_name}.socket" do - source 'systemd/docker.socket-override.erb' - owner 'root' - group 'root' - mode '0644' - variables( - config: new_resource, - docker_name: docker_name, - docker_socket: connect_socket.sub(%r{unix://|fd://}, '') - ) - cookbook 'docker' - notifies :run, 'execute[systemctl daemon-reload]', :immediately - action :create - end - - # avoid 'Unit file changed on disk' warning - execute 'systemctl daemon-reload' do - command '/bin/systemctl daemon-reload' - action :nothing - end - - # service management resource - service docker_name do - provider Chef::Provider::Service::Systemd - supports status: true - action [:enable, :start] - only_if { ::File.exist?("/lib/systemd/system/#{docker_name}.service") } - end - end - - action :stop do - # service management resource - service docker_name do - provider Chef::Provider::Service::Systemd - supports status: true - action [:disable, :stop] - only_if { ::File.exist?("/lib/systemd/system/#{docker_name}.service") } - end - end - - action :restart do - action_stop - action_start - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service_manager_sysvinit_debian.rb b/vendor-cookbooks/docker/libraries/docker_service_manager_sysvinit_debian.rb deleted file mode 100644 index af3ce968..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service_manager_sysvinit_debian.rb +++ /dev/null @@ -1,87 +0,0 @@ -module DockerCookbook - class DockerServiceManagerSysvinitDebian < DockerServiceBase - resource_name :docker_service_manager_sysvinit_debian - - provides :docker_service_manager, platform: 'debian' do |node| - node['platform_version'].to_f < 8.0 - end - - provides :docker_service_manager, platform: 'ubuntu' do |node| - node['platform_version'].to_f < 12.04 - end - - provides :docker_service_manager_sysvinit, platform: 'debian' do |node| - node['platform_version'].to_f < 8.0 - end - - provides :docker_service_manager_sysvinit, platform: 'ubuntu' do |node| - node['platform_version'].to_f < 12.04 - end - - action :start do - create_docker_wait_ready - create_init - create_service - end - - action :stop do - create_init - s = create_service - s.action :stop - end - - action :restart do - action_stop - action_start - end - - action_class.class_eval do - def create_init - execute 'groupadd docker' do - not_if 'getent group docker' - action :run - end - - link "/usr/bin/#{docker_name}" do - to '/usr/bin/docker' - link_type :hard - action :create - not_if { docker_name == 'docker' } - end - - template "/etc/init.d/#{docker_name}" do - source 'sysvinit/docker-debian.erb' - owner 'root' - group 'root' - mode '0755' - variables( - docker_name: docker_name, - docker_daemon_arg: docker_daemon_arg, - docker_wait_ready: "#{libexec_dir}/#{docker_name}-wait-ready" - ) - cookbook 'docker' - action :create - end - - template "/etc/default/#{docker_name}" do - source 'default/docker.erb' - variables( - config: new_resource, - docker_daemon: docker_daemon, - docker_daemon_opts: docker_daemon_opts.join(' ') - ) - cookbook 'docker' - action :create - end - end - - def create_service - service docker_name do - provider Chef::Provider::Service::Init::Debian - supports restart: true, status: true - action [:enable, :start] - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service_manager_sysvinit_rhel.rb b/vendor-cookbooks/docker/libraries/docker_service_manager_sysvinit_rhel.rb deleted file mode 100644 index 1efaee30..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service_manager_sysvinit_rhel.rb +++ /dev/null @@ -1,81 +0,0 @@ -module DockerCookbook - class DockerServiceManagerSysvinitRhel < DockerServiceBase - resource_name :docker_service_manager_sysvinit_rhel - - provides :docker_service_manager, platform: 'amazon' - provides :docker_service_manager, platform: 'suse' - provides :docker_service_manager, platform: %w(redhat centos scientific oracle) do |node| # ~FC005 - node['platform_version'].to_f <= 7.0 - end - - provides :docker_service_manager_sysvinit, platform: 'amazon' - provides :docker_service_manager_sysvinit, platform: 'suse' - provides :docker_service_manager_sysvinit, platform: %w(redhat centos scientific oracle) do |node| # ~FC005 - node['platform_version'].to_f <= 7.0 - end - - action :start do - create_docker_wait_ready - create_init - create_service - end - - action :stop do - create_init - s = create_service - s.action :stop - end - - action :restart do - action_stop - action_start - end - - action_class.class_eval do - def create_init - execute 'groupadd docker' do - not_if 'getent group docker' - action :run - end - - link "/usr/bin/#{docker_name}" do - to '/usr/bin/docker' - link_type :hard - action :create - not_if { docker_name == 'docker' } - end - - template "/etc/init.d/#{docker_name}" do - source 'sysvinit/docker-rhel.erb' - owner 'root' - group 'root' - mode '0755' - variables( - docker_name: docker_name, - docker_daemon_arg: docker_daemon_arg, - docker_wait_ready: "#{libexec_dir}/#{docker_name}-wait-ready" - ) - cookbook 'docker' - action :create - end - - template "/etc/sysconfig/#{docker_name}" do - source 'sysconfig/docker.erb' - variables( - config: new_resource, - docker_daemon_opts: docker_daemon_opts.join(' ') - ) - cookbook 'docker' - action :create - end - end - - def create_service - service docker_name do - supports restart: true, status: true - action [:enable, :start] - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_service_manager_upstart.rb b/vendor-cookbooks/docker/libraries/docker_service_manager_upstart.rb deleted file mode 100644 index db536c68..00000000 --- a/vendor-cookbooks/docker/libraries/docker_service_manager_upstart.rb +++ /dev/null @@ -1,74 +0,0 @@ -module DockerCookbook - class DockerServiceManagerUpstart < DockerServiceBase - resource_name :docker_service_manager_upstart - - provides :docker_service_manager, platform: 'ubuntu' - provides :docker_service_manager, platform: 'linuxmint' - - action :start do - create_docker_wait_ready - - template "/etc/init/#{docker_name}.conf" do - source 'upstart/docker.conf.erb' - owner 'root' - group 'root' - mode '0644' - variables( - docker_name: docker_name, - docker_daemon_arg: docker_daemon_arg, - docker_wait_ready: "#{libexec_dir}/#{docker_name}-wait-ready" - ) - cookbook 'docker' - action :create - end - - template "/etc/default/#{docker_name}" do - source 'default/docker.erb' - variables( - config: new_resource, - docker_daemon: docker_daemon, - docker_daemon_opts: docker_daemon_opts.join(' ') - ) - cookbook 'docker' - action :create - end - - # Upstart broken in 12.17.44 - # https://github.com/chef/chef/issues/2819 ish.. - # - # hack around this until it gets fixed in Chef proper - # - # service docker_name do - # provider Chef::Provider::Service::Upstart - # supports status: true - # action :start - # end - - execute '/sbin/initctl start docker' do - only_if '/sbin/status docker | grep "stop/waiting"' - end - end - - action :stop do - # Upstart broken in 12.17.44 - # https://github.com/chef/chef/issues/2819 ish.. - # - # hack around this until it gets fixed in Chef proper - # - # service docker_name do - # provider Chef::Provider::Service::Upstart - # supports status: true - # action :stop - # end - - execute '/sbin/initctl stop docker' do - not_if '/sbin/status docker | grep "stop/waiting"' - end - end - - action :restart do - action_stop - action_start - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_tag.rb b/vendor-cookbooks/docker/libraries/docker_tag.rb deleted file mode 100644 index e9fc4715..00000000 --- a/vendor-cookbooks/docker/libraries/docker_tag.rb +++ /dev/null @@ -1,27 +0,0 @@ -module DockerCookbook - class DockerTag < DockerBase - resource_name :docker_tag - - property :target_repo, String, name_property: true - property :target_tag, String - property :to_repo, String - property :to_tag, String - property :force, Boolean, default: false - - ######### - # Actions - ######### - - action :tag do - return if force == false && Docker::Image.exist?("#{to_repo}:#{to_tag}") - begin - converge_by "update #{target_repo}:#{target_tag} to #{to_repo}:#{to_tag}" do - i = Docker::Image.get("#{target_repo}:#{target_tag}") - i.tag('repo' => to_repo, 'tag' => to_tag, 'force' => force) - end - rescue Docker::Error => e - raise e.message - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/docker_volume.rb b/vendor-cookbooks/docker/libraries/docker_volume.rb deleted file mode 100644 index 9bc735f3..00000000 --- a/vendor-cookbooks/docker/libraries/docker_volume.rb +++ /dev/null @@ -1,33 +0,0 @@ -module DockerCookbook - class DockerVolume < DockerBase - require 'docker' - - resource_name :docker_volume - - property :driver, String, desired_state: false - property :host, [String, nil], default: lazy { default_host }, desired_state: false - property :opts, [String, Array, nil], desired_state: false - property :volume, Docker::Volume, desired_state: false - property :volume_name, String, name_property: true - - load_current_value do - begin - with_retries { volume Docker::Volume.get(volume_name, connection) } - rescue Docker::Error::NotFoundError - current_value_does_not_exist! - end - end - - action :create do - converge_by "creating volume #{volume_name}" do - Docker::Volume.create(volume_name, {}, connection) - end if volume.nil? - end - - action :remove do - converge_by "removing volume #{volume_name}" do - volume.remove - end unless volume.nil? - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_auth.rb b/vendor-cookbooks/docker/libraries/helpers_auth.rb deleted file mode 100644 index 40b36540..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_auth.rb +++ /dev/null @@ -1,10 +0,0 @@ -module DockerCookbook - module DockerHelpers - module Authentication - # https://github.com/docker/docker/blob/4fcb9ac40ce33c4d6e08d5669af6be5e076e2574/registry/auth.go#L231 - def parse_registry_host(val) - val.sub(%r{https?://}, '').split('/').first - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_base.rb b/vendor-cookbooks/docker/libraries/helpers_base.rb deleted file mode 100644 index 43b8f30f..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_base.rb +++ /dev/null @@ -1,110 +0,0 @@ -module DockerCookbook - module DockerHelpers - module Base - require 'shellwords' - - # Misc - def to_snake_case(name) - # ExposedPorts -> _exposed_ports - name = name.gsub(/[A-Z]/) { |x| "_#{x.downcase}" } - # _exposed_ports -> exposed_ports - name = name[1..-1] if name.start_with?('_') - name - end - - ########## - # coersion - ########## - - def coerce_labels(v) - case v - when Hash, nil - v - else - Array(v).each_with_object({}) do |label, h| - parts = label.split(':') - h[parts[0]] = parts[1] - end - end - end - - def coerce_shell_command(v) - return nil if v.nil? - return DockerBase::ShellCommandString.new( - ::Shellwords.join(v) - ) if v.is_a?(Array) - DockerBase::ShellCommandString.new(v) - end - - ################ - # Helper methods - ################ - - def api_version - @api_version ||= Docker.version(connection)['ApiVersion'] - end - - def connection - @connection ||= begin - opts = {} - opts[:read_timeout] = read_timeout if read_timeout - opts[:write_timeout] = write_timeout if write_timeout - - if host =~ /^tcp:/ - opts[:scheme] = 'https' if tls || !tls_verify.nil? - opts[:ssl_ca_file] = tls_ca_cert if tls_ca_cert - opts[:client_cert] = tls_client_cert if tls_client_cert - opts[:client_key] = tls_client_key if tls_client_key - end - Docker::Connection.new(host || Docker.url, opts) - end - end - - def with_retries(&_block) - tries = api_retries - begin - yield - # Only catch errors that can be fixed with retries. - rescue Docker::Error::ServerError, # 404 - Docker::Error::UnexpectedResponseError, # 400 - Docker::Error::TimeoutError, - Docker::Error::IOError - tries -= 1 - retry if tries > 0 - raise - end - end - - def call_action(_action) - new_resource.run_action - end - - def default_host - return nil unless ENV['DOCKER_HOST'] - ENV['DOCKER_HOST'] - end - - def default_tls - return nil unless ENV['DOCKER_TLS'] - ENV['DOCKER_TLS'] - end - - def default_tls_verify - return nil unless ENV['DOCKER_TLS_VERIFY'] - ENV['DOCKER_TLS_VERIFY'] - end - - def default_tls_cert_path(v) - return nil unless ENV['DOCKER_CERT_PATH'] - case v - when 'ca' - "#{ENV['DOCKER_CERT_PATH']}/ca.pem" - when 'cert' - "#{ENV['DOCKER_CERT_PATH']}/cert.pem" - when 'key' - "#{ENV['DOCKER_CERT_PATH']}/key.pem" - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_container.rb b/vendor-cookbooks/docker/libraries/helpers_container.rb deleted file mode 100644 index 66e8dca5..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_container.rb +++ /dev/null @@ -1,236 +0,0 @@ -module DockerCookbook - module DockerHelpers - module Container - def coerce_links(v) - case v - when DockerBase::UnorderedArray, nil - v - else - return nil if v.empty? - # Parse docker input of /source:/container_name/dest into source:dest - DockerBase::UnorderedArray.new(Array(v)).map! do |link| - if link =~ %r{^/(?.+):/#{name}/(?.+)} - link = "#{Regexp.last_match[:source]}:#{Regexp.last_match[:dest]}" - end - link - end - end - end - - def coerce_log_opts(v) - case v - when Hash, nil - v - else - Array(v).each_with_object({}) do |log_opt, memo| - key, value = log_opt.split('=', 2) - memo[key] = value - end - end - end - - def coerce_ulimits(v) - return v if v.nil? - Array(v).map do |u| - u = "#{u['Name']}=#{u['Soft']}:#{u['Hard']}" if u.is_a?(Hash) - u - end - end - - def coerce_volumes(v) - case v - when DockerBase::PartialHash, nil - v - when Hash - DockerBase::PartialHash[v] - else - b = [] - v = Array(v).to_a # in case v.is_A?(Chef::Node::ImmutableArray) - v.delete_if do |x| - parts = x.split(':') - b << x if parts.length > 1 - end - b = nil if b.empty? - volumes_binds b - return DockerBase::PartialHash.new if v.empty? - v.each_with_object(DockerBase::PartialHash.new) { |volume, h| h[volume] = {} } - end - end - - def state - # Always return the latest state, see #510 - return Docker::Container.get(container_name, {}, connection).info['State'] - rescue - return {} - end - - def wait_running_state(v) - tries = running_wait_time - tries.times do - return if state['Running'] == v - sleep 1 - end - return if state['Running'] == v - - # Container failed to reach correct state: Throw an error - desired_state_str = v ? 'running' : 'not running' - raise Docker::Error::TimeoutError, "Container #{container_name} failed to change to #{desired_state_str} state after #{tries} seconds" - end - - def port(v = nil) - return @port if v.nil? - exposed_ports coerce_exposed_ports(v) - port_bindings coerce_port_bindings(v) - @port = v - @port - end - - def parse_port(v) - parts = v.split(':') - case parts.length - when 3 - host_ip = parts[0] - host_port = parts[1] - container_port = parts[2] - when 2 - host_ip = '0.0.0.0' - host_port = parts[0] - container_port = parts[1] - when 1 - host_ip = '' - host_port = '' - container_port = parts[0] - end - port_range, protocol = container_port.split('/') - if port_range.include?('-') - port_range = container_port.split('-') - port_range.map!(&:to_i) - Chef::Log.fatal("FATAL: Invalid port range! #{container_port}") if port_range[0] > port_range[1] - port_range = (port_range[0]..port_range[1]).to_a - end - # qualify the port-binding protocol even when it is implicitly tcp #427. - protocol = 'tcp' if protocol.nil? - Array(port_range).map do |port| - { - 'host_ip' => host_ip, - 'host_port' => host_port, - 'container_port' => "#{port}/#{protocol}", - } - end - end - - def coerce_exposed_ports(v) - case v - when Hash, nil - v - else - x = Array(v).map { |a| parse_port(a) } - x.flatten! - x.each_with_object({}) do |y, h| - h[y['container_port']] = {} - end - end - end - - def coerce_port_bindings(v) - case v - when Hash, nil - v - else - x = Array(v).map { |a| parse_port(a) } - x.flatten! - x.each_with_object({}) do |y, h| - h[y['container_port']] = [] unless h[y['container_port']] - h[y['container_port']] << { - 'HostIp' => y['host_ip'], - 'HostPort' => y['host_port'], - } - end - end - end - - # log_driver and log_opts really handle this - def log_config(value = Chef::NOT_PASSED) - if value != Chef::NOT_PASSED - @log_config = value - log_driver value['Type'] - log_opts value['Config'] - end - return @log_config if defined?(@log_config) - def_logcfg = {} - def_logcfg['Type'] = log_driver if property_is_set?(:log_driver) - def_logcfg['Config'] = log_opts if property_is_set?(:log_opts) - def_logcfg = nil if def_logcfg.empty? - def_logcfg - end - - # TODO: test image property in serverspec and kitchen, not only in rspec - # for full specs of image parsing, see spec/helpers_container_spec.rb - # - # If you say: `repo 'blah'` - # Image will be: `blah:latest` - # - # If you say: `repo 'blah'; tag '3.1'` - # Image will be: `blah:3.1` - # - # If you say: `image 'blah'` - # Repo will be: `blah` - # Tag will be: `latest` - # - # If you say: `image 'blah:3.1'` - # Repo will be: `blah` - # Tag will be: `3.1` - # - # If you say: `image 'repo/blah'` - # Repo will be: `repo/blah` - # Tag will be: `latest` - # - # If you say: `image 'repo/blah:3.1'` - # Repo will be: `repo/blah` - # Tag will be: `3.1` - # - # If you say: `image 'repo:1337/blah'` - # Repo will be: `repo:1337/blah` - # Tag will be: `latest' - # - # If you say: `image 'repo:1337/blah:3.1'` - # Repo will be: `repo:1337/blah` - # Tag will be: `3.1` - # - def image(image = nil) - if image - if image.include?('/') - # pathological case, a ':' may be present which starts the 'port' - # part of the image name and not a tag. example: 'host:1337/blah' - # fortunately, tags are only found in the 'basename' part of image - # so we can split on '/' and rebuild once the tag has been parsed. - dirname, _, basename = image.rpartition('/') - r, t = basename.split(':', 2) - r = [dirname, r].join('/') - else - # normal case, the ':' starts the tag part - r, t = image.split(':', 2) - end - repo r - tag t if t - end - "#{repo}:#{tag}" - end - - def to_shellwords(command) - return nil if command.nil? - Shellwords.shellwords(command) - end - - def ulimits_to_hash - return nil if ulimits.nil? - ulimits.map do |u| - name = u.split('=')[0] - soft = u.split('=')[1].split(':')[0] - hard = u.split('=')[1].split(':')[1] - { 'Name' => name, 'Soft' => soft.to_i, 'Hard' => hard.to_i } - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_image.rb b/vendor-cookbooks/docker/libraries/helpers_image.rb deleted file mode 100644 index f08614c9..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_image.rb +++ /dev/null @@ -1,104 +0,0 @@ -module DockerCookbook - module DockerHelpers - module Image - ################ - # Helper methods - ################ - - def build_from_directory - i = Docker::Image.build_from_dir( - source, - { - 'nocache' => nocache, - 'rm' => rm, - }, - connection - ) - i.tag('repo' => repo, 'tag' => tag, 'force' => force) - end - - def build_from_dockerfile - i = Docker::Image.build( - IO.read(source), - { - 'nocache' => nocache, - 'rm' => rm, - }, - connection - ) - i.tag('repo' => repo, 'tag' => tag, 'force' => force) - end - - def build_from_tar - i = Docker::Image.build_from_tar( - ::File.open(source, 'r'), - { - 'nocache' => nocache, - 'rm' => rm, - }, - connection - ) - i.tag('repo' => repo, 'tag' => tag, 'force' => force) - end - - def build_image - if ::File.directory?(source) - build_from_directory - elsif ::File.extname(source) == '.tar' - build_from_tar - else - build_from_dockerfile - end - end - - def image_identifier - "#{repo}:#{tag}" - end - - def import_image - with_retries do - i = Docker::Image.import(source, {}, connection) - i.tag('repo' => repo, 'tag' => tag, 'force' => force) - end - end - - def pull_image - with_retries do - registry_host = parse_registry_host(repo) - creds = node.run_state['docker_auth'] && node.run_state['docker_auth'][registry_host] || (node.run_state['docker_auth'] ||= {})['index.docker.io'] - - original_image = Docker::Image.get(image_identifier, {}, connection) if Docker::Image.exist?(image_identifier, {}, connection) - new_image = Docker::Image.create({ 'fromImage' => image_identifier }, creds, connection) - - !(original_image && original_image.id.start_with?(new_image.id)) - end - end - - def push_image - with_retries do - i = Docker::Image.get(image_identifier, {}, connection) - i.push - end - end - - def remove_image - with_retries do - i = Docker::Image.get(image_identifier, {}, connection) - i.remove(force: force, noprune: noprune) - end - end - - def save_image - with_retries do - Docker::Image.save(repo, destination, connection) - end - end - - def load_image - with_retries do - Docker::Image.load(source, {}, connection) - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_installation_binary.rb b/vendor-cookbooks/docker/libraries/helpers_installation_binary.rb deleted file mode 100644 index 625c8dcd..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_installation_binary.rb +++ /dev/null @@ -1,66 +0,0 @@ -module DockerCookbook - module DockerHelpers - module InstallationBinary - def docker_bin - '/usr/bin/docker' - end - - def docker_kernel - node['kernel']['name'] - end - - def docker_arch - node['kernel']['machine'] - end - - def default_source - "https://get.docker.com/builds/#{docker_kernel}/#{docker_arch}/docker-#{version}" - end - - def default_checksum - case docker_kernel - when 'Darwin' - case version - when '1.6.0' then '9e960e925561b4ec2b81f52b6151cd129739c1f4fba91ce94bdc0333d7d98c38' - when '1.6.2' then 'f29b8b2185c291bd276f7cdac45a674f904e964426d5b969fda7b8ef6b8ab557' - when '1.7.0' then '1c8ee59249fdde401afebc9a079cb75d7674f03d2491789fb45c88020a8c5783' - when '1.7.1' then 'b8209b4382d0b4292c756dd055c12e5efacec2055d5900ac91efc8e81d317cf9' - when '1.8.1' then '0f5db35127cf14b57614ad7513296be600ddaa79182d8d118d095cb90c721e3a' - when '1.8.2' then 'cef593612752e5a50bd075931956075a534b293b7002892072397c3093fe11a6' - when '1.8.3' then 'b5a63a0e6fb393de8c3543c83433224796c7545901963ff3e3e9a41b1430c9cd' - when '1.9.0' then '91a8701e41a479def5371a333657c58c36478602e1f5eb1835457a3880232a2e' - when '1.9.1' then '8750ccc2098ec94ef7db110e0016ab02cfa47a1a76f0deb3faa50335b5ec0df9' - when '1.10.0' then 'f8dc0c7ef2a7efbe0e062017822066e55a40c752b9e92a636359f59ef562d79f' - when '1.10.1' then 'de4057057acd259ec38b5244a40d806993e2ca219e9869ace133fad0e09cedf2' - when '1.10.2' then '29249598587ad8f8597235bbeb11a11888fffb977b8089ea80b5ac5267ba9f2e' - end - when 'Linux' - case version - when '1.6.0' then '526fbd15dc6bcf2f24f99959d998d080136e290bbb017624a5a3821b63916ae8' - when '1.6.2' then 'e131b2d78d9f9e51b0e5ca8df632ac0a1d48bcba92036d0c839e371d6cf960ec' - when '1.7.1' then '4d535a62882f2123fb9545a5d140a6a2ccc7bfc7a3c0ec5361d33e498e4876d5' - when '1.8.1' then '843f90f5001e87d639df82441342e6d4c53886c65f72a5cc4765a7ba3ad4fc57' - when '1.8.2' then '97a3f5924b0b831a310efa8bf0a4c91956cd6387c4a8667d27e2b2dd3da67e4d' - when '1.8.3' then 'f024bc65c45a3778cf07213d26016075e8172de8f6e4b5702bedde06c241650f' - when '1.9.0' then '5d46455aac507e231fd2a558459779f1994f7151d6cb027efabfa36f568cf017' - when '1.9.1' then '52286a92999f003e1129422e78be3e1049f963be1888afc3c9a99d5a9af04666' - when '1.10.0' then 'a66b20423b7d849aa8ef448b98b41d18c45a30bf3fe952cc2ba4760600b18087' - when '1.10.1' then 'de4057057acd259ec38b5244a40d806993e2ca219e9869ace133fad0e09cedf2' - when '1.10.2' then '3fcac4f30e1c1a346c52ba33104175ae4ccbd9b9dbb947f56a0a32c9e401b768' - end - end - end - - def default_version - if node['platform'] == 'amazon' || - node['platform'] == 'ubuntu' && node['platform_version'].to_f < 15.04 || - node['platform_family'] == 'rhel' && node['platform_version'].to_i < 7 || - node['platform_family'] == 'debian' && node['platform_version'].to_i <= 7 - '1.6.2' - else - '1.10.2' - end - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_installation_package.rb b/vendor-cookbooks/docker/libraries/helpers_installation_package.rb deleted file mode 100644 index 4899f4b6..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_installation_package.rb +++ /dev/null @@ -1,94 +0,0 @@ -module DockerCookbook - module DockerHelpers - module InstallationPackage - def el6? - return true if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 6 - false - end - - def el7? - return true if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7 - false - end - - def fedora? - return true if node['platform'] == 'fedora' - false - end - - def wheezy? - return true if node['platform'] == 'debian' && node['platform_version'].to_i == 7 - false - end - - def jesse? - return true if node['platform'] == 'debian' && node['platform_version'].to_i == 8 - false - end - - def precise? - return true if node['platform'] == 'ubuntu' && node['platform_version'] == '12.04' - false - end - - def trusty? - return true if node['platform'] == 'ubuntu' && node['platform_version'] == '14.04' - return true if node['platform'] == 'linuxmint' && node['platform_version'] =~ /^17\.[0-9]$/ - false - end - - def vivid? - return true if node['platform'] == 'ubuntu' && node['platform_version'] == '15.04' - false - end - - def wily? - return true if node['platform'] == 'ubuntu' && node['platform_version'] == '15.10' - false - end - - def xenial? - return true if node['platform'] == 'ubuntu' && node['platform_version'] == '16.04' - false - end - - def amazon? - return true if node['platform'] == 'amazon' - false - end - - # https://github.com/chef/chef/issues/4103 - def version_string(v) - ubuntu_prefix = if Gem::Version.new(v) > Gem::Version.new('1.12.3') - 'ubuntu-' - else - '' - end - - return "#{v}-1.el6" if el6? - return "#{v}-1.el7.centos" if el7? - return "#{v}-1.el6" if amazon? - return "#{v}-1.fc#{node['platform_version'].to_i}" if fedora? - return "#{v}-0~wheezy" if wheezy? - return "#{v}-0~jessie" if jesse? - return "#{v}-0~#{ubuntu_prefix}precise" if precise? - return "#{v}-0~#{ubuntu_prefix}trusty" if trusty? - return "#{v}-0~#{ubuntu_prefix}vivid" if vivid? - return "#{v}-0~#{ubuntu_prefix}wily" if wily? - return "#{v}-0~#{ubuntu_prefix}xenial" if xenial? - v - end - - def default_docker_version - return '1.7.1' if el6? - return '1.7.1' if amazon? - return '1.9.1' if vivid? - '1.11.2' - end - - def docker_bin - '/usr/bin/docker' - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_installation_tarball.rb b/vendor-cookbooks/docker/libraries/helpers_installation_tarball.rb deleted file mode 100644 index dd3c27cd..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_installation_tarball.rb +++ /dev/null @@ -1,50 +0,0 @@ -module DockerCookbook - module DockerHelpers - module InstallationTarball - def docker_bin_prefix - '/usr/bin' - end - - def docker_bin - "#{docker_bin_prefix}/docker" - end - - def docker_tarball - "#{Chef::Config[:file_cache_path]}/docker-#{version}.tgz" - end - - def docker_kernel - node['kernel']['name'] - end - - def docker_arch - node['kernel']['machine'] - end - - def default_source - "https://get.docker.com/builds/#{docker_kernel}/#{docker_arch}/docker-#{version}.tgz" - end - - def default_checksum - case docker_kernel - when 'Darwin' - case version - when '1.11.0' then '25e4f5f37e2e17beb20e5a468674750350824059bdeeca09d6a941bca8fc4f73' - when '1.11.1' then '6d35487fbcc7e3f722f3d5f3e5c070a41d87c88e3770f52ae28460a689c40efd' - when '1.11.2' then 'f44da1025c355c51ae6e150fcc0672b87a738b9c8ad98e5fa6091502211da19a' - end - when 'Linux' - case version - when '1.11.0' then '87331b3b75d32d3de5d507db9a19a24dd30ff9b2eb6a5a9bdfaba954da15e16b' - when '1.11.1' then '893e3c6e89c0cd2c5f1e51ea41bc2dd97f5e791fcfa3cee28445df277836339d' - when '1.11.2' then '8c2e0c35e3cda11706f54b2d46c2521a6e9026a7b13c7d4b8ae1f3a706fc55e1' - end - end - end - - def default_version - '1.11.2' - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_network.rb b/vendor-cookbooks/docker/libraries/helpers_network.rb deleted file mode 100644 index b42ee246..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_network.rb +++ /dev/null @@ -1,118 +0,0 @@ -module DockerCookbook - module DockerHelpers - module Network - require 'ipaddr' - - ################### - # property coersion - ################### - - def coerce_auxiliary_addresses(v) - ray = [] - Array(v).each do |e| - case e - when String, Array, nil - ray += Array(e) - when Hash - e.each { |key, val| ray << "#{key}=#{val}" } - end - end - ray.length == 1 ? ray[0] : ray - end - - def coerce_gateway(v) - case v - when String - v.split('/')[0] - when Array - ray = Array(v).map { |a| a.split('/')[0] } - ray.length == 1 ? ray[0] : ray - end - end - - def coerce_subnet(v) - Array(v).length == 1 ? Array(v)[0] : v - end - - def coerce_ip_range(v) - Array(v).length == 1 ? Array(v)[0] : v - end - - ###### - # IPAM - ###### - - def consolidate_ipam(subnets, ranges, gateways, auxaddrs) - subnets = Array(subnets) - ranges = Array(ranges) - gateways = Array(gateways) - auxaddrs = Array(auxaddrs) - subnets = [] if subnets.empty? - ranges = [] if ranges.empty? - gateways = [] if gateways.empty? - auxaddrs = [] if auxaddrs.empty? - if subnets.size < ranges.size || subnets.size < gateways.size - raise 'every ip-range or gateway myust have a corresponding subnet' - end - - data = {} - - # Check overlapping subnets - subnets.each do |s| - data.each do |k, _| - if subnet_matches(s, k) || subnet_matches(k, s) - raise 'multiple overlapping subnet configuration is not supported' - end - end - data[s] = { 'Subnet' => s, 'AuxiliaryAddresses' => {} } - end - - ranges.each do |r| - match = false - subnets.each do |s| - ok = subnet_matches(s, r) - next unless ok - if data[s].fetch('IPRange', '') != '' - raise 'cannot configure multiple ranges on the same subnet' - end - data[s]['IPRange'] = r - match = true - end - raise "no matching subnet for range #{r}" unless match - end - - gateways.each do |g| - match = false - subnets.each do |s| - ok = subnet_matches(s, g) - next unless ok - unless data[s].fetch('Gateway', '').empty? - raise "cannot configure multiple gateways (#{g}, #{data[s]['Gateway']}) for the same subnet (#{s})" - end - data[s]['Gateway'] = g - match = true - end - raise "no matching subnet for gateway #{s}" unless match - end - - auxaddrs.each do |aa| - key, a = aa.split('=') - match = false - subnets.each do |s| - # require 'pry' ; binding.pry - ok = subnet_matches(s, a) - next unless ok - data[s]['AuxiliaryAddresses'][key] = a - match = true - end - raise "no matching subnet for aux-address #{a}" unless match - end - data.values - end - - def subnet_matches(subnet, data) - IPAddr.new(subnet).include?(IPAddr.new(data)) - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/helpers_service.rb b/vendor-cookbooks/docker/libraries/helpers_service.rb deleted file mode 100644 index 2eed5a22..00000000 --- a/vendor-cookbooks/docker/libraries/helpers_service.rb +++ /dev/null @@ -1,226 +0,0 @@ -# Constants -IPV6_ADDR ||= /( -([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}| -([0-9a-fA-F]{1,4}:){1,7}:| -([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}| -([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}| -([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}| -([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}| -([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}| -[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})| -:((:[0-9a-fA-F]{1,4}){1,7}|:)| -fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}| -::(ffff(:0{1,4}){0,1}:){0,1} -((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3} -(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])| -([0-9a-fA-F]{1,4}:){1,4}: -((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3} -(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]) -)/ - -IPV4_ADDR ||= /((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/ - -IPV6_CIDR ||= /s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*/ - -IPV4_CIDR ||= %r{(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))} - -module DockerCookbook - module DockerHelpers - module Service - def docker_bin - '/usr/bin/docker' - end - - def dockerd_bin - '/usr/bin/dockerd' - end - - def docker_name - return 'docker' if name == 'default' - "docker-#{name}" - end - - def docker_version - o = shell_out("#{docker_bin} --version") - o.stdout.split[2].chomp(',') - end - - def connect_host - return nil unless host - sorted = coerce_host(host).sort do |a, b| - c_a = 1 if a =~ /^unix:/ - c_a = 2 if a =~ /^fd:/ - c_a = 3 if a =~ %r{^tcp://127.0.0.1:} - c_a = 4 if a =~ %r{^tcp://(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.).*:} - c_a = 5 if a =~ %r{^tcp://0.0.0.0:} - c_a = 6 unless c_a - c_b = 1 if b =~ /^unix:/ - c_b = 2 if b =~ /^fd:/ - c_b = 3 if b =~ %r{^tcp://127.0.0.1:} - c_b = 4 if b =~ %r{^tcp://(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.).*:} - c_b = 5 if b =~ %r{^tcp://0.0.0.0:} - c_b = 6 unless c_b - c_a <=> c_b - end - if sorted.first =~ %r{^tcp://0.0.0.0:} - r = sorted.first.match(%r{(?.*)://(?[^:]+):?(?\d+)?}) - return "tcp://127.0.0.1:#{r['port']}" - end - sorted.first - end - - def connect_socket - return "/var/run/#{docker_name}.sock" unless host - sorted = coerce_host(host).sort do |a, b| - c_a = 1 if a =~ /^unix:/ - c_a = 2 if a =~ /^fd:/ - c_a = 3 unless c_a - c_b = 1 if b =~ /^unix:/ - c_b = 2 if b =~ /^fd:/ - c_b = 3 unless c_b - c_a <=> c_b - end - sorted.first - end - - def coerce_host(v) - v = v.split if v.is_a?(String) - Array(v).each_with_object([]) do |s, r| - if s.match(/^unix:/) || s.match(/^tcp:/) || s.match(/^fd:/) - r << s - else - Chef::Log.info("WARNING: docker_service host property #{s} not valid") - end - end - end - - def coerce_daemon_labels(v) - Array(v).each_with_object([]) do |label, a| - if label =~ /:/ - parts = label.split(':') - a << "#{parts[0]}=\"#{parts[1]}\"" - elsif label =~ /=/ - parts = label.split('=') - a << "#{parts[0]}=#{parts[1]}" - else - Chef::Log.info("WARNING: docker_service label #{label} not valid") - end - end - end - - def coerce_insecure_registry(v) - case v - when Array, nil - v - else - Array(v) - end - end - - def docker_major_version - ray = docker_version.split('.') - ray.pop - ray.push.join('.') - end - - def docker_daemon - if Gem::Version.new(docker_major_version) < Gem::Version.new('1.12') - docker_bin - else - dockerd_bin - end - end - - def docker_daemon_arg - if Gem::Version.new(docker_major_version) < Gem::Version.new('1.8') - '-d' - elsif Gem::Version.new(docker_major_version) < Gem::Version.new('1.12') - 'daemon' - else - '' - end - end - - def docker_daemon_cmd - [docker_daemon, docker_daemon_arg, docker_daemon_opts].join(' ') - end - - def docker_cmd - [docker_bin, docker_opts].join(' ') - end - - def docker_opts - opts = [] - opts << "--host=#{connect_host}" if connect_host - if connect_host =~ /^tcp:/ - opts << "--tls=#{tls}" unless tls.nil? - opts << "--tlsverify=#{tls_verify}" unless tls_verify.nil? - opts << "--tlscacert=#{tls_ca_cert}" if tls_ca_cert - opts << "--tlscert=#{tls_client_cert}" if tls_client_cert - opts << "--tlskey=#{tls_client_key}" if tls_client_key - end - opts - end - - def systemd_args - opts = '' - systemd_opts.each { |systemd_opt| opts << "#{systemd_opt}\n" } if systemd_opts - opts - end - - def docker_daemon_opts - opts = [] - opts << "--api-cors-header=#{api_cors_header}" if api_cors_header - opts << "--bridge=#{bridge}" if bridge - opts << "--bip=#{bip}" if bip - opts << '--debug' if debug - opts << "--cluster-advertise=#{cluster_advertise}" if cluster_advertise - opts << "--cluster-store=#{cluster_store}" if cluster_store - cluster_store_opts.each { |store_opt| opts << "--cluster-store-opt=#{store_opt}" } if cluster_store_opts - default_ulimit.each { |u| opts << "--default-ulimit=#{u}" } if default_ulimit - dns.each { |dns| opts << "--dns=#{dns}" } if dns - dns_search.each { |dns| opts << "--dns-search=#{dns}" } if dns_search - opts << "--exec-driver=#{exec_driver}" if exec_driver - exec_opts.each { |exec_opt| opts << "--exec-opt=#{exec_opt}" } if exec_opts - opts << "--fixed-cidr=#{fixed_cidr}" if fixed_cidr - opts << "--fixed-cidr-v6=#{fixed_cidr_v6}" if fixed_cidr_v6 - opts << "--group=#{group}" if group - opts << "--graph=#{graph}" if graph - host.each { |h| opts << "-H #{h}" } if host - opts << "--icc=#{icc}" unless icc.nil? - insecure_registry.each { |i| opts << "--insecure-registry=#{i}" } if insecure_registry - opts << "--ip=#{ip}" if ip - opts << "--ip-forward=#{ip_forward}" unless ip_forward.nil? - opts << "--ip-masq=#{ip_masq}" unless ip_masq.nil? - opts << "--iptables=#{iptables}" unless iptables.nil? - opts << "--ipv6=#{ipv6}" unless ipv6.nil? - opts << "--log-level=#{log_level}" if log_level - labels.each { |l| opts << "--label=#{l}" } if labels - opts << "--log-driver=#{log_driver}" if log_driver - log_opts.each { |log_opt| opts << "--log-opt #{log_opt}" } if log_opts - opts << "--mtu=#{mtu}" if mtu - opts << "--pidfile=#{pidfile}" if pidfile - opts << "--registry-mirror=#{registry_mirror}" if registry_mirror - storage_driver.each { |s| opts << "--storage-driver=#{s}" } if storage_driver - opts << "--selinux-enabled=#{selinux_enabled}" unless selinux_enabled.nil? - storage_opts.each { |storage_opt| opts << "--storage-opt=#{storage_opt}" } if storage_opts - opts << "--tls=#{tls}" unless tls.nil? - opts << "--tlsverify=#{tls_verify}" unless tls_verify.nil? - opts << "--tlscacert=#{tls_ca_cert}" if tls_ca_cert - opts << "--tlscert=#{tls_server_cert}" if tls_server_cert - opts << "--tlskey=#{tls_server_key}" if tls_server_key - opts << "--userland-proxy=#{userland_proxy}" unless userland_proxy.nil? - opts << "--disable-legacy-registry=#{disable_legacy_registry}" unless disable_legacy_registry.nil? - opts << "--userns-remap=#{userns_remap}" if userns_remap - opts << misc_opts if misc_opts - opts - end - - def docker_running? - o = shell_out("#{docker_cmd} ps | head -n 1 | grep ^CONTAINER") - return true if o.stdout =~ /CONTAINER/ - false - end - end - end -end diff --git a/vendor-cookbooks/docker/libraries/matchers.rb b/vendor-cookbooks/docker/libraries/matchers.rb deleted file mode 100644 index 87cb23d9..00000000 --- a/vendor-cookbooks/docker/libraries/matchers.rb +++ /dev/null @@ -1,339 +0,0 @@ -if defined?(ChefSpec) - ##################### - # docker_installation - ##################### - ChefSpec.define_matcher :docker_installation - - def create_docker_installation(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation, :create, resource_name) - end - - def delete_docker_installation(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation, :delete, resource_name) - end - - def create_docker_installation_binary(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_binary, :create, resource_name) - end - - def delete_docker_installation_binary(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_binary, :delete, resource_name) - end - - def create_docker_installation_script(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_script, :create, resource_name) - end - - def delete_docker_installation_script(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_script, :delete, resource_name) - end - - def create_docker_installation_package(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_package, :create, resource_name) - end - - def delete_docker_installation_package(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_package, :delete, resource_name) - end - - def create_docker_installation_tarball(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_tarball, :create, resource_name) - end - - def delete_docker_installation_tarball(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_tarball, :delete, resource_name) - end - - ################ - # docker_service - ################ - ChefSpec.define_matcher :docker_service - - def create_docker_service(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service, :create, resource_name) - end - - def delete_docker_service(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service, :delete, resource_name) - end - - def start_docker_service(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service, :start, resource_name) - end - - def stop_docker_service(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service, :stop, resource_name) - end - - def restart_docker_service(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service, :restart, resource_name) - end - - ######################## - # docker_service_manager - ######################## - ChefSpec.define_matcher :docker_service_manager - - def create_docker_service_manager(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager, :create, resource_name) - end - - def delete_docker_service_manager(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager, :delete, resource_name) - end - - def start_docker_service_manager(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager, :start, resource_name) - end - - def stop_docker_service_manager(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager, :stop, resource_name) - end - - def restart_docker_service_manager(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager, :restart, resource_name) - end - - def create_docker_service_manager_execute(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_execute, :create, resource_name) - end - - def delete_docker_service_manager_execute(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_execute, :delete, resource_name) - end - - def start_docker_service_manager_execute(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_execute, :start, resource_name) - end - - def stop_docker_service_manager_execute(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_execute, :stop, resource_name) - end - - def restart_docker_service_manager_execute(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_execute, :restart, resource_name) - end - - def create_docker_service_manager_sysvinit(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_sysvinit, :create, resource_name) - end - - def delete_docker_service_manager_sysvinit(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_sysvinit, :delete, resource_name) - end - - def start_docker_service_manager_sysvinit(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_sysvinit, :start, resource_name) - end - - def stop_docker_service_manager_sysvinit(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_sysvinit, :stop, resource_name) - end - - def restart_docker_service_manager_sysvinit(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_sysvinit, :restart, resource_name) - end - - def create_docker_service_manager_upstart(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_upstart, :create, resource_name) - end - - def delete_docker_service_manager_upstart(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_upstart, :delete, resource_name) - end - - def start_docker_service_manager_upstart(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_upstart, :start, resource_name) - end - - def stop_docker_service_manager_upstart(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_upstart, :stop, resource_name) - end - - def restart_docker_service_manager_upstart(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_upstart, :restart, resource_name) - end - - def create_docker_service_manager_systemd(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_systemd, :create, resource_name) - end - - def delete_docker_service_manager_systemd(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_systemd, :delete, resource_name) - end - - def start_docker_service_manager_systemd(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_systemd, :start, resource_name) - end - - def stop_docker_service_manager_systemd(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_systemd, :stop, resource_name) - end - - def restart_docker_service_manager_systemd(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_service_manager_systemd, :restart, resource_name) - end - - ############## - # docker_image - ############## - ChefSpec.define_matcher :docker_image - - def build_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :build, resource_name) - end - - def build_if_missing_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :build_if_missing, resource_name) - end - - def pull_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :pull, resource_name) - end - - def pull_if_missing_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :pull_if_missing, resource_name) - end - - def import_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :import, resource_name) - end - - def push_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :push, resource_name) - end - - def remove_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :remove, resource_name) - end - - def save_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :save, resource_name) - end - - def load_docker_image(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_image, :load, resource_name) - end - - ################## - # docker_container - ################## - ChefSpec.define_matcher :docker_container - - def create_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :create, resource_name) - end - - def start_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :start, resource_name) - end - - def stop_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :stop, resource_name) - end - - def kill_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :kill, resource_name) - end - - def run_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :run, resource_name) - end - - def run_if_missing_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :run_if_missing, resource_name) - end - - def pause_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :pause, resource_name) - end - - def unpause_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :unpause, resource_name) - end - - def restart_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :restart, resource_name) - end - - def redeploy_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :redeploy, resource_name) - end - - def delete_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :delete, resource_name) - end - - def remove_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :remove, resource_name) - end - - def commit_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :commit, resource_name) - end - - def export_docker_container(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_container, :export, resource_name) - end - - ############## - # docker_tag - ############## - ChefSpec.define_matcher :docker_tag - - def tag_docker_tag(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_tag, :tag, resource_name) - end - - ################# - # docker_registry - ################# - ChefSpec.define_matcher :docker_registry - - def login_docker_registry(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_registry, :login, resource_name) - end - - ################ - # docker_network - ################ - ChefSpec.define_matcher :docker_network - - def create_docker_network(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_network, :create, resource_name) - end - - def delete_docker_network(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_network, :delete, resource_name) - end - - def connect_docker_network(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_network, :connect, resource_name) - end - - def disconnect_docker_network(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_network, :disconnect, resource_name) - end - - ############### - # docker_volume - ############### - ChefSpec.define_matcher :docker_volume - - def create_docker_volume(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_volume, :create, resource_name) - end - - def remove_docker_volume(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_volume, :remove, resource_name) - end - - ############### - # docker_exec - ############### - ChefSpec.define_matcher :docker_exec - - def run_docker_exec(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:docker_exec, :run, resource_name) - end -end diff --git a/vendor-cookbooks/docker/metadata.json b/vendor-cookbooks/docker/metadata.json deleted file mode 100644 index 09bd3d2e..00000000 --- a/vendor-cookbooks/docker/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"docker","version":"2.13.10","description":"Provides docker_service, docker_image, and docker_container resources","long_description":"","maintainer":"Cookbook Engineering Team","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0","debian":">= 0.0.0","fedora":">= 0.0.0","redhat":">= 0.0.0","ubuntu":">= 0.0.0"},"dependencies":{"compat_resource":">= 12.16.2"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} \ No newline at end of file diff --git a/vendor-cookbooks/docker/templates/default/default/docker-wait-ready.erb b/vendor-cookbooks/docker/templates/default/default/docker-wait-ready.erb deleted file mode 100644 index 35312215..00000000 --- a/vendor-cookbooks/docker/templates/default/default/docker-wait-ready.erb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -i=0 -while [ $i -lt <%= @service_timeout * 2 %> ]; do - <%= @docker_cmd %> ps | head -n 1 | grep ^CONTAINER > /dev/null 2>&1 - [ $? -eq 0 ] && break - ((i++)) - sleep 0.5 -done -[ $i -eq <%= @service_timeout * 2 %> ] && exit 1 -exit 0 diff --git a/vendor-cookbooks/docker/templates/default/default/docker.erb b/vendor-cookbooks/docker/templates/default/default/docker.erb deleted file mode 100644 index f683bb18..00000000 --- a/vendor-cookbooks/docker/templates/default/default/docker.erb +++ /dev/null @@ -1,24 +0,0 @@ -# Docker Upstart and SysVinit configuration file - -# Customize location of Docker binary (especially for development testing). -DOCKER="<%= @docker_daemon %>" - -# Use DOCKER_OPTS to modify the daemon startup options. -DOCKER_OPTS="<%= @docker_daemon_opts %>" - -# If you need Docker to use an HTTP proxy, it can also be specified here. -<% if @config.http_proxy %> -export http_proxy="<%= @config.http_proxy %>" -<% end %> -<% if @config.https_proxy %> -export https_proxy="<%= @config.https_proxy %>" -<% end %> - -<% if @config.no_proxy %> -export no_proxy="<%= @config.no_proxy %>" -<% end %> - -# This is also a handy place to tweak where Docker's temporary files go. -<% if @config.tmpdir %> -export TMPDIR="<%= @config.tmpdir %>" -<% end %> diff --git a/vendor-cookbooks/docker/templates/default/sysconfig/docker.erb b/vendor-cookbooks/docker/templates/default/sysconfig/docker.erb deleted file mode 100644 index b1322407..00000000 --- a/vendor-cookbooks/docker/templates/default/sysconfig/docker.erb +++ /dev/null @@ -1,19 +0,0 @@ -# /etc/sysconfig/docker -# -# Other arguments to pass to the docker daemon process -# These will be parsed by the sysv initscript and appended -# to the arguments list passed to docker - -other_args="<%= @docker_daemon_opts %>" - -# If you need Docker to use an HTTP proxy, it can also be specified here. -<% if @config.http_proxy %> -export http_proxy="<%= @config.http_proxy %>" -<% end %> -<% if @config.https_proxy %> -export https_proxy="<%= @config.https_proxy %>" -<% end %> - -<% if @config.no_proxy %> -export no_proxy="<%= @config.no_proxy %>" -<% end %> diff --git a/vendor-cookbooks/docker/templates/default/systemd/docker.service-override.erb b/vendor-cookbooks/docker/templates/default/systemd/docker.service-override.erb deleted file mode 100644 index 8c0f83ea..00000000 --- a/vendor-cookbooks/docker/templates/default/systemd/docker.service-override.erb +++ /dev/null @@ -1,36 +0,0 @@ -[Unit] -Description=Docker Application Container Engine -Documentation=http://docs.docker.com -After=network.target - -[Service] -Type=notify -<% if @config.http_proxy %> -Environment="HTTP_PROXY=<%= @config.http_proxy %>" -<% end %> -<% if @config.https_proxy %> -Environment="HTTPS_PROXY=<%= @config.https_proxy %>" -<% end %> -<% if @config.no_proxy %> -Environment="NO_PROXY=<%= @config.no_proxy %>" -<% end %> -<% if @config.tmpdir %> -Environment="TMPDIR=<%= @config.tmpdir %>" -<% end %> -<% if @config.ipv4_forward %> -ExecStartPre=/sbin/sysctl -w net.ipv4.ip_forward=1 -<% end %> -<% if @config.ipv6_forward %> -ExecStartPre=/sbin/sysctl -w net.ipv6.conf.all.forwarding=1 -<% end %> -ExecStart=<%= @docker_daemon_cmd %> -ExecStartPost=<%= @docker_wait_ready %> -Restart=always -MountFlags=<%= @docker_mount_flags %> -LimitNOFILE=1048576 -LimitNPROC=1048576 -LimitCORE=infinity -<%= @systemd_args %> - -[Install] -WantedBy=multi-user.target diff --git a/vendor-cookbooks/docker/templates/default/systemd/docker.service.erb b/vendor-cookbooks/docker/templates/default/systemd/docker.service.erb deleted file mode 100644 index 5c924d8a..00000000 --- a/vendor-cookbooks/docker/templates/default/systemd/docker.service.erb +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=Docker Application Container Engine -Documentation=https://docs.docker.com -After=network.target <%= @docker_name %>.socket -Requires=<%= @docker_name %>.socket - -[Service] -Type=notify -ExecStart=/usr/bin/docker daemon -H fd:// -MountFlags=<%= @docker_mount_flags %> -LimitNOFILE=1048576 -LimitNPROC=1048576 -LimitCORE=infinity -TasksMax=1048576 -TimeoutStartSec=0 - -[Install] -WantedBy=multi-user.target diff --git a/vendor-cookbooks/docker/templates/default/systemd/docker.socket-override.erb b/vendor-cookbooks/docker/templates/default/systemd/docker.socket-override.erb deleted file mode 100644 index 7e6b7050..00000000 --- a/vendor-cookbooks/docker/templates/default/systemd/docker.socket-override.erb +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Docker Socket for the API -PartOf=<%= @docker_name %>.service - -[Socket] -ListenStream=<%= @docker_socket %> -SocketMode=0660 -SocketUser=root -SocketGroup=<%= @config.group %> - -[Install] -WantedBy=sockets.target diff --git a/vendor-cookbooks/docker/templates/default/systemd/docker.socket.erb b/vendor-cookbooks/docker/templates/default/systemd/docker.socket.erb deleted file mode 100644 index 22b452d9..00000000 --- a/vendor-cookbooks/docker/templates/default/systemd/docker.socket.erb +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Docker Socket for the API -PartOf=<%= @docker_name %>.service - -[Socket] -ListenStream=<%= @docker_socket %> -SocketMode=0660 -SocketUser=root -SocketGroup=docker - -[Install] -WantedBy=sockets.target diff --git a/vendor-cookbooks/docker/templates/default/systemd/tmpfiles.d.conf.erb b/vendor-cookbooks/docker/templates/default/systemd/tmpfiles.d.conf.erb deleted file mode 100644 index a77e3fd8..00000000 --- a/vendor-cookbooks/docker/templates/default/systemd/tmpfiles.d.conf.erb +++ /dev/null @@ -1 +0,0 @@ -d /var/run/docker 0755 root <%= @config.group || 'root' %> - diff --git a/vendor-cookbooks/docker/templates/default/sysvinit/docker-debian.erb b/vendor-cookbooks/docker/templates/default/sysvinit/docker-debian.erb deleted file mode 100644 index 88f87159..00000000 --- a/vendor-cookbooks/docker/templates/default/sysvinit/docker-debian.erb +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/sh -set -e - -### BEGIN INIT INFO -# Provides: <%= @docker_name %> -# Required-Start: $syslog $remote_fs -# Required-Stop: $syslog $remote_fs -# Should-Start: cgroupfs-mount cgroup-lite -# Should-Stop: cgroupfs-mount cgroup-lite -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Create lightweight, portable, self-sufficient containers. -# Description: -# Docker is an open-source project to easily create lightweight, portable, -# self-sufficient containers from any application. The same container that a -# developer builds and tests on a laptop can run at scale, in production, on -# VMs, bare metal, OpenStack clusters, public clouds and more. -### END INIT INFO - -export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin - -BASE=<%= @docker_name %> - -# modify these in /etc/default/$BASE (/etc/default/docker) -DOCKER=/usr/bin/$BASE -# This is the pid file managed by docker itself -DOCKER_PIDFILE=/var/run/$BASE.pid -# This is the pid file created/managed by start-stop-daemon -DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid -DOCKER_LOGFILE=/var/log/$BASE.log -DOCKER_OPTS= -DOCKER_DESC="Docker" - -# Get lsb functions -. /lib/lsb/init-functions - -if [ -f /etc/default/$BASE ]; then - . /etc/default/$BASE -fi - -# Check docker is present -if [ ! -x $DOCKER ]; then - log_failure_msg "$DOCKER not present or not executable" - exit 1 -fi - -check_init() { - # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly) - if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then - log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1" - exit 1 - fi -} - -fail_unless_root() { - if [ "$(id -u)" != '0' ]; then - log_failure_msg "$DOCKER_DESC must be run as root" - exit 1 - fi -} - -cgroupfs_mount() { - # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount - if grep -v '^#' /etc/fstab | grep -q cgroup \ - || [ ! -e /proc/cgroups ] \ - || [ ! -d /sys/fs/cgroup ]; then - return - fi - if ! mountpoint -q /sys/fs/cgroup; then - mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup - fi - ( - cd /sys/fs/cgroup - for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do - mkdir -p $sys - if ! mountpoint -q $sys; then - if ! mount -n -t cgroup -o $sys cgroup $sys; then - rmdir $sys || true - fi - fi - done - ) -} - -case "$1" in - start) - check_init - - fail_unless_root - - cgroupfs_mount - - touch "$DOCKER_LOGFILE" - chgrp docker "$DOCKER_LOGFILE" - - ulimit -n 1048576 - if [ "$BASH" ]; then - ulimit -u 1048576 - else - ulimit -p 1048576 - fi - - log_begin_msg "Starting $DOCKER_DESC: $BASE" - start-stop-daemon --start --background \ - --no-close \ - --exec "$DOCKER" \ - --pidfile "$DOCKER_SSD_PIDFILE" \ - --make-pidfile \ - -- \ - daemon -p "$DOCKER_PIDFILE" \ - $DOCKER_OPTS \ - >> "$DOCKER_LOGFILE" 2>&1 - <%= @docker_wait_ready %> - log_end_msg $? - ;; - - stop) - check_init - fail_unless_root - log_begin_msg "Stopping $DOCKER_DESC: $BASE" - start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE" --retry 10 - log_end_msg $? - ;; - - restart) - check_init - fail_unless_root - docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null` - [ -n "$docker_pid" ] \ - && ps -p $docker_pid > /dev/null 2>&1 \ - && $0 stop - $0 start - ;; - - force-reload) - check_init - fail_unless_root - $0 restart - ;; - - status) - check_init - status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKER" "$DOCKER_DESC" - ;; - - *) - echo "Usage: service docker {start|stop|restart|status}" - exit 1 - ;; -esac diff --git a/vendor-cookbooks/docker/templates/default/sysvinit/docker-rhel.erb b/vendor-cookbooks/docker/templates/default/sysvinit/docker-rhel.erb deleted file mode 100644 index 6134447b..00000000 --- a/vendor-cookbooks/docker/templates/default/sysvinit/docker-rhel.erb +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/sh -# -# /etc/rc.d/init.d/docker -# -# Daemon for docker.com -# -# chkconfig: 2345 95 95 -# description: Daemon for docker.com - -### BEGIN INIT INFO -# Provides: docker -# Required-Start: $network cgconfig -# Required-Stop: -# Should-Start: -# Should-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start and stop docker -# Description: Daemon for docker.com -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -prog="<%= @docker_name %>" -unshare=/usr/bin/unshare -exec="/usr/bin/$prog" -pidfile="/var/run/$prog.pid" -lockfile="/var/lock/subsys/$prog" -logfile="/var/log/$prog" - -[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog - -prestart() { - service cgconfig status > /dev/null - - if [[ $? != 0 ]]; then - service cgconfig start - fi - -} - -start() { - [ -x $exec ] || exit 5 - - check_for_cleanup - - if ! [ -f $pidfile ]; then - prestart - printf "Starting $prog:\t" - echo "\n$(date)\n" >> $logfile - "$unshare" -m -- $exec <%= @docker_daemon_arg %> $other_args &>> $logfile & - <%= @docker_wait_ready %> - [ $? -eq 0 ] && success || failure - echo - else - failure - echo - printf "$pidfile still exists...\n" - exit 7 - fi -} - -stop() { - echo -n $"Stopping $prog: " - killproc -p $pidfile -d 300 $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - status -p $pidfile $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -check_for_cleanup() { - if [ -f ${pidfile} ]; then - /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile} - fi -} - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac - -exit $? diff --git a/vendor-cookbooks/docker/templates/default/upstart/docker.conf.erb b/vendor-cookbooks/docker/templates/default/upstart/docker.conf.erb deleted file mode 100644 index b5c188f4..00000000 --- a/vendor-cookbooks/docker/templates/default/upstart/docker.conf.erb +++ /dev/null @@ -1,57 +0,0 @@ -description "Docker daemon" - -start on (filesystem and net-device-up IFACE!=lo) -stop on runlevel [!2345] -limit nofile 524288 1048576 -limit nproc 524288 1048576 - -respawn - -kill timeout 20 - -pre-start script - # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount - if grep -v '^#' /etc/fstab | grep -q cgroup \ - || [ ! -e /proc/cgroups ] \ - || [ ! -d /sys/fs/cgroup ]; then - exit 0 - fi - if ! mountpoint -q /sys/fs/cgroup; then - mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup - fi - ( - cd /sys/fs/cgroup - for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do - mkdir -p $sys - if ! mountpoint -q $sys; then - if ! mount -n -t cgroup -o $sys cgroup $sys; then - rmdir $sys || true - fi - fi - done - ) -end script - -script - # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) - DOCKER=/usr/bin/dockerd - DOCKER_OPTS= - if [ -f /etc/default/$UPSTART_JOB ]; then - . /etc/default/$UPSTART_JOB - fi - exec "$DOCKER" <%= @docker_daemon_arg %> $DOCKER_OPTS --raw-logs -end script - -post-start script - DOCKER_OPTS= - if [ -f /etc/default/$UPSTART_JOB ]; then - . /etc/default/$UPSTART_JOB - fi - <%= @docker_wait_ready %> - if [ $? -eq 0 ]; then - echo "<%= @docker_socket %> is up" - else - echo "<%= @docker_socket %> failed to come start" - exit 1 - fi -end script diff --git a/vendor-cookbooks/docker_compose/HISTORY.md b/vendor-cookbooks/docker_compose/HISTORY.md deleted file mode 100644 index 8983e3fe..00000000 --- a/vendor-cookbooks/docker_compose/HISTORY.md +++ /dev/null @@ -1,14 +0,0 @@ -# Release History - -## vNEXT - -## v0.1.1 - -* Added support for docker-compose's --remove-orphans parameter. -* The cookbook is now compatible with CentOS. -* Improved cookbook documentation. - -## v0.1.0 - -* Initial release. - diff --git a/vendor-cookbooks/docker_compose/LICENSE b/vendor-cookbooks/docker_compose/LICENSE deleted file mode 100644 index 8dada3ed..00000000 --- a/vendor-cookbooks/docker_compose/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - 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. diff --git a/vendor-cookbooks/docker_compose/README.md b/vendor-cookbooks/docker_compose/README.md deleted file mode 100644 index 7df1604e..00000000 --- a/vendor-cookbooks/docker_compose/README.md +++ /dev/null @@ -1,144 +0,0 @@ -# Docker Compose Cookbook - -The Docker Compose Cookbook is a library cookbook that provides custom -resources for use in recipes. - - -## Requirements - -- Working Docker installation. You might want to use the excellent -[docker Cookbook](https://supermarket.chef.io/cookbooks/docker) to provision -Docker. - - -## Usage - -Place a dependency on the docker-compose cookbook in your cookbook's -metadata.rb - -```ruby -depends 'docker_compose', '~> 0.0' -``` - -Create a [Docker Compose file](https://docs.docker.com/compose/compose-file/) -for the application you want to provision. A simple Compose file that uses the -[official nginx Docker image](https://hub.docker.com/_/nginx/) looks like this: - -``` -version: '2' -services: - web_server: - image: nginx - ports: - - "80:80" -``` - -Then, in a recipe: - -```ruby -include_recipe 'docker_compose::installation' - -# Provision Compose file -cookbook_file '/etc/docker-compose_nginx.yml' do - source 'docker-compose_nginx.yml' - owner 'root' - group 'root' - mode 0640 - notifies :up, 'docker_compose_application[nginx]', :delayed -end - -# Provision Compose application -docker_compose_application 'nginx' do - action :up - compose_files [ '/etc/docker-compose_nginx.yml' ] -end -``` - -## Attributes - -- `node['docker_compose']['release']` - The release version of Docker Compose - to install. Defaults to a sane, current default. - -- `node['docker_compose']['command_path']` - The path under which the - `docker-compose` command should be installed. - Defaults to `/usr/local/bin/docker-compose` - - -## Recipes - -### default - -The `default` recipe is simply an alias for the `installation` recipe. - -### installation - -The `installation` recipe installs the `docker-compose` binary by downloading -it from the vendor's servers, as described in the -[official Docker Compose documentation](https://docs.docker.com/compose/install/). - -The path to which the `docker-compose` command is installed can be configured -via the `node['docker_compose']['command_path']` attribute. - - -## Resources - -### docker_compose_application - -The `docker_compose_application` provisions a Docker application (that usually -consists of several services) using a Docker Compose file. - -#### Example - -```ruby -docker_compose_application 'nginx' do - action :up - compose_files [ '/etc/docker-compose_nginx.yml', '/etc/docker-compose_nginx.additional.yml' ] -end -``` - -#### Parameters - -- `project_name` - A string to identify the Docker Compose application. - Defaults to the resource name. - -- `compose_files` - The list of Compose files that makes up the Docker Compose - application. The specified file names are passed to the `docker-compose` - command in the order in which they appear in the list. - -- `remove_orphans` - Remove containers for services not defined in the - Compose file - -#### Actions - -- `:up` - Create and start containers. - Equivalent to calling `docker-compose up` with the Compose files specified - using the `compose_files` parameter. - -- `:down` - Stop and remove containers, networks, images, and volumes. - Equivalent to calling `docker-compose down` with the Compose files specified - using the `compose_files` parameter. - - -## License & Authors - -### Authors - -- Sebastian Boschert () - -### License - -Copyright (c) 2016 Sebastian Boschert. - -``` -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. -``` diff --git a/vendor-cookbooks/docker_compose/attributes/default.rb b/vendor-cookbooks/docker_compose/attributes/default.rb deleted file mode 100644 index b0380e11..00000000 --- a/vendor-cookbooks/docker_compose/attributes/default.rb +++ /dev/null @@ -1,2 +0,0 @@ -default['docker_compose']['release'] = '1.8.0' -default['docker_compose']['command_path'] = '/usr/local/bin/docker-compose' \ No newline at end of file diff --git a/vendor-cookbooks/docker_compose/chefignore b/vendor-cookbooks/docker_compose/chefignore deleted file mode 100644 index a9769175..00000000 --- a/vendor-cookbooks/docker_compose/chefignore +++ /dev/null @@ -1,102 +0,0 @@ -# Put files/directories that should be ignored in this file when uploading -# to a chef-server or supermarket. -# Lines that start with '# ' are comments. - -# OS generated files # -###################### -.DS_Store -Icon? -nohup.out -ehthumbs.db -Thumbs.db - -# SASS # -######## -.sass-cache - -# EDITORS # -########### -\#* -.#* -*~ -*.sw[a-z] -*.bak -REVISION -TAGS* -tmtags -*_flymake.* -*_flymake -*.tmproj -.project -.settings -mkmf.log - -## COMPILED ## -############## -a.out -*.o -*.pyc -*.so -*.com -*.class -*.dll -*.exe -*/rdoc/ - -# Testing # -########### -.watchr -.rspec -spec/* -spec/fixtures/* -test/* -features/* -examples/* -Guardfile -Procfile -.kitchen* -.rubocop.yml -spec/* -Rakefile -.travis.yml -.foodcritic -.codeclimate.yml - -# SCM # -####### -.git -*/.git -.gitignore -.gitmodules -.gitconfig -.gitattributes -.svn -*/.bzr/* -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Cookbooks # -############# -CONTRIBUTING* -CHANGELOG* -TESTING* -MAINTAINERS.toml - -# Strainer # -############ -Colanderfile -Strainerfile -.colander -.strainer - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/vendor-cookbooks/docker_compose/metadata.json b/vendor-cookbooks/docker_compose/metadata.json deleted file mode 100644 index 4528803d..00000000 --- a/vendor-cookbooks/docker_compose/metadata.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "docker_compose", - "description": "Installs docker_compose and provides the docker_compose_application resource.", - "long_description": "Installs docker_compose and provides the docker_compose_application resource.", - "maintainer": "Sebastian Boschert", - "maintainer_email": "sebastian@2007.org", - "license": "Apache v2.0", - "platforms": { - "debian": ">= 0.0.0", - "ubuntu": ">= 0.0.0", - "redhat": ">= 0.0.0", - "centos": ">= 0.0.0" - }, - "dependencies": { - - }, - "recommendations": { - - }, - "suggestions": { - - }, - "conflicting": { - - }, - "providing": { - - }, - "replacing": { - - }, - "attributes": { - - }, - "groupings": { - - }, - "recipes": { - - }, - "version": "0.1.1", - "source_url": "https://github.com/sboschert/chef-cookbook-docker_compose", - "issues_url": "https://github.com/sboschert/chef-cookbook-docker_compose/issues", - "privacy": false, - "chef_versions": [ - [ - ">= 12" - ] - ], - "ohai_versions": [ - - ], - "gems": [ - - ] -} diff --git a/vendor-cookbooks/docker_compose/recipes/default.rb b/vendor-cookbooks/docker_compose/recipes/default.rb deleted file mode 100644 index 559b3a6d..00000000 --- a/vendor-cookbooks/docker_compose/recipes/default.rb +++ /dev/null @@ -1,7 +0,0 @@ -# -# Cookbook Name:: docker_compose -# Recipe:: default -# -# Copyright (c) 2016 Sebastian Boschert, All Rights Reserved. - -include_recipe 'docker_compose::default' \ No newline at end of file diff --git a/vendor-cookbooks/docker_compose/recipes/installation.rb b/vendor-cookbooks/docker_compose/recipes/installation.rb deleted file mode 100644 index 04a62f98..00000000 --- a/vendor-cookbooks/docker_compose/recipes/installation.rb +++ /dev/null @@ -1,35 +0,0 @@ -# -# Cookbook Name:: docker_compose -# Recipe:: installation -# -# Copyright (c) 2016 Sebastian Boschert, All Rights Reserved. - -def get_install_url - release = node['docker_compose']['release'] - kernel_name = node['kernel']['name'] - machine_hw_name = node['kernel']['machine'] - "https://github.com/docker/compose/releases/download/#{release}/docker-compose-#{kernel_name}-#{machine_hw_name}" -end - -command_path = node['docker_compose']['command_path'] -install_url = get_install_url - -package 'curl' do - action :install -end - -directory '/etc/docker-compose' do - action :create - owner 'root' - group 'docker' - mode '0750' -end - -execute 'install docker-compose' do - action :run - command "curl -sSL #{install_url} > #{command_path} && chmod +x #{command_path}" - creates command_path - user 'root' - group 'docker' - umask '0027' -end diff --git a/vendor-cookbooks/docker_compose/resources/application.rb b/vendor-cookbooks/docker_compose/resources/application.rb deleted file mode 100644 index f89960ed..00000000 --- a/vendor-cookbooks/docker_compose/resources/application.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# Cookbook Name:: docker_compose -# Resource:: application -# -# Copyright (c) 2016 Sebastian Boschert, All Rights Reserved. - -property :project_name, kind_of: String, name_property: true -property :compose_files, kind_of: Array, required: true -property :remove_orphans, kind_of: [TrueClass, FalseClass], default: false - -default_action :up - -def get_compose_params - "-p #{project_name}" + - ' -f ' + compose_files.join(' -f ') -end - -def get_up_params - '-d' + - (remove_orphans ? ' --remove-orphans' : '') -end - -def get_down_params - (remove_orphans ? ' --remove-orphans' : '') -end - -action :up do - execute "running docker-compose up for project #{project_name}" do - command "docker-compose #{get_compose_params} up #{get_up_params}" - user 'root' - group 'root' - end -end - - -action :down do - execute "running docker-compose down for project #{project_name}" do - command "docker-compose #{get_compose_params} down #{get_down_params}" - user 'root' - group 'root' - end -end diff --git a/vendor-cookbooks/magic_shell/CHANGELOG.md b/vendor-cookbooks/magic_shell/CHANGELOG.md deleted file mode 100644 index 2d292da3..00000000 --- a/vendor-cookbooks/magic_shell/CHANGELOG.md +++ /dev/null @@ -1,61 +0,0 @@ -magic_shell CHANGELOG -===================== - -1.0.0 ------ -* Refactor providers to support whyrun mode -* Package custom ChefSpec matchers -* Add Test Kitchen integration test -* Update ChefSpec tests -* Expand environment variables (like `$PATH`) -* Add Rakefile for running tests -* Use the latest and greatest testing strategies - -0.3.1, 0.3.2 ------------- - -* **No changes** - chefigonre with `knife cookbook site share` was being ignored, so unnecessary artifacts were uploaded - -0.3.0 ----- - -* Full test suite -* Test with strainer -* Support for cross-Chef version default_action - -0.2.0 ----- - -* Add `magic_shell_environment` - -0.1.5 ----- - -* The default action for the alias resource is now :add - -0.1.4 ------ - -* The default action for the alias resource is now :create -* Formatting changes to the metadata, README, and CHANGELOG - -0.1.3 ------ - -* Address FC0016 - specify a default action -* Add integration with Travis CI - -0.1.2 ------ - -* Update the README to indicate that you need to specify an action (:add or :remove) - -0.1.1 ------ - -* Rename the resource and provider files - -0.1.0 ------ - -* Initial release of magic_shell diff --git a/vendor-cookbooks/magic_shell/README.md b/vendor-cookbooks/magic_shell/README.md deleted file mode 100644 index f10339e7..00000000 --- a/vendor-cookbooks/magic_shell/README.md +++ /dev/null @@ -1,78 +0,0 @@ -magic_shell Cookbook -==================== -[![Build Status](https://secure.travis-ci.org/customink-webops/magic_shell.png)](http://travis-ci.org/customink-webops/magic_shell) - -Provides utility for adding some syntactic sugar to your shell. - -Usage ------ -Update the `metadata.rb` for your cookbook to depend on magic_shell - -```ruby -depends 'magic_shell' -``` - -Use the `magic_shell_alias` resource to create a command alias. - -```ruby -magic_shell_alias 'myrailsapp' do - command 'cd /opt/myrailsapp/current' -end -``` - -This will alias `myrailsapp` to `cd /opt/myrailsapp/current`. - -You can also remove aliases: - -```ruby -magic_shell_alias 'myrailsapp' do - action :remove -end -``` - -Use the `magic_shell_environment` resource to create a shell environment variable. - -```ruby -magic_shell_environment 'EDITOR' do - value 'vim' -end -``` - -This will export an `EDITOR` environment variable with a value of `vim`. - -You can also remove environment variables: - -```ruby -magic_shell_environment 'EDITOR' do - action :remove -end -``` - -Contributing ------------- -1. Fork the repo -2. Create a feature branch -3. Code, document, write specs, test -4. Submit a PR - - -License & Authors ------------------ -- Author: Nathen Harvey -- Author: Seth Vargo - -```text -Copyright 2012-2014 CustomInk, LLC. - -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. -``` diff --git a/vendor-cookbooks/magic_shell/libraries/matchers.rb b/vendor-cookbooks/magic_shell/libraries/matchers.rb deleted file mode 100644 index f316efe0..00000000 --- a/vendor-cookbooks/magic_shell/libraries/matchers.rb +++ /dev/null @@ -1,17 +0,0 @@ -if defined?(ChefSpec) - def add_magic_shell_alias(name) - ChefSpec::Matchers::ResourceMatcher.new(:magic_shell_alias, :add, name) - end - - def remove_magic_shell_alias(name) - ChefSpec::Matchers::ResourceMatcher.new(:magic_shell_alias, :remove, name) - end - - def add_magic_shell_environment(name) - ChefSpec::Matchers::ResourceMatcher.new(:magic_shell_environment, :add, name) - end - - def remove_magic_shell_environment(name) - ChefSpec::Matchers::ResourceMatcher.new(:magic_shell_environment, :remove, name) - end -end diff --git a/vendor-cookbooks/magic_shell/metadata.json b/vendor-cookbooks/magic_shell/metadata.json deleted file mode 100644 index 3f913a5f..00000000 --- a/vendor-cookbooks/magic_shell/metadata.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "magic_shell", - "version": "1.0.0", - "description": "Installs/Configures command_alias", - "long_description": "magic_shell Cookbook\n====================\n[![Build Status](https://secure.travis-ci.org/customink-webops/magic_shell.png)](http://travis-ci.org/customink-webops/magic_shell)\n\nProvides utility for adding some syntactic sugar to your shell.\n\nUsage\n-----\nUpdate the `metadata.rb` for your cookbook to depend on magic_shell\n\n```ruby\ndepends 'magic_shell'\n```\n\nUse the `magic_shell_alias` resource to create a command alias.\n\n```ruby\nmagic_shell_alias 'myrailsapp' do\n command 'cd /opt/myrailsapp/current'\nend\n```\n\nThis will alias `myrailsapp` to `cd /opt/myrailsapp/current`.\n\nYou can also remove aliases:\n\n```ruby\nmagic_shell_alias 'myrailsapp' do\n action :remove\nend\n```\n\nUse the `magic_shell_environment` resource to create a shell environment variable.\n\n```ruby\nmagic_shell_environment 'EDITOR' do\n value 'vim'\nend\n```\n\nThis will export an `EDITOR` environment variable with a value of `vim`.\n\nYou can also remove environment variables:\n\n```ruby\nmagic_shell_environment 'EDITOR' do\n action :remove\nend\n```\n\nContributing\n------------\n1. Fork the repo\n2. Create a feature branch\n3. Code, document, write specs, test\n4. Submit a PR\n\n\nLicense & Authors\n-----------------\n- Author: Nathen Harvey \n- Author: Seth Vargo \n\n```text\nCopyright 2012-2014 CustomInk, LLC.\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": "CustomInk, LLC", - "maintainer_email": "webops@customink.com", - "license": "Apache 2.0", - "platforms": { - }, - "dependencies": { - }, - "recommendations": { - }, - "suggestions": { - }, - "conflicting": { - }, - "providing": { - }, - "replacing": { - }, - "attributes": { - }, - "groupings": { - }, - "recipes": { - } -} \ No newline at end of file diff --git a/vendor-cookbooks/magic_shell/providers/alias.rb b/vendor-cookbooks/magic_shell/providers/alias.rb deleted file mode 100644 index d842ca01..00000000 --- a/vendor-cookbooks/magic_shell/providers/alias.rb +++ /dev/null @@ -1,68 +0,0 @@ -# -# Cookbook Name:: magic_shell -# Provider:: alias -# -# Author:: Nathen Harvey -# Author:: Seth Vargo -# -# Copyright 2012-2014, CustomInk, LLC. -# -# 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. -# - -# -# Delegate update actions to inline resources -# -use_inline_resources - -# -# This provider supports why-run mode. -# -def whyrun_supported? - true -end - -# -# Create a file entry for the given alias. -# -action :add do - file = Chef::Resource::File.new(destination, run_context) - file.owner('root') - file.group('root') - file.mode('0755') - file.content(<<-EOH.gsub(/^ {8}/, '')) - # - # This file was generated by Chef for #{node['fqdn']} - # Do NOT modify this file by hand! - # - - alias #{new_resource.alias_name}="#{new_resource.command}" - EOH - file.run_action(:create) -end - -# -# Delete the file entry for the given alias. -# -action :remove do - file = Chef::Resource::File.new(destination, run_context) - file.run_action(:delete) -end - -def destination - "/etc/profile.d/#{filename}.sh" -end - -def filename - new_resource.alias_name.to_s.gsub(/\s/, '_') -end diff --git a/vendor-cookbooks/magic_shell/providers/environment.rb b/vendor-cookbooks/magic_shell/providers/environment.rb deleted file mode 100644 index 5eea670f..00000000 --- a/vendor-cookbooks/magic_shell/providers/environment.rb +++ /dev/null @@ -1,68 +0,0 @@ -# -# Cookbook Name:: magic_shell -# Provider:: environment -# -# Author:: Nathen Harvey -# Author:: Seth Vargo -# -# Copyright 2012-2014, CustomInk, LLC. -# -# 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. -# - -# -# Delegate update actions to inline resources -# -use_inline_resources - -# -# This provider supports why-run mode. -# -def whyrun_supported? - true -end - -# -# Create a file entry for the given environment. -# -action :add do - file = Chef::Resource::File.new(destination, run_context) - file.owner('root') - file.group('root') - file.mode('0755') - file.content(<<-EOH.gsub(/^ {8}/, '')) - # - # This file was generated by Chef for #{node['fqdn']} - # Do NOT modify this file by hand! - # - - export #{new_resource.environment_variable}="#{new_resource.value}" - EOH - file.run_action(:create) -end - -# -# -# -action :remove do - file = Chef::Resource::File.new(destination, run_context) - file.run_action(:delete) -end - -def destination - "/etc/profile.d/#{filename}.sh" -end - -def filename - new_resource.environment_variable.to_s.gsub(/\s/, '_') -end diff --git a/vendor-cookbooks/magic_shell/resources/alias.rb b/vendor-cookbooks/magic_shell/resources/alias.rb deleted file mode 100644 index c71c72c8..00000000 --- a/vendor-cookbooks/magic_shell/resources/alias.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# Cookbook Name:: magic_shell -# Resource:: alias -# -# Author:: Nathen Harvey -# Author:: Seth Vargo -# -# Copyright 2012-2014, CustomInk, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -actions :add, :remove -default_action :add - -attribute :alias_name, kind_of: String, name_attribute: true -attribute :command, kind_of: String diff --git a/vendor-cookbooks/magic_shell/resources/environment.rb b/vendor-cookbooks/magic_shell/resources/environment.rb deleted file mode 100644 index 849aebb3..00000000 --- a/vendor-cookbooks/magic_shell/resources/environment.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# Cookbook Name:: magic_shell -# Resource:: environment -# -# Author:: Nathen Harvey -# Author:: Seth Vargo -# -# Copyright 2012-2014, CustomInk, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -actions :add, :remove -default_action :add - -attribute :environment_variable, kind_of: String, name_attribute: true -attribute :value, kind_of: String diff --git a/vendor-cookbooks/vim/CHANGELOG.md b/vendor-cookbooks/vim/CHANGELOG.md deleted file mode 100644 index 01f17a96..00000000 --- a/vendor-cookbooks/vim/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -# vim Cookbook CHANGELOG - -This file is used to list changes made in each version of the vim cookbook. - -## 2.0.2 (2016-08-30) - -- Add IBM zLinux to metadata -- Use kitchen-dokken in Travis CI and test on more Platforms -- Update specs with new platforms -- Remove Chef 11 compatibility -- Add chef_version to metadata - -## v2.0.1 (2016-02-22) - -- add missing bzip2 package to fix source recipe. - -## v2.0.0 (2015-10-01) - -- Use multi-package installs introduced in Chef 12.1 to simplify code and speed up installs -- Add Fedora source install support -- Fix CentOS source install support and ensure vim compiles correctly on CentOS 5/6/7 -- Fix the tarball checksum to be the actual SHA256 checksum -- Enable lua, perl, tcl support in the source install and add the necessary development packages for that support -- Use the correct ctags package on Debian/Ubuntu systems to prevent errors or warnings -- Improve how the code compilation runs in source installs so that a failed run doesn't prevent subsequent Chef runs or introduce a state where vim is never compiled -- Add basic Serverspec test for source installs to ensure that vim runs -- Fixed the error message is a bad install_method attribute is given to describe the actual problema and vim cookbook - -## v1.1.4 (2015-09-21) - -- Converted value_for_platform to value_for_platform_family in order to support all RHEL and Debian derivitives -- Added a Kitchen CI config for integration testing -- Updated Travis to test on the latest ruby versions and to perform Chefspec tests -- Updated Berkfile to 3.X format -- Added updated CONTRIBUTING.MD, TESTING.MD and MAINTAINERS.MD files -- Added Chefspec tests to get coverage to 100% -- Added an expanded .gitignore and a chefignore file to limit the files uploaded to the chef-server -- Added a Rakefile for simplified testing -- Resolved rubocop warnings -- Added Oracle Linux and Amazon Linux to the metadata file -- Updated development dependencies -- Updated Kitchen config to work with the latest in Chef DK - -## v1.1.2 (2013-12-30) - -- Fixed Ubuntu package installer bug. Adding specs. - -## v1.1.0 - -### Improvement - -- **[COOK-2465](https://tickets.opscode.com/browse/COOK-2465)** - Add a compile and settings optional recipe. diff --git a/vendor-cookbooks/vim/CONTRIBUTING.md b/vendor-cookbooks/vim/CONTRIBUTING.md deleted file mode 100644 index ef2f2b80..00000000 --- a/vendor-cookbooks/vim/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/vim/MAINTAINERS.md b/vendor-cookbooks/vim/MAINTAINERS.md deleted file mode 100644 index 00eed8d7..00000000 --- a/vendor-cookbooks/vim/MAINTAINERS.md +++ /dev/null @@ -1,18 +0,0 @@ - - -# Maintainers -This file lists how this cookbook project is maintained. When making changes to the system, this -file tells you who needs to review your patch - you need a simple majority of maintainers -for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need -to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) -for details on the process and how to become a maintainer or the project lead. - -# Project Maintainer -* [Tim Smith](https://github.com/tas50) - -# Maintainers -* [Jennifer Davis](https://github.com/sigje) -* [Tim Smith](https://github.com/tas50) -* [Thom May](https://github.com/thommay) diff --git a/vendor-cookbooks/vim/README.md b/vendor-cookbooks/vim/README.md deleted file mode 100644 index 91c93248..00000000 --- a/vendor-cookbooks/vim/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# vim Cookbook - -[![Build Status](https://travis-ci.org/chef-cookbooks/vim.svg?branch=master)](https://travis-ci.org/chef-cookbooks/vim) [![Cookbook Version](https://img.shields.io/cookbook/v/vim.svg)](https://supermarket.chef.io/cookbooks/vim) - -Installs or compiles/installs vim. - -## Requirements - -### Platforms - -- Ubuntu/Debian -- RHEL/CentOS/Scientific/Amazon/Oracle -- Fedora - -### Chef - -- Chef 12.1+ - -### Cookbooks - -- none - -## Attributes - -### Default recipe attributes: - -- `node['vim']['extra_packages']` - An array of extra packages related to vim to install (like plugins). Empty array by default. - -- `node['vim']['install_method']` - Sets the install method, choose from the various install recipes. This attribute is set to 'package' by default. - -### Source recipe attributes: - -- `node['vim']['source']['version']` - The version of vim to compile, 7.4 by default. -- `node['vim']['source']['checksum']` - The source file checksum. -- `node['vim']['source']['dependencies']` - These are the non rhl specific devel dependencies for compiling vim. -- `node['vim']['source']['centos_dependencies']` - These are the rhl and centos specific dependencies needed for compiling vim. -- `node['vim']['source']['prefix']` - This is the path the vim bin will be placed, it's `/usr/local` -- `node['vim']['source']['configuration']` - If you prefer to compile vim differently than the default you can override this configuration. - -## Usage - -Add `recipe[vim]` to your run list or include the default recipe with `include_recipe 'vim'` in a recipe that is in your run list. - -This uses the value of the attribute `node['vim']['install_method']` which by default is _package_. - -If you would like to install additional vim plugin packages, include their package names in the `node['vim']['extra_packages']` attribute. Verify that your operating sytem has the package available. - -If you would rather compile vim from source, as the case may be for centos nodes, then override the `node['vim']['install_method']` with a value of `'source'`. - -## License & Authors - -**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io)) - -**Copyright:** 2008-2016, Chef Software, Inc. - -``` -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -``` diff --git a/vendor-cookbooks/vim/attributes/default.rb b/vendor-cookbooks/vim/attributes/default.rb deleted file mode 100644 index beb1a403..00000000 --- a/vendor-cookbooks/vim/attributes/default.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -# Cookbook Name:: vim -# Attributes:: default -# -# Copyright 2010-2015, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -default['vim']['extra_packages'] = [] -default['vim']['install_method'] = 'package' diff --git a/vendor-cookbooks/vim/attributes/source.rb b/vendor-cookbooks/vim/attributes/source.rb deleted file mode 100644 index 3eaa5eff..00000000 --- a/vendor-cookbooks/vim/attributes/source.rb +++ /dev/null @@ -1,63 +0,0 @@ -# -# Cookbook Name:: vim -# Attributes:: source -# -# Copyright 2013-2015, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -default['vim']['source']['version'] = '7.4' -default['vim']['source']['checksum'] = 'd0f5a6d2c439f02d97fa21bd9121f4c5abb1f6cd8b5a79d3ca82867495734ade' -default['vim']['source']['prefix'] = '/usr/local' -default['vim']['source']['configuration'] = "--without-x --enable-pythoninterp --enable-rubyinterp --enable-tclinterp --enable-luainterp --enable-perlinterp --enable-cscope --with-features=huge --prefix=#{default['vim']['source']['prefix']}" - -default['vim']['source']['dependencies'] = if platform_family? 'rhel', 'fedora' - if node['platform_version'].to_i >= 6 - %w( ctags - gcc - lua-devel - make - ncurses-devel - perl-devel - perl-ExtUtils-CBuilder - perl-ExtUtils-Embed - perl-ExtUtils-ParseXS - python-devel - ruby-devel - tcl-devel - ) - else # centos 5 and earlier lack lua, luajit, and many of the perl packages found in later releases. Also installs fail without libselinux-devel - %w( ctags - gcc - make - ncurses-devel - perl - python-devel - ruby-devel - tcl-devel - libselinux-devel - ) - end - else - %w( exuberant-ctags - gcc - libncurses5-dev - libperl-dev - lua5.1 - make - python-dev - ruby-dev - tcl-dev - ) - end diff --git a/vendor-cookbooks/vim/metadata.json b/vendor-cookbooks/vim/metadata.json deleted file mode 100644 index 1833c1ef..00000000 --- a/vendor-cookbooks/vim/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"vim","version":"2.0.2","description":"Installs vim and optional extra packages.","long_description":"# vim Cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/vim.svg?branch=master)](https://travis-ci.org/chef-cookbooks/vim) [![Cookbook Version](https://img.shields.io/cookbook/v/vim.svg)](https://supermarket.chef.io/cookbooks/vim)\n\nInstalls or compiles/installs vim.\n\n## Requirements\n\n### Platforms\n\n- Ubuntu/Debian\n- RHEL/CentOS/Scientific/Amazon/Oracle\n- Fedora\n\n### Chef\n\n- Chef 12.1+\n\n### Cookbooks\n\n- none\n\n## Attributes\n\n### Default recipe attributes:\n\n- `node['vim']['extra_packages']` - An array of extra packages related to vim to install (like plugins). Empty array by default.\n\n- `node['vim']['install_method']` - Sets the install method, choose from the various install recipes. This attribute is set to 'package' by default.\n\n### Source recipe attributes:\n\n- `node['vim']['source']['version']` - The version of vim to compile, 7.4 by default.\n- `node['vim']['source']['checksum']` - The source file checksum.\n- `node['vim']['source']['dependencies']` - These are the non rhl specific devel dependencies for compiling vim.\n- `node['vim']['source']['centos_dependencies']` - These are the rhl and centos specific dependencies needed for compiling vim.\n- `node['vim']['source']['prefix']` - This is the path the vim bin will be placed, it's `/usr/local`\n- `node['vim']['source']['configuration']` - If you prefer to compile vim differently than the default you can override this configuration.\n\n## Usage\n\nAdd `recipe[vim]` to your run list or include the default recipe with `include_recipe 'vim'` in a recipe that is in your run list.\n\nThis uses the value of the attribute `node['vim']['install_method']` which by default is _package_.\n\nIf you would like to install additional vim plugin packages, include their package names in the `node['vim']['extra_packages']` attribute. Verify that your operating sytem has the package available.\n\nIf you would rather compile vim from source, as the case may be for centos nodes, then override the `node['vim']['install_method']` with a value of `'source'`.\n\n## License & Authors\n\n**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))\n\n**Copyright:** 2008-2016, Chef Software, Inc.\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":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"debian":">= 0.0.0","ubuntu":">= 0.0.0","arch":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0","amazon":">= 0.0.0","zlinux":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} \ No newline at end of file diff --git a/vendor-cookbooks/vim/recipes/default.rb b/vendor-cookbooks/vim/recipes/default.rb deleted file mode 100644 index 8b073066..00000000 --- a/vendor-cookbooks/vim/recipes/default.rb +++ /dev/null @@ -1,24 +0,0 @@ -# -# Cookbook Name:: vim -# Recipe:: default -# -# Copyright 2010-2015, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -begin - include_recipe "vim::#{node['vim']['install_method']}" -rescue Chef::Exceptions::RecipeNotFound - Chef::Log.warn "A vim recipe does not exist for the install method specified: #{node['vim']['install_method']}" -end diff --git a/vendor-cookbooks/vim/recipes/package.rb b/vendor-cookbooks/vim/recipes/package.rb deleted file mode 100644 index 551881a8..00000000 --- a/vendor-cookbooks/vim/recipes/package.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# Cookbook Name:: vim -# Recipe:: package -# -# Copyright 2013-2015, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# There is no vim package on RHEL/CentOS derivatives -# * vim-minimal gives you /bin/vi -# * vim-enhanced gives you /usr/bin/vim -# -vim_base_pkgs = value_for_platform_family( - %w(debian arch) => ['vim'], - %w(rhel fedora) => ['vim-minimal', 'vim-enhanced'], - 'default' => ['vim'] -) - -package vim_base_pkgs - -package node['vim']['extra_packages'] diff --git a/vendor-cookbooks/vim/recipes/source.rb b/vendor-cookbooks/vim/recipes/source.rb deleted file mode 100644 index dda69034..00000000 --- a/vendor-cookbooks/vim/recipes/source.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# Cookbook Name:: vim -# Recipe:: source -# -# Copyright 2013-2015, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cache_path = Chef::Config['file_cache_path'] -source_version = node['vim']['source']['version'] - -package 'bzip2' -package node['vim']['source']['dependencies'] - -include_recipe 'vim::source_rhel' if platform?('fedora') || platform_family?('rhel') - -remote_file "#{cache_path}/vim-#{source_version}.tar.bz2" do - source "http://ftp.vim.org/pub/vim/unix/vim-#{source_version}.tar.bz2" - checksum node['vim']['source']['checksum'] -end - -bash 'install_vim' do - cwd cache_path - code <<-EOH - mkdir vim-#{source_version} - tar -jxf vim-#{source_version}.tar.bz2 -C vim-#{source_version} --strip-components 1 - (cd vim-#{source_version}/ && make clean && ./configure #{node['vim']['source']['configuration']} && make && make install) - EOH - creates "#{node['vim']['source']['prefix']}/bin/vim" -end diff --git a/vendor-cookbooks/vim/recipes/source_rhel.rb b/vendor-cookbooks/vim/recipes/source_rhel.rb deleted file mode 100644 index 3add1410..00000000 --- a/vendor-cookbooks/vim/recipes/source_rhel.rb +++ /dev/null @@ -1,8 +0,0 @@ -# vim looks for xsubpp in wrong location RHEL 7+ and Fedora - -link '/usr/share/perl5/ExtUtils/xsubpp' do - to '/usr/bin/xsubpp' - only_if { ::File.exist?('/usr/bin/xsubpp') } # if package node attributes don't include perl this won't be here -end if node['platform_version'].to_i >= 7 - -package 'bzip2' if node['platform_version'].to_i >= 7