Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

docker-platform (8) Versions 1.6.0

Use Docker ressources to install/configure Docker with attributes

Policyfile
Berkshelf
Knife
cookbook 'docker-platform', '~> 1.6.0', :supermarket
cookbook 'docker-platform', '~> 1.6.0'
knife supermarket install docker-platform
knife supermarket download docker-platform
README
Dependencies
Changelog
Quality 50%

Docker Platform Cookbook

Description

Docker is an open-source project that automates
the deployment of applications inside software containers, by providing
an additional layer of abstraction and automation of operating-system-level
virtualisation on Linux.

Docker uses the resource isolation features of the Linux kernel such as cgroups
and kernel namespaces, and a union-capable file system such as aufs and others
to allow independent "containers" to run within a single Linux instance,
avoiding the overhead of starting and maintaining virtual machines.

This cookbook provides recipes to install and configure Docker with
configuration stored in attributes. It wraps docker cookbook resources to
control Docker status and also provides resources to manager swarm cluster
creation and volumes deployment.

Requirements

Cookbooks and gems

Declared in [metadata.rb](metadata.rb) and in [Gemfile](Gemfile).

Platforms

  • RHEL Family 7, tested on Centos

Note: by composing it with apt-docker cookbook, it should work fine on
Debian / Ubuntu.

Usage

Quick Start

Add default recipe to install Docker from package, configure it and set up any
requested ressources (like service, image, etc.) defined in attributes. It also
sets up the swarm if configured to do so.

If you need you docker-machine, add docker-machine recipe to install it.

Test

This cookbook is fully tested in test-kitchen, using docker itself and
serverspec verifier. Beware: tests are run in privileged mode.

For more information, see [.kitchen.yml](.kitchen.yml) and [test](test)
directory.

Attributes

Configuration is done by overriding default attributes. All configuration keys
have a default defined in [attributes/default.rb](attributes/default.rb).
Please read it to have a comprehensive view of what and how you can configure
this cookbook behavior.

In addition, you can use attributes to define docker cookbook resources.
All you have to do is to define an attribute of the same name as the resource
you want to call containing the different instances of this resource. For
instance:

"docker_volume": {
  "data": {
    "action": "create"
  },
  "to_remove": {
    "action": "remove"
  }
}

It creates a docker volume named data and remove the one called to_remove.
The key of each sub hash table is the name attribute and the value is an hash
table containing the resource configuration, mapping exactly the attribute name
defined in docker cookbook documentation.

If you need multiple arguments for an attribute, you have to declare them in
an array. If you need an array as single argument, add an extra array.

For instance:

"docker_container": {
  "my_alpine": {
    "container_name": "alpine",
    "repo": "alpine",
    "volumes": [["data:/data"]],
    "action": "run",
    "subscribes": ["redeploy", "docker_image[alpine]", "immediately"]
  }
}

You can find other examples in [.kitchen.yml](.kitchen.yml) file.

Recipes

default

Include all other recipes to install, configure, run and launch Docker
volumes/services.

repository

Configure and install official docker yum repository.

package

Install docker-engine package or upgrade it if attribute version is set to
latest.

tls

Activate tls support if a data bag item is defined. Load cacert, cert, key
needed from it. See test data bag for more informations.

config

Manage docker configuration file. Configuration keys can be manipulated by
attributes or by others recipes by setting the run_state.

service

Enable and start docker service.

docker

Wrap all docker cookbook resources so it is possible to use them with
attributes. Read attributes section for more details.

login

Create '/root/.docker/config.json' with authentication info declared in
docker\_registry attributes. In other work, make registries login permanent.

swarm

Use docker_platform_swarm resource of the cookbook to initialize or join
a swarm. See [.kitchen.yml](.kitchen.yml) for examples.

Use cluster-search cookbook to determine the list of managers and an
external consul cluster to orchestrate the initialization and the storage of
join tokens.

You need a consul cluster. This is not in the scope of this cookbook but
if you need one, you should consider using Consul Platform.

docker-machine

Install docker-machine (just a remote file).

swarm_secrets

Use docker_platform_secret resource of the cookbook to manage swarm secrets.

swarm_services

Use docker_platform_service resource of the cookbook to manage swarm
services.

Resources/Providers

swarm

For instance:

Initialize a swarm and store token on consul:

"docker_platform": {
  "swarm": {
    "consul": {
      "hosts": "consul-swarm-host"
    },
    "options": {
      "listen_addr": "0.0.0.0:2377",
      "action": "create"
    }
  }
}

Join an existing docker swarm with token stored on consul:

"docker_platform": {
  "swarm": {
    "consul": {
      "hosts": "consul-swarm-host"
    },
    "action": ["join"]
  }
}

secret

Deploy a secret, from a file or from an attribute.

Example: deploy two secrets, one from /root/secret-file named "secret-file",
the other one containing "this is a secret from content" named secret-content.

"docker_platform": {
  "secrets": {
    "secret-file": {
      "file": "/root/secret-file"
    },
    "secret-content": {
      "content": "this is a secret from content"
    }
  }
}

service

