OSDN Git Service

dcos-grid-0.3.0 dcos-grid-0.3.0
authorwhitestar <whitestar@gaea.test>
Sat, 10 Sep 2016 11:35:31 +0000 (20:35 +0900)
committerwhitestar <whitestar@gaea.test>
Sat, 10 Sep 2016 11:35:31 +0000 (20:35 +0900)
26 files changed:
cookbooks/dcos-grid/.foodcritic [new file with mode: 0644]
cookbooks/dcos-grid/.rubocop.yml
cookbooks/dcos-grid/CHANGELOG.md
cookbooks/dcos-grid/README.md
cookbooks/dcos-grid/Rakefile
cookbooks/dcos-grid/attributes/default.rb
cookbooks/dcos-grid/metadata.rb
cookbooks/dcos-grid/recipes/agent.rb
cookbooks/dcos-grid/recipes/bootstrap.rb
cookbooks/dcos-grid/recipes/cli.rb [new file with mode: 0644]
cookbooks/dcos-grid/recipes/cloud-config.rb
cookbooks/dcos-grid/recipes/master.rb
cookbooks/dcos-grid/recipes/node-commons.rb
cookbooks/dcos-grid/recipes/public-agent.rb
cookbooks/dcos-grid/templates/default/etc/apt/sources.list.d/docker.list [new file with mode: 0644]
cookbooks/dcos-grid/templates/default/opt/dcos-grid/bootstrap_setup.sh
cookbooks/dcos-grid/templates/default/opt/dcos-grid/cli_setup.sh [new file with mode: 0644]
cookbooks/dcos-grid/templates/default/opt/dcos-grid/cloud-config.yaml
cookbooks/dcos-grid/templates/default/opt/dcos-grid/genconf/config.yaml
cookbooks/dcos-grid/templates/default/opt/dcos-grid/genconf/ip-detect
cookbooks/dcos-grid/templates/default/opt/dcos-grid/node_setup.sh
cookbooks/dcos-grid/templates/default/opt/dcos-grid/uninstall.sh
roles/dcos0-agent.rb
roles/dcos0-cli.rb [new file with mode: 0644]
roles/dcos0-master.rb
roles/dcos0.rb

diff --git a/cookbooks/dcos-grid/.foodcritic b/cookbooks/dcos-grid/.foodcritic
new file mode 100644 (file)
index 0000000..3907cff
--- /dev/null
@@ -0,0 +1 @@
+~FC001
index 2c03794..17f87f1 100644 (file)
@@ -10,8 +10,6 @@ Lint/UnusedBlockArgument:
   Enabled: false
 Metrics/AbcSize:
   Enabled: false
-Style/SpaceBeforeFirstArg:
-  Enabled: false
 Style/BlockComments:
   Enabled: false
 Style/BlockDelimiters:
@@ -24,7 +22,16 @@ Style/LeadingCommentSpace:
   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
index a45072a..cbed622 100644 (file)
@@ -1,6 +1,11 @@
 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
index 3e1bd90..619660a 100644 (file)
@@ -6,6 +6,12 @@ This cookbook sets up your customized DC/OS cluster on bare metal, virtual machi
 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.
 
@@ -15,7 +21,11 @@ Attributes
 |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'`|
@@ -26,7 +36,7 @@ Attributes
 |`['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'`|
@@ -47,8 +57,7 @@ This recipe does nothing.
 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
@@ -56,10 +65,13 @@ $ ./node_setup.sh slave
 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.
@@ -103,8 +115,7 @@ $ sudo coreos-install -d /dev/sda -C stable -c ~/cloud-config.yaml
 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
@@ -112,8 +123,7 @@ $ ./node_setup.sh master
 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
@@ -125,8 +135,7 @@ This recipe sets up common environment for DC/OS node.
 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
