Enabled: false
Metrics/AbcSize:
Enabled: false
-Style/SpaceBeforeFirstArg:
- Enabled: false
Style/BlockComments:
Enabled: false
Style/BlockDelimiters:
Enabled: false
Style/RescueModifier:
Enabled: false
-Style/WordArray:
+Style/SpaceBeforeFirstArg:
Enabled: false
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
+Style/WordArray:
+ Enabled: false
+
+#Style/AccessorMethodName:
+# Enabled: false
+#Style/MethodLength:
+# Max: 30
+#Style/ModuleLength:
+# Max: 150
dcos-grid CHANGELOG
===================
+0.3.0
+-----
+- adds Ubuntu (>= 16.04) support (Experimental).
+- adds `dcos-grid::cli` recipe.
+
0.2.0
-----
- adds some attributes for the generation of cloud-config.yaml
Requirements
------------
+#### platforms
+- CentOS, Red Hat Enterprise Linux >= 7.2
+- CoreOS Latest version.
+- Ubuntu 16.04 (Experimental). DC/OS does not officially support Ubuntu yet. See [_Ubuntu 16.04 Enablement_](https://dcosjira.atlassian.net/browse/DCOS-25).
+ - DC/OS requires systemd, which is only fully supported in Ubuntu 15.04 and later releases. See [_SystemdForUpstartUsers_](https://wiki.ubuntu.com/SystemdForUpstartUsers)
+
#### packages
- none.
|Key|Type|Description, example|Default|
|:--|:--|:--|:--|
|`['dcos-grid']['dcos_release_url']`|String|DC/OS download URL.|`'https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh'`|
-|`['dcos-grid']['docker-engine']['version']`|String|Docker 1.9.x - 1.11.x is recommended for stability reasons.|`'1.11.2-1.el7.centos'`|
+|`['dcos-grid']['dcos_cli_release_url']`|String|DC/OS CLI download URL (ver. 0.3.0 or later).|`'https://downloads.dcos.io/binaries/cli/linux/x86-64/0.4.10/dcos'`|
+|`['dcos-grid']['docker-engine']['setup']`|Boolean|Docker setup by this cookbook. If you will set up Docker by another cookbook, verify that this attribute is false. (ver. 0.3.0 or later)|`true`|
+|`['dcos-grid']['docker-engine']['version_on_centos']`|String|Docker version for CentOS (ver. 0.3.0 or later).|`'1.11.2-1'`|
+|`['dcos-grid']['docker-engine']['version_on_ubuntu']`|String|Docker version for Ubuntu (ver. 0.3.0 or later).|`'1.11.2-0'`|
+|`['dcos-grid']['docker-engine']['version']`|String|Docker 1.9.x - 1.11.x is recommended for stability reasons. Note: this **default** value is overwritten by the `version_on_{centos or ubuntu}` (ver. 0.3.0 or later).|See default.rb|
|`['dcos-grid']['bootstrap']['ip']`|String|Bootstrap node IP address.|`'127.0.0.1'`|
|`['dcos-grid']['bootstrap']['port']`|String|Bootstrap node port number.|`'8080'`|
|`['dcos-grid']['bootstrap']['genconf_dir']`|String|genconf directory path.|`'/opt/dcos-grid/genconf'`|
|`['dcos-grid']['bootstrap']['config']['ip_detect_filename']`|String||`'/genconf/ip-detect'`|
|`['dcos-grid']['bootstrap']['config']['master_list']`|Array|e.g. `['192.168.1.101','192.168.1.102','192.168.1.103']`|`nil`|
|`['dcos-grid']['bootstrap']['config']['resolvers']`|Array|e.g. `['8.8.8.8','8.8.4.4']` (Google DNS)|`nil`|
-|`['dcos-grid']['bootstrap']['bootstrap']['ip-detect']['interface']`|String|Network interface on each node for ip-detect.|`'eth0'`|
+|`['dcos-grid']['bootstrap']['bootstrap']['ip-detect']['interface']`|String|Network interface on each node for the `ip-detect` script. Note: If you set comma-delimited interface list (e.g. `'eth0,enp0s3'`), the first detected interface's ip is adopted (ver. 0.3.0 or later). |`'eth0'`|
|`['dcos-grid']['node']['auto_setup']`|Boolean|execute the node setup script automatically or not.|`false`|
|`['dcos-grid']['cloud-config']['target_platform']`|String|CoreOS only now.|`'coreos'`|
|`['dcos-grid']['cloud-config']['target_dir']`|String||`'/home/core'`|
This recipe sets up a private agent node. Note: If `node['dcos-grid']['node']['auto_setup']` is `false`, you must execute the following manually.
```
-$ cd /opt/dcos-grid
-$ ./node_setup.sh slave
+$ /opt/dcos-grid/node_setup.sh slave
```
#### dcos-grid::bootstrap
This recipe sets up a bootstrap node. Note: Please execute the following manually.
```
-$ cd /opt/dcos-grid
-$ ./bootstrap_setup.sh
+$ /opt/dcos-grid/bootstrap_setup.sh
```
+#### dcos-grid::cli (ver. 0.3.0 or later)
+
+This recipe installs DC/OS CLI.
+
#### dcos-grid::cloud-config (for CoreOS only)
This recipe generates a `/opt/dcos-grid/cloud-config.yaml` template file on local machine by the following `chef-solo` command.
This recipe sets up a master node. Note: If `node['dcos-grid']['node']['auto_setup']` is `false`, you must execute the following manually.
```
-$ cd /opt/dcos-grid
-$ ./node_setup.sh master
+$ /opt/dcos-grid/node_setup.sh master
```
#### dcos-grid::node
This recipe sets up a base node (particular role is not assigned yet). Note: Please execute the following manually.
```
-$ cd /opt/dcos-grid
-$ ./node_setup.sh {master|slave|slave_public}
+$ /opt/dcos-grid/node_setup.sh {master|slave|slave_public}
```
#### dcos-grid::node-commons
This recipe sets up a public node. Note: If `node['dcos-grid']['node']['auto_setup']` is `false`, you must execute the following manually.
```
-$ cd /opt/dcos-grid
-$ ./node_setup.sh slave_public
+$ /opt/dcos-grid/node_setup.sh slave_public
```
### Role Examples
'dcos-grid' => {
'dcos_release_url' => 'https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh',
'docker-engine' => {
- 'version' => '1.11.2-1.el7.centos',
+ 'version_on_centos' => '1.11.2-1',
+ 'version_on_ubuntu' => '1.11.2-0',
+ #'version' => '1.11.2-1.el7.centos',
},
'bootstrap' => {
'ip' => '192.168.56.100',
],
},
'ip-detect' => {
- 'interface' => 'enp0s8',
+ 'interface' => 'eth1,enp0s8',
},
},
'node' => {
Please log in each node and execute the following.
```
-$ cd /opt/dcos-grid
-$ ./uninstall.sh
+$ /opt/dcos-grid/uninstall.sh
```
License and Authors
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any'],
- tags: ['~FC001'],
}
end
end
#
default['dcos-grid']['dcos_release_url'] = 'https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh'
-default['dcos-grid']['docker-engine']['version'] = '1.11.2-1.el7.centos'
+default['dcos-grid']['dcos_cli_release_url'] = 'https://downloads.dcos.io/binaries/cli/linux/x86-64/0.4.10/dcos'
+default['dcos-grid']['docker-engine']['setup'] = true
+default['dcos-grid']['docker-engine']['version_on_centos'] = '1.11.2-1'
+default['dcos-grid']['docker-engine']['version_on_ubuntu'] = '1.11.2-0'
+default['dcos-grid']['docker-engine']['version'] = node.value_for_platform(
+ ['centos', 'redhat'] => {
+ 'default' => "#{node['dcos-grid']['docker-engine']['version_on_centos']}.el#{node['platform_version'].to_i}.#{node['platform']}",
+ },
+ 'ubuntu' => {
+ 'default' => "#{node['dcos-grid']['docker-engine']['version_on_ubuntu']}~#{node['lsb']['codename']}",
+ }
+)
default['dcos-grid']['bootstrap']['ip'] = '127.0.0.1'
default['dcos-grid']['bootstrap']['port'] = '8080'
default['dcos-grid']['bootstrap']['genconf_dir'] = '/opt/dcos-grid/genconf'
+# $ knife supermarket share dcos-grid "Operating Systems & Virtualization"
name 'dcos-grid'
maintainer 'whitestar'
maintainer_email ''
license 'Apache 2.0'
description 'Installs/Configures DC/OS Cluster Node.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version '0.2.0'
+version '0.3.0'
source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
issues_url 'https://osdn.jp/projects/metasearch/ticket'
%w( centos redhat ).each do |os|
supports os, '>= 7.2'
end
+# Experimental
+supports 'ubuntu', '>= 16.04'
EOH
not_if { ::Dir.exist?('/opt/mesosphere') }
end
+else
+ log <<-"EOM"
+Note: You must execute the following command only once.
+ $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_setup.sh slave
+ EOM
end
group 'root'
mode '0755'
end
+
+log <<-"EOM"
+Note: You must execute the following command manually.
+ $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/bootstrap_setup.sh
+EOM
--- /dev/null
+#
+# Cookbook Name:: dcos-grid
+# Recipe:: cli
+#
+# Copyright 2016, whitestar
+#
+# 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.
+#
+
+genconf_dir = node['dcos-grid']['bootstrap']['genconf_dir']
+
+directory genconf_dir do
+ owner 'root'
+ group 'root'
+ mode '0755'
+ recursive true
+ action :create
+end
+
+=begin
+# old way
+case node['platform_family']
+when 'rhel'
+ # TODO: package installation.
+when 'debian'
+ [
+ 'curl',
+ 'python-pip',
+ 'python-virtualenv',
+ 'virtualenv',
+ ].each {|pkg|
+ package pkg do
+ action :install
+ end
+ }
+end
+=end
+
+template "#{File.dirname(genconf_dir)}/cli_setup.sh" do
+ source 'opt/dcos-grid/cli_setup.sh'
+ owner 'root'
+ group 'root'
+ mode '0755'
+end
+
+bash 'install_dcos_cli' do
+ code <<-"EOH"
+ #{File.dirname(genconf_dir)}/cli_setup.sh
+ EOH
+ not_if { ::File.exist?('/usr/local/bin/dcos') }
+end
mode '0644'
variables config_params: CONFIG_PARAMS
end
+
+log <<-EOM
+Info: You can install CoreOS with DC/OS setup scripts by the the cloud-config.yaml.
+ $ coreos-cloudinit -from-file ~/cloud-config.yaml -validate
+ ...
+ $ sudo coreos-install -d /dev/sda -C stable -c ~/cloud-config.yaml
+EOM
EOH
not_if { ::Dir.exist?('/opt/mesosphere') }
end
+else
+ log <<-"EOM"
+Note: You must execute the following command only once.
+ $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_setup.sh master
+ EOM
end
# limitations under the License.
#
+# https://dcos.io/docs/1.8/administration/installing/custom/system-requirements/
+
genconf_dir = node['dcos-grid']['bootstrap']['genconf_dir']
directory genconf_dir do
mode '0755'
end
+group 'nogroup' do
+ action :create
+end
+
case node['platform_family']
when 'rhel'
service 'firewalld' do
mode '0644'
end
- group 'nogroup' do
- action :create
- end
+ # https://dcos.io/docs/1.8/administration/installing/custom/system-requirements/install-docker-centos/
+ if node['dcos-grid']['docker-engine']['setup']
+ bash 'load_overlayfs_kernel_module' do
+ code <<-EOH
+ modprobe overlay
+ EOH
+ not_if 'lsmod | grep overlay'
+ end
+ template '/etc/modules-load.d/overlay.conf' do
+ source 'etc/modules-load.d/overlay.conf'
+ owner 'root'
+ group 'root'
+ mode '0644'
+ end
- bash 'load_overlayfs_kernel_module' do
- code <<-EOH
- modprobe overlay
- EOH
- not_if 'lsmod | grep overlay'
- end
- template '/etc/modules-load.d/overlay.conf' do
- source 'etc/modules-load.d/overlay.conf'
- owner 'root'
- group 'root'
- mode '0644'
- end
+ template '/etc/yum.repos.d/docker.repo' do
+ source 'etc/yum.repos.d/docker.repo'
+ owner 'root'
+ group 'root'
+ mode '0644'
+ end
- template '/etc/yum.repos.d/docker.repo' do
- source 'etc/yum.repos.d/docker.repo'
- owner 'root'
- group 'root'
- mode '0644'
- end
+ directory '/etc/systemd/system/docker.service.d' do
+ owner 'root'
+ group 'root'
+ mode '0755'
+ action :create
+ end
- directory '/etc/systemd/system/docker.service.d' do
- owner 'root'
- group 'root'
- mode '0755'
- action :create
- end
+ template '/etc/systemd/system/docker.service.d/override.conf' do
+ source 'etc/systemd/system/docker.service.d/override.conf'
+ owner 'root'
+ group 'root'
+ mode '0644'
+ end
- template '/etc/systemd/system/docker.service.d/override.conf' do
- source 'etc/systemd/system/docker.service.d/override.conf'
- owner 'root'
- group 'root'
- mode '0644'
- end
+ [
+ 'docker-engine-selinux',
+ 'docker-engine',
+ ].each {|pkg|
+ package pkg do
+ action :install
+ version node['dcos-grid']['docker-engine']['version']
+ options '--enablerepo=dockerrepo'
+ end
+ }
+ service 'docker' do
+ action [:start, :enable]
+ end
+ end
+when 'debian'
[
- 'docker-engine-selinux',
- 'docker-engine',
+ 'tar',
+ 'xz-utils',
+ 'unzip',
+ 'curl',
+ 'ipset',
].each {|pkg|
package pkg do
action :install
- version node['dcos-grid']['docker-engine']['version']
- options '--enablerepo=dockerrepo'
end
}
- service 'docker' do
- action [:start, :enable]
+ # https://docs.docker.com/engine/installation/linux/ubuntulinux/
+ if node['dcos-grid']['docker-engine']['setup']
+ [
+ 'apt-transport-https',
+ 'ca-certificates',
+ # for aufs
+ "linux-image-extra-#{node['os_version']}",
+ 'linux-image-extra-virtual',
+ ].each {|pkg|
+ package pkg do
+ action :install
+ end
+ }
+
+ template '/etc/apt/sources.list.d/docker.list' do
+ source 'etc/apt/sources.list.d/docker.list'
+ owner 'root'
+ group 'root'
+ mode '0644'
+ end
+
+ bash 'apt-key_adv_docker_tools_key' do
+ code <<-EOH
+ apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
+ apt-get update
+ EOH
+ not_if 'apt-key list | grep -i docker'
+ end
+
+ # Default Storage Driver: aufs
+ [
+ 'docker-engine',
+ ].each {|pkg|
+ package pkg do
+ action :install
+ version node['dcos-grid']['docker-engine']['version']
+ end
+ }
+
+ service 'docker' do
+ action [:start, :enable]
+ end
+ end
+
+ # work around for DC/OS service units
+ link '/usr/bin/mkdir' do
+ to '/bin/mkdir'
+ end
+ link '/usr/bin/ln' do
+ to '/bin/ln'
+ end
+ link '/usr/bin/tar' do
+ to '/bin/tar'
+ end
+ link '/sbin/useradd' do
+ to '/usr/sbin/useradd'
end
end
EOH
not_if { ::Dir.exist?('/opt/mesosphere') }
end
+else
+ log <<-"EOM"
+Note: You must execute the following command only once.
+ $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_setup.sh public-slave
+ EOM
end
--- /dev/null
+deb https://apt.dockerproject.org/repo ubuntu-<%= node['lsb']['codename'] %> main
#!/usr/bin/env bash
+<%
+# NOTE for cookbook developer: If you edit this script, you must update opt/dcos-grid/cloud-config.yaml
+-%>
PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
--- /dev/null
+#!/usr/bin/env bash
+
+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
+
+user=`whoami`
+sudo='sudo'
+if [ $user = 'root' ]; then
+ sudo=''
+fi
+
+$sudo curl <%= node['dcos-grid']['dcos_cli_release_url'] %> -o /usr/local/bin/dcos &&
+$sudo chmod +x /usr/local/bin/dcos &&
+$sudo dcos config set core.dcos_url https://<%= node['dcos-grid']['bootstrap']['config']['master_list'][0] %>
+
+# old way
+#mkdir -p dcos && cd dcos &&
+#curl -O https://downloads.dcos.io/dcos-cli/install.sh &&
+#bash ./install.sh . https://<%= node['dcos-grid']['bootstrap']['config']['master_list'][0] %> &&
+#source ./bin/env-setup
owner: "<%= cloud_config['target_owner'] %>"
content: |
#!/usr/bin/env bash
- set -o nounset -o errexit
+ set -o nounset #-o errexit
export PATH=/usr/sbin:/usr/bin:$PATH
iface=<%= node['dcos-grid']['bootstrap']['ip-detect']['interface'] %> # or eth0,...
- echo $(ip addr show $iface | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
+ for iface in `echo $ifaces | tr ',' ' '`; do
+ #echo $iface
+ ip addr show $iface > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ # first detected interface
+ echo $(ip addr show $iface | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
+ break
+ fi
+ done
- path: "<%= cloud_config['target_dir'] %>/bootstrap_setup.sh"
permissions: "0755"
owner: "<%= cloud_config['target_owner'] %>"
echo 'Remove /opt/mesosphere and /etc/mesosphere ...'
sudo rm -rf /opt/mesosphere /etc/mesosphere
fi
-
+ if [ -e /tmp/dcos ]; then
+ echo 'Remove /tmp/dcos ...'
+ $sudo rm -rf /tmp/dcos
+ fi
---
<%
+# NOTE for cookbook developer: If you edit this script, you must update opt/dcos-grid/cloud-config.yaml
+
config = node['dcos-grid']['bootstrap']['config']
config.each {|key, value|
if !@config_params.include?(key) || value.nil? || value.empty? then
#!/usr/bin/env bash
-set -o nounset -o errexit
+<%
+# NOTE for cookbook developer: If you edit this script, you must update opt/dcos-grid/cloud-config.yaml
+-%>
+set -o nounset #-o errexit
export PATH=/usr/sbin:/usr/bin:$PATH
-iface=<%= node['dcos-grid']['bootstrap']['ip-detect']['interface'] %> # or eth0,...
-echo $(ip addr show $iface | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
\ No newline at end of file
+ifaces='<%= node['dcos-grid']['bootstrap']['ip-detect']['interface'] %>' # or eth0,...
+for iface in `echo $ifaces | tr ',' ' '`; do
+ #echo $iface
+ ip addr show $iface > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ # first detected interface
+ echo $(ip addr show $iface | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
+ break
+ fi
+done
#!/usr/bin/env bash
+<%
+# NOTE for cookbook developer: If you edit this script, you must update opt/dcos-grid/cloud-config.yaml
+-%>
PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
#!/usr/bin/env bash
+<%
+# NOTE for cookbook developer: If you edit this script, you must update opt/dcos-grid/cloud-config.yaml
+-%>
PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
echo 'Remove /opt/mesosphere and /etc/mesosphere ...'
$sudo rm -rf /opt/mesosphere /etc/mesosphere
fi
+
+if [ -e /tmp/dcos ]; then
+ echo 'Remove /tmp/dcos ...'
+ $sudo rm -rf /tmp/dcos
+fi
override_attributes(
'dcos-grid' => {
'node' => {
- 'auto_setup' => true,
+ 'auto_setup' => false,
},
},
)
--- /dev/null
+name 'dcos0-cli'
+description 'dcos0 CLI setup'
+
+run_list(
+ 'role[dcos0]',
+ 'recipe[dcos-grid::cli]',
+)
+
+#env_run_lists
+
+default_attributes(
+)
+
+override_attributes(
+)
override_attributes(
'dcos-grid' => {
'node' => {
- 'auto_setup' => true,
+ 'auto_setup' => false,
},
},
)
'dcos-grid' => {
'dcos_release_url' => 'https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh',
'docker-engine' => {
- 'version' => '1.11.2-1.el7.centos',
+ 'version_on_centos' => '1.11.2-1',
+ 'version_on_ubuntu' => '1.11.2-0',
},
'bootstrap' => {
'ip' => '192.168.56.100',
],
},
'ip-detect' => {
- 'interface' => 'enp0s8',
+ # the first detected interface's ip is adopted.
+ 'interface' => 'eth1,eth0,enp0s8,enp0s3',
},
},
'node' => {