Deploy 5 replicas of redis image on a docker swarm with a placement preference:

"docker_platform": {
  "services": {
    "redis": {
      "action": "create",
      "replicas": 5,
      "image": "redis:latest",
      "options": {
        "placement-pref": [
          "spread=node.labels.datacenter", "spread=node.labels.rack"
        ]
      }
    }
  }
}

Changelog

Available in [CHANGELOG.md](CHANGELOG.md).

Contributing

Please read carefully [CONTRIBUTING.md](CONTRIBUTING.md) before making a merge
request.

License and Author

Copyright (c) 2016-2017 Sam4Mobile, 2017-2018 Make.org

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.

Dependent cookbooks

cluster-search >= 0.0.0
docker >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Changelog

1.6.0

Main:

  • feat: can install docker-machine through docker-machine recipe, not included in default

1.5.0

Main:

  • Chef 14 support
    • fix(chef 14): add an alias for property_is_set?
    • fix(chef 14): use new_resource for resource properties
  • feat: handle swarm secrets, from file or content

Tests:

  • test: include .gitlab-ci.yml from test-cookbook

Misc:

  • style(rubocop): fix redundant return and spaces
  • fix(foodcritic): do not use kind_of in resources
  • doc: use doc in git message instead of docs
  • chore: set generic maintainer & helpdesk email

1.4.0

Main:

  • fix: do not try to init a cluster when joined (this fixes the case when the Consul is erased and reinitialised)
  • feat: rename 'name' service property to 'service'
  • feat: add config recipe to manage daemon.json
  • feat: add tls support
  • feat: set detach true for service creation
  • feat: allow multiples values for a service option

Tests:

  • use .gitlab-ci.yml template [20180208]

Misc:

  • docs: update swarm recipe part
  • fix: deprecation warning in swarm resource
  • fix: workaround a 13.7 nasty chef bug

1.3.0

Main:

  • feat: add partial override of unit as default
    • You can override systemd unit of docker in two way:
    • merge (default), configure just the keys you want to add/modify
    • full, replace packaged unit completely
    • WARN: Before this patch, only full was available. By using merge as default, this introduces a potential breaking change.
  • feat: create auth file for registry attributes
    • Create '/root/.docker/config.json' with authentication info specified in 'docker_registry' attributes.
  • feat: update pkg & repo info to get latest version
    • Docker repositories and package name change after the 17.05 version. This patch updates the default info and allows a better configuration.
  • feat: monkey patches docker to fix ip_address bug
    • ip_address value is not returned correctly by load_current_value. This causes the resource to run each time, destroying and restarting containers with fixed ip at each run.
    • This patch monkey-patches docker cookbook to fix this bug. When the bug will be resolved upstream, a warning will be outputted.

Misc:

  • fix: use new_resource prefix in swarm resource

1.2.0

Main:

  • feat(swarm): get managers from search
    • Nodes are separated in two roles, managers and workers:
    • managers are found by a search on a role
    • workers are the other nodes
    • Upload to consul both manager and worker token
  • feat: remove the need to define an initiator
    • Before this version, an initiator would have to be defined to perform all swarm admin action like init, network, etc. By using Consul and its distributed lock feature, we remove the need to set an initiator: admin ops can be done by any manager
    • Also fixes many other problems, basically because the initiator was a SPOF:
    • the rejoin of a previously initiator (which was trying to recreate a cluster)
    • the join of any node if the initiator was down (because all nodes tried to join by contacting the initiator)
  • refactor: add swarm in default, refact resources
    • Set swarm recipe in default recipe, before calling docker cookbook resources. Add a flag "enabled?" (default to false) for stand-alone nodes.
  • remove network resource as it can be done by docker_network.
  • fix against latest version of diplomat (consul gem)
  • fix chef 13 when package_retries is nil (default)
  • refactor: move swarm config in consul to swarm sub-key
  • fix #1: wait for docker to be ready after start it
  • fix: merge init_opts with join_opts for swarm init

Tests:

  • use most recent image and add build_pull
  • fix consul config, improve errors output
  • reduce wait times and scaling requirement
  • add info while waiting, betting balancing
  • use .gitlab-ci.yml template [20170731]
  • use 3 manager nodes and 1 worker
  • check each node status in the cluster
  • separate test of standalone suite from swarm
  • check redis image after rebalancing

Misc:

  • handover maintainance to Make.org, fix metadata
  • style: fix rubocop offenses: %i stuff
  • fix: move consul dependency to tests
  • fix(gemfile): add linter, force molinillo version
  • refactor: change wording, master to manager
  • style: fix indentation in .kitchen.yml
  • style(rubocop): fix heredoc delimiters
  • docs: use karma for git format in contributing

1.1.0

Add swarm creation support and service deployment by using custom resources

1.0.1

  • Fix versionning of package

1.0.0

  • Initial version for Centos 7

Collaborator Number Metric
            

1.6.0 passed this metric

Contributing File Metric
            

1.6.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

1.6.0 passed this metric

No Binaries Metric
            

1.6.0 passed this metric

Testing File Metric
            

1.6.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

1.6.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number