@@ -144,7 +153,9 @@ override_attributes(
   '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',
@@ -162,7 +173,7 @@ override_attributes(
         ],
       },
       'ip-detect' => {
-        'interface' => 'enp0s8',
+        'interface' => 'eth1,enp0s8',
       },
     },
     'node' => {
@@ -229,8 +240,7 @@ override_attributes(
 Please log in each node and execute the following.
 
 ```
-$ cd /opt/dcos-grid
-$ ./uninstall.sh
+$ /opt/dcos-grid/uninstall.sh
 ```
 
 License and Authors
index b05b9e3..513cecc 100644 (file)
@@ -10,7 +10,6 @@ namespace :style do
   FoodCritic::Rake::LintTask.new(:chef) do |t|
     t.options = {
       fail_tags: ['any'],
-      tags: ['~FC001'],
     }
   end
 end
index 5d8c1a9..c90de4d 100644 (file)
 #
 
 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'
index 332ea84..d6a684a 100644 (file)
@@ -1,13 +1,16 @@
+# $ 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'
index ec12f4a..497069a 100644 (file)
@@ -27,4 +27,9 @@ if node['dcos-grid']['node']['auto_setup']
     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
index 4d64fe3..70f6e42 100644 (file)
@@ -44,3 +44,8 @@ template "#{File.dirname(genconf_dir)}/bootstrap_setup.sh" do
   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
diff --git a/cookbooks/dcos-grid/recipes/cli.rb b/cookbooks/dcos-grid/recipes/cli.rb
new file mode 100644 (file)
index 0000000..0fc9af7
--- /dev/null
@@ -0,0 +1,61 @@
+#
+# 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
index dd17c03..3cc67cf 100644 (file)
@@ -36,3 +36,10 @@ template "#{File.dirname(genconf_dir)}/cloud-config.yaml" do
   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
index 7be0312..357170e 100644 (file)
@@ -27,4 +27,9 @@ if node['dcos-grid']['node']['auto_setup']
     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
index 26e1963..c7b7ebf 100644 (file)
@@ -17,6 +17,8 @@
 # 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
@@ -34,6 +36,10 @@ template "#{File.dirname(genconf_dir)}/uninstall.sh" do
   mode '0755'
 end
 
+group 'nogroup' do
+  action :create
+end
+
 case node['platform_family']
 when 'rhel'
   service 'firewalld' do
@@ -65,56 +71,125 @@ when 'rhel'
     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
index 3e5c5ba..d2a7ecf 100644 (file)
@@ -27,4 +27,9 @@ if node['dcos-grid']['node']['auto_setup']
     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
diff --git a/cookbooks/dcos-grid/templates/default/etc/apt/sources.list.d/docker.list b/cookbooks/dcos-grid/templates/default/etc/apt/sources.list.d/docker.list
new file mode 100644 (file)
index 0000000..d465b0a
--- /dev/null
@@ -0,0 +1 @@
+deb https://apt.dockerproject.org/repo ubuntu-<%= node['lsb']['codename'] %> main
index 806b3c0..1291009 100644 (file)
@@ -1,4 +1,7 @@
 #!/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`
 
diff --git a/cookbooks/dcos-grid/templates/default/opt/dcos-grid/cli_setup.sh b/cookbooks/dcos-grid/templates/default/opt/dcos-grid/cli_setup.sh
new file mode 100644 (file)
index 0000000..889ebc3
--- /dev/null
@@ -0,0 +1,19 @@
+#!/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
index b3feab2..595d14f 100644 (file)
@@ -99,10 +99,18 @@ dcos_config.each {|key, value|
     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'] %>"
@@ -175,4 +183,7 @@ dcos_config.each {|key, value|
         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
index bcb2631..e6c9dd4 100644 (file)
@@ -1,5 +1,7 @@
 ---
 <%
+# 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
index f0df3e0..ad1c1e9 100644 (file)
@@ -1,5 +1,16 @@
 #!/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
index 9f168ac..8680671 100644 (file)
@@ -1,4 +1,7 @@
 #!/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`
 
index 7548268..4487c9f 100644 (file)
@@ -1,4 +1,7 @@
 #!/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`
 
@@ -18,3 +21,8 @@ if [ -e /opt/mesosphere ]; then
   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
index cb7c809..b3d0d90 100644 (file)
@@ -14,7 +14,7 @@ default_attributes(
 override_attributes(
   'dcos-grid' => {
     'node' => {
-      'auto_setup' => true,
+      'auto_setup' => false,
     },
   },
 )
diff --git a/roles/dcos0-cli.rb b/roles/dcos0-cli.rb
new file mode 100644 (file)
index 0000000..d42a3a7
--- /dev/null
@@ -0,0 +1,15 @@
+name 'dcos0-cli'
+description 'dcos0 CLI setup'
+
+run_list(
+  'role[dcos0]',
+  'recipe[dcos-grid::cli]',
+)
+
+#env_run_lists
+
+default_attributes(
+)
+
+override_attributes(
+)
index 49a8c9f..a71db73 100644 (file)
@@ -14,7 +14,7 @@ default_attributes(
 override_attributes(
   'dcos-grid' => {
     'node' => {
-      'auto_setup' => true,
+      'auto_setup' => false,
     },
   },
 )
index 55bb66a..fe620d0 100644 (file)
@@ -13,7 +13,8 @@ override_attributes(
   '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',
@@ -31,7 +32,8 @@ override_attributes(
         ],
       },
       'ip-detect' => {
-        'interface' => 'enp0s8',
+        # the first detected interface's ip is adopted.
+        'interface' => 'eth1,eth0,enp0s8,enp0s3',
       },
     },
     'node' => {