OSDN Git Service

dcos-grid-0.4.3 dcos-grid-0.4.3
authorwhitestar <whitestar@gaea.test>
Sun, 20 Nov 2016 10:53:32 +0000 (19:53 +0900)
committerwhitestar <whitestar@gaea.test>
Sun, 20 Nov 2016 10:53:32 +0000 (19:53 +0900)
20 files changed:
cookbooks/dcos-grid/CHANGELOG.md
cookbooks/dcos-grid/README.md
cookbooks/dcos-grid/attributes/default.rb
cookbooks/dcos-grid/libraries/helper.rb
cookbooks/dcos-grid/metadata.rb
cookbooks/dcos-grid/recipes/agent.rb
cookbooks/dcos-grid/recipes/bootstrap.rb
cookbooks/dcos-grid/recipes/cli.rb
cookbooks/dcos-grid/recipes/master.rb
cookbooks/dcos-grid/recipes/node.rb
cookbooks/dcos-grid/recipes/public-agent.rb
cookbooks/dcos-grid/templates/default/opt/dcos-grid/bootstrap_setup.sh
cookbooks/dcos-grid/templates/default/opt/dcos-grid/bootstrap_upgrade.sh [new file with mode: 0644]
cookbooks/dcos-grid/templates/default/opt/dcos-grid/cli_setup.sh
cookbooks/dcos-grid/templates/default/opt/dcos-grid/genconf/config.yaml
cookbooks/dcos-grid/templates/default/opt/dcos-grid/node_setup.sh
cookbooks/dcos-grid/templates/default/opt/dcos-grid/node_upgrade.sh [new file with mode: 0644]
cookbooks/dcos-grid/templates/default/opt/dcos-grid/uninstall.sh
roles/dcos0-cli.rb
roles/dcos0.rb

index 6737602..8b59d89 100644 (file)
@@ -1,6 +1,14 @@
 dcos-grid CHANGELOG
 ===================
 
+0.4.3
+-----
+- refactoring.
+- updates `docker-grid` cookbook dependency.
+- updates `['dcos-grid']['dcos_cli_release_url']` default value.
+- adds `['dcos-grid']['dcos_cli_upgrade']` attribute.
+- adds node upgrade scripts.
+
 0.4.2
 -----
 - bug fix: generating genconf/config.yaml
index 735d330..f910c62 100644 (file)
@@ -22,6 +22,7 @@ This cookbook sets up your customized DC/OS cluster on bare metal, virtual machi
     - [dcos-grid::node-commons](#dcos-gridnode-commons)
     - [dcos-grid::public-agent](#dcos-gridpublic-agent)
   - [Role Examples](#role-examples)
+  - [Upgrade DC/OS (ver. 0.4.3 or later)](#upgrade-dcos-ver-043-or-later)
   - [Uninstall DC/OS](#uninstall-dcos)
 - [License and Authors](#license-and-authors)
 
@@ -44,7 +45,8 @@ This cookbook sets up your customized DC/OS cluster on bare metal, virtual machi
 |Key|Type|Description, example|Default|
 |:--|:--|:--|:--|
 |`['dcos-grid']['dcos_release_url']`|String|DC/OS download URL.|`'https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh'`|
-|`['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']['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/dcos-1.8/dcos'`|
+|`['dcos-grid']['dcos_cli_upgrade']`|Boolean|Whether upgrade DC/OS CLI or not (ver. 0.4.3 or later).|`false`|
 |`['dcos-grid']['docker']['apt_repo']['url']`|String|DEPRECATED: use `['docker-grid']['apt_repo']['url']` (ver. 0.4.0 or later)|`nil`|
 |`['dcos-grid']['docker']['apt_repo']['keyserver']`|String|DEPRECATED: use `['docker-grid']['apt_repo']['keyserver']` (ver. 0.4.0 or later)|`nil`|
 |`['dcos-grid']['docker']['apt_repo']['recv-keys']`|String|DEPRECATED: use `['docker-grid']['apt_repo']['recv-keys']` (ver. 0.4.0 or later)|`nil`|
@@ -204,6 +206,7 @@ override_attributes(
   'dcos-grid' => {
     'dcos_release_url' => 'https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh',
     #'dcos_release_url' => 'https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh',
+    'dcos_cli_release_url' => 'https://downloads.dcos.io/binaries/cli/linux/x86-64/dcos-1.8/dcos',
     'bootstrap' => {
       'ip' => '192.168.56.100',
       'port' => '8080',
@@ -244,7 +247,7 @@ run_list(
 )
 ```
 
-- `roles/dcos-master.rb`
+- `roles/dcos0-master.rb`
 
 ```ruby
 cluster_name = 'dcos0'
@@ -288,6 +291,50 @@ override_attributes(
 )
 ```
 
+- `roles/dcos0-cli.rb`
+
+```ruby
+cluster_name = 'dcos0'
+
+name "#{cluster_name}-cli"
+description "#{cluster_name} CLI setup"
+
+run_list(
+  "role[#{cluster_name}]",
+  'recipe[dcos-grid::cli]',
+)
+
+override_attributes(
+  'dcos-grid' => {
+    'dcos_cli_upgrade' => true,
+  },
+)
+```
+
+### Upgrade DC/OS (ver. 0.4.3 or later)
+
+- Update attributes about DC/OS release URL (`['dcos-grid']['dcos_release_url']`) and configurations (`['dcos-grid']['bootstrap']['config']`).
+
+- execute `sudo chef-client` on each node.
+
+- upgrade the boostrap node.
+
+```
+$ /opt/dcos-grid/bootstrap_upgrade.sh
+```
+
+- upgrade each follower master node at first, and then upgrade the leader master node.
+
+```
+$ /opt/dcos-grid/node_upgrade.sh master
+```
+
+- upgrade each agent node.
+
+```
+$ /opt/dcos-grid/node_upgrade.sh {slave|slave_public}
+```
+
 ### Uninstall DC/OS
 
 Please log in each node and execute the following.
index f38cc6a..576b99a 100644 (file)
@@ -18,7 +18,8 @@
 #
 
 default['dcos-grid']['dcos_release_url'] = 'https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh'
-default['dcos-grid']['dcos_cli_release_url'] = 'https://downloads.dcos.io/binaries/cli/linux/x86-64/0.4.10/dcos'
+default['dcos-grid']['dcos_cli_release_url'] = 'https://downloads.dcos.io/binaries/cli/linux/x86-64/dcos-1.8/dcos'
+default['dcos-grid']['dcos_cli_upgrade'] = false
 # DEPRECATED: ['dcos-grid']['docker'][*] attributes. Use ['docker-grid'][*]
 default['dcos-grid']['docker']['apt_repo'] = {
   'url' => nil,
index 673d84c..e03d1c4 100644 (file)
@@ -48,6 +48,11 @@ module DCOSGrid
       dns_search
       master_dns_bindall
       resolvers
+      use_proxy
+      http_proxy
+      https_proxy
+      no_proxy
+      check_time
       docker_remove_delay
       gc_delay
       log_directory
@@ -66,6 +71,9 @@ module DCOSGrid
       oauth_enabled
       oauth_issuer_url
       oauth_client_id
+      dcos_overlay_enable
+      dcos_overlay_config_attempts
+      dcos_overlay_mtu
       dcos_overlay_network
       vtep_subnet
       vtep_mac_oui
index e5e6daa..1ba979a 100644 (file)
@@ -5,7 +5,7 @@ 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.4.2'
+version          '0.4.3'
 source_url       'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
 issues_url       'https://osdn.jp/projects/metasearch/ticket'
 
@@ -16,4 +16,4 @@ end
 supports 'ubuntu', '>= 16.04'
 
 # external cookbooks
-depends 'docker-grid', '>= 0.2.0'
+depends 'docker-grid', '>= 0.2.1'
index 497069a..9ce9a23 100644 (file)
@@ -23,13 +23,16 @@ if node['dcos-grid']['node']['auto_setup']
   bash 'setup_private_agent_node' do
     code <<-"EOH"
       cd #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}
-      ./node_setup.sh slave
+      ./node_setup.sh -y slave
     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
+Note: You must execute the following command.
+  - Install (only once):
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_setup.sh slave
+  - Upgrade:
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_upgrade.sh slave
   EOM
 end
index 119b762..4a35cd4 100644 (file)
@@ -39,14 +39,22 @@ template "#{genconf_dir}/ip-detect" do
   mode '0755'
 end
 
-template "#{File.dirname(genconf_dir)}/bootstrap_setup.sh" do
-  source  'opt/dcos-grid/bootstrap_setup.sh'
-  owner 'root'
-  group 'root'
-  mode '0755'
-end
+[
+  'bootstrap_setup.sh',
+  'bootstrap_upgrade.sh',
+].each {|script_file|
+  template "#{File.dirname(genconf_dir)}/#{script_file}" do
+    source  "opt/dcos-grid/#{script_file}"
+    owner 'root'
+    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
+  - Install:
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/bootstrap_setup.sh
+  - Upgrade:
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/bootstrap_upgrade.sh
 EOM
index 0fc9af7..c17ac3d 100644 (file)
@@ -55,7 +55,7 @@ end
 
 bash 'install_dcos_cli' do
   code <<-"EOH"
-    #{File.dirname(genconf_dir)}/cli_setup.sh
+    #{File.dirname(genconf_dir)}/cli_setup.sh -y
   EOH
-  not_if { ::File.exist?('/usr/local/bin/dcos') }
+  not_if { ::File.exist?('/usr/local/bin/dcos') } unless node['dcos-grid']['dcos_cli_upgrade']
 end
index 357170e..8be98f3 100644 (file)
@@ -23,13 +23,16 @@ if node['dcos-grid']['node']['auto_setup']
   bash 'setup_master_node' do
     code <<-"EOH"
       cd #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}
-      ./node_setup.sh master
+      ./node_setup.sh -y master
     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
+Note: You must execute the following command.
+  - Install (only once):
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_setup.sh master
+  - Upgrade:
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_upgrade.sh master
   EOM
 end
index 8b94ba4..758860b 100644 (file)
@@ -21,9 +21,14 @@ include_recipe 'dcos-grid::node-commons'
 
 genconf_dir = node['dcos-grid']['bootstrap']['genconf_dir']
 
-template "#{File.dirname(genconf_dir)}/node_setup.sh" do
-  source  'opt/dcos-grid/node_setup.sh'
-  owner 'root'
-  group 'root'
-  mode '0755'
-end
+[
+  'node_setup.sh',
+  'node_upgrade.sh',
+].each {|script_file|
+  template "#{File.dirname(genconf_dir)}/#{script_file}" do
+    source  "opt/dcos-grid/#{script_file}"
+    owner 'root'
+    group 'root'
+    mode '0755'
+  end
+}
index 46b7d49..a20c04a 100644 (file)
@@ -23,13 +23,16 @@ if node['dcos-grid']['node']['auto_setup']
   bash 'setup_public_agent_node' do
     code <<-"EOH"
       cd #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}
-      ./node_setup.sh slave_public
+      ./node_setup.sh -y slave_public
     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_public
+Note: You must execute the following command.
+  - Install (only once):
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_setup.sh slave_public
+  - Upgrade:
+    $ #{File.dirname(node['dcos-grid']['bootstrap']['genconf_dir'])}/node_upgrade.sh slave_public
   EOM
 end
index 806b3c0..0149f66 100644 (file)
@@ -1,17 +1,82 @@
 #!/usr/bin/env bash
 
+# https://dcos.io/docs/1.8/administration/installing/custom/advanced/
+# https://dcos.io/docs/1.7/administration/installing/custom/advanced/
+
 PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
 
+usage() {
+  echo 'Usage: bootstrap_setup.sh [-y] [-h]'
+  echo 'This script sets up DC/OS bootstrap node.'
+  echo
+  echo "Options:"
+  echo "  -h: this help."
+  echo "  -y: always yes."
+  echo
+}
+
+ARGS="$@"
+# Validation
+while getopts 'yh' OPT; do
+  case $OPT in
+    'y' )
+      always_yes=1
+      ;;
+    'h' )
+      usage
+      exit 0
+      ;;
+    '?' )
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+shift $((OPTIND - 1))
+
+echo 'This node will be set up as a Bootstrap node.'
+while true; do
+  if [ "$always_yes" = 1 ]; then
+    break
+  fi
+  echo -n 'Continue the setup? [y/N]: '
+  read answer
+  case $answer in
+    'y' | 'yes' )
+      break
+      ;;
+    '' | 'n' | 'no' )
+      echo 'Setup was aborted by user.'
+      exit 0
+      ;;
+    * )
+      ;;
+  esac
+done
+
 user=`whoami`
 sudo='sudo'
 if [ $user = 'root' ]; then
   sudo=''
 fi
 
-cd <%= File.dirname(node['dcos-grid']['bootstrap']['genconf_dir']) %>
+# Setup
+CMD='cd <%= File.dirname(node['dcos-grid']['bootstrap']['genconf_dir']) %>'
+echo "Command: $CMD"
+$CMD
+
 echo 'Downloading DC/OS release ...'
-$sudo curl -O <%= node['dcos-grid']['dcos_release_url'] %>
+CMD="$sudo curl -O <%= node['dcos-grid']['dcos_release_url'] %>"
+echo "Command: $CMD"
+$CMD
+
 echo 'Generating DC/OS configurations ...'
-$sudo bash dcos_generate_config.sh
+CMD="$sudo bash dcos_generate_config.sh"
+echo "Command: $CMD"
+$CMD
+
 echo 'Launching Docker container for the bootstrap service ...'
-$sudo docker run -d -p <%= node['dcos-grid']['bootstrap']['port'] %>:80 -v $PWD/genconf/serve:/usr/share/nginx/html:ro nginx
+CMD="$sudo docker run -d -p <%= node['dcos-grid']['bootstrap']['port'] %>:80 -v $PWD/genconf/serve:/usr/share/nginx/html:ro nginx"
+echo "Command: $CMD"
+$CMD
diff --git a/cookbooks/dcos-grid/templates/default/opt/dcos-grid/bootstrap_upgrade.sh b/cookbooks/dcos-grid/templates/default/opt/dcos-grid/bootstrap_upgrade.sh
new file mode 100644 (file)
index 0000000..7340512
--- /dev/null
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+
+# https://dcos.io/docs/1.8/administration/upgrading/
+# https://dcos.io/docs/1.7/administration/upgrading/
+
+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
+
+usage() {
+  echo 'Usage: bootstrap_upgrade.sh [-y] [-h]'
+  echo 'This script upgrades DC/OS bootstrap node.'
+  echo
+  echo "Options:"
+  echo "  -h: this help."
+  echo "  -y: always yes."
+  echo
+}
+
+ARGS="$@"
+# Validation
+while getopts 'yh' OPT; do
+  case $OPT in
+    'y' )
+      always_yes=1
+      ;;
+    'h' )
+      usage
+      exit 0
+      ;;
+    '?' )
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+shift $((OPTIND - 1))
+
+echo 'This node will be upgraded as a Bootstrap node.'
+while true; do
+  if [ "$always_yes" = 1 ]; then
+    break
+  fi
+  echo -n 'Continue the upgrade? [y/N]: '
+  read answer
+  case $answer in
+    'y' | 'yes' )
+      break
+      ;;
+    '' | 'n' | 'no' )
+      echo 'Upgrade was aborted by user.'
+      exit 0
+      ;;
+    * )
+      ;;
+  esac
+done
+
+user=`whoami`
+sudo='sudo'
+if [ $user = 'root' ]; then
+  sudo=''
+fi
+
+# Upgrade
+CMD='cd <%= File.dirname(node['dcos-grid']['bootstrap']['genconf_dir']) %>'
+echo "Command: $CMD"
+$CMD
+
+echo 'Downloading new DC/OS release ...'
+CMD="$sudo curl -O <%= node['dcos-grid']['dcos_release_url'] %>"
+echo "Command: $CMD"
+$CMD
+
+echo 'Generating new DC/OS configurations ...'
+CMD="$sudo bash dcos_generate_config.sh"
+echo "Command: $CMD"
+$CMD
+
+echo 'Disable Docker restarts in dcos_install.sh'
+CMD="$sudo sed -i -e 's/systemctl restart systemd-journald//g' -e 's/systemctl restart docker//g' genconf/serve/dcos_install.sh"
+echo "Command: $CMD"
+eval $CMD
+
+port=<%= node['dcos-grid']['bootstrap']['port'] %>
+if $sudo docker ps | grep "${port}->80"; then
+  echo 'Docker container for the bootstrap service is already running.'
+else
+  echo 'Launching Docker container for the bootstrap service ...'
+  CMD="$sudo docker run -d -p ${port}:80 -v $PWD/genconf/serve:/usr/share/nginx/html:ro nginx"
+  echo "Command: $CMD"
+  $CMD
+fi
index 889ebc3..4135fc4 100644 (file)
@@ -2,15 +2,67 @@
 
 PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
 
+usage() {
+  echo 'Usage: cli_setup.sh [-y] [-h]'
+  echo 'This script sets up DC/OS client.'
+  echo
+  echo "Options:"
+  echo "  -h: this help."
+  echo "  -y: always yes."
+  echo
+}
+
+ARGS="$@"
+# Validation
+while getopts 'yh' OPT; do
+  case $OPT in
+    'y' )
+      always_yes=1
+      ;;
+    'h' )
+      usage
+      exit 0
+      ;;
+    '?' )
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+shift $((OPTIND - 1))
+
+echo 'DC/OS client will be installed.'
+while true; do
+  if [ "$always_yes" = 1 ]; then
+    break
+  fi
+  echo -n 'Continue the install? [y/N]: '
+  read answer
+  case $answer in
+    'y' | 'yes' )
+      break
+      ;;
+    '' | 'n' | 'no' )
+      echo 'Install was aborted by user.'
+      exit 0
+      ;;
+    * )
+      ;;
+  esac
+done
+
 user=`whoami`
 sudo='sudo'
 if [ $user = 'root' ]; then
   sudo=''
 fi
 
-$sudo curl <%= node['dcos-grid']['dcos_cli_release_url'] %> -o /usr/local/bin/dcos && 
+CMD="$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] %>
+$sudo /usr/local/bin/dcos config set core.dcos_url https://<%= node['dcos-grid']['bootstrap']['config']['master_list'][0] %>"
+echo "Command: $CMD"
+eval $CMD
 
 # old way
 #mkdir -p dcos && cd dcos && 
index 7199f89..92aeaea 100644 (file)
@@ -2,6 +2,7 @@
 dcos_config = node['dcos-grid']['bootstrap']['config']
 
 require 'yaml'
-yaml_str = YAML::dump(dcos_config.to_hash)
+#yaml_str = YAML::dump(dcos_config.to_hash)
+yaml_str = dcos_config.to_hash.to_yaml
 -%>
 <%= yaml_str %>
\ No newline at end of file
index b167159..063a4b3 100644 (file)
@@ -1,21 +1,45 @@
 #!/usr/bin/env bash
 
+# https://dcos.io/docs/1.8/administration/installing/custom/advanced/
+# https://dcos.io/docs/1.7/administration/installing/custom/advanced/
+
 PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
 
-help() {
-  echo 'Usage: node_setup.sh {master,agent,slave,agent_public,slave_public}'
+usage() {
+  echo 'Usage: node_setup.sh [-y] [-h] {master,agent,slave,agent_public,slave_public}'
+  echo 'This script sets up DC/OS master or agent node.'
+  echo
+  echo "Options:"
+  echo "  -h: this help."
+  echo "  -y: always yes."
+  echo
 }
 
 ARGS="$@"
-ROLE=$1
-
 # Validation
+while getopts 'yh' OPT; do
+  case $OPT in
+    'y' )
+      always_yes=1
+      ;;
+    'h' )
+      usage
+      exit 0
+      ;;
+    '?' )
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+shift $((OPTIND - 1))
+
 if [ $# != 1 ]; then
-  help
+  usage
   exit 1
-elif [ $ROLE = '-h' ]; then
-  help
-  exit 0
+else
+  ROLE=$1
 fi
 
 case "$ROLE" in
@@ -29,12 +53,33 @@ case "$ROLE" in
     ROLE='slave_public'
     ;;
   * )
-    help
+    usage
     exit 1
     ;;
 esac
 echo "Node Role: $ROLE"
 
+echo "This node will be set up as a $ROLE node."
+while true; do
+  if [ "$always_yes" = 1 ]; then
+    break
+  fi
+  echo -n 'Continue the setup? [y/N]: '
+  read answer
+  case $answer in
+    'y' | 'yes' )
+      break
+      ;;
+    '' | 'n' | 'no' )
+      echo 'Setup was aborted by user.'
+      exit 0
+      ;;
+    * )
+      ;;
+  esac
+done
+
+# Setup
 if [ -d /opt/mesosphere ]; then
   echo -e '[ERROR] DC/OS is already installed.'
   exit 1
@@ -47,11 +92,20 @@ if [ $user = 'root' ]; then
 fi
 
 if [ ! -d /tmp/dcos ]; then
-  mkdir /tmp/dcos
+  CMD='mkdir /tmp/dcos'
+  echo "Command: $CMD"
+  $CMD
 fi
-cd /tmp/dcos
+CMD='cd /tmp/dcos'
+echo "Command: $CMD"
+$CMD
+
 echo 'Downloading dcos_install.sh ...'
-curl -O <%= node['dcos-grid']['bootstrap']['config']['bootstrap_url'] %>/dcos_install.sh
-echo "Installing DC/OS $ROLE node ..."
-$sudo bash dcos_install.sh $ROLE
+CMD='curl -O <%= node['dcos-grid']['bootstrap']['config']['bootstrap_url'] %>/dcos_install.sh'
+echo "Command: $CMD"
+$CMD
 
+echo "Installing DC/OS $ROLE node ..."
+CMD="$sudo bash dcos_install.sh $ROLE"
+echo "Command: $CMD"
+$CMD
diff --git a/cookbooks/dcos-grid/templates/default/opt/dcos-grid/node_upgrade.sh b/cookbooks/dcos-grid/templates/default/opt/dcos-grid/node_upgrade.sh
new file mode 100644 (file)
index 0000000..7356edf
--- /dev/null
@@ -0,0 +1,199 @@
+#!/usr/bin/env bash
+
+# https://dcos.io/docs/1.8/administration/installing/custom/advanced/
+# https://dcos.io/docs/1.7/administration/installing/custom/advanced/
+
+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
+
+exhibitor_storage_backend=<%= node['dcos-grid']['bootstrap']['config']['exhibitor_storage_backend'] %>
+
+usage() {
+  echo 'Usage: node_upgrade.sh [-y] [-h] {master,agent,slave,agent_public,slave_public}'
+  echo 'This script upgrades DC/OS master or agent node.'
+  echo
+  echo "Options:"
+  echo "  -h: this help."
+  echo "  -y: always yes."
+  echo
+}
+
+ARGS="$@"
+# Validation
+while getopts 'yh' OPT; do
+  case $OPT in
+    'y' )
+      always_yes=1
+      ;;
+    'h' )
+      usage
+      exit 0
+      ;;
+    '?' )
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+shift $((OPTIND - 1))
+
+if [ $# != 1 ]; then
+  usage
+  exit 1
+else
+  ROLE=$1
+fi
+
+case "$ROLE" in
+  'master' | 'slave' | 'slave_public' )
+    ;;
+  # aliases
+  'agent' | 'agent_public' )
+    ROLE=${ROLE//agent/slave}
+    ;;
+  'public_agent' | 'public-agent' )
+    ROLE='slave_public'
+    ;;
+  * )
+    usage
+    exit 1
+    ;;
+esac
+echo "Node Role: $ROLE"
+
+echo "This node will be upgraded as a $ROLE node."
+while true; do
+  if [ "$always_yes" = 1 ]; then
+    break
+  fi
+  echo -n 'Continue the upgrade? [y/N]: '
+  read answer
+  case $answer in
+    'y' | 'yes' )
+      break
+      ;;
+    '' | 'n' | 'no' )
+      echo 'Upgrade was aborted by user.'
+      exit 0
+      ;;
+    * )
+      ;;
+  esac
+done
+
+user=`whoami`
+sudo='sudo'
+if [ $user = 'root' ]; then
+  sudo=''
+fi
+
+if [ $ROLE = 'master' ]; then
+  zk_mode=`echo stat | /opt/mesosphere/bin/toybox nc localhost 2181 | grep "Mode:"`
+  echo "Zookeeper $zk_mode"
+
+  if echo $zk_mode | grep 'leader'; then
+    echo 'This node is Zookeeper leader. You should upgrade Zookeeper leader node at the end.'
+    while true; do
+      if [ "$always_yes" = 1 ]; then
+        break
+      fi
+      echo -n 'Continue the upgrade? [y/N]: '
+      read answer
+      case $answer in
+        'y' | 'yes' )
+          break
+          ;;
+        '' | 'n' | 'no' )
+          echo 'Upgrade was aborted by user.'
+          exit 0
+          ;;
+        * )
+          ;;
+      esac
+    done
+  fi
+fi
+
+# Upgrade
+if [ ! -d /tmp/dcos ]; then
+  CMD='mkdir /tmp/dcos'
+  echo "Command: $CMD"
+  $CMD
+fi
+CMD='cd /tmp/dcos'
+echo "Command: $CMD"
+$CMD
+
+echo 'Downloading new dcos_install.sh ...'
+CMD="$sudo curl -O <%= node['dcos-grid']['bootstrap']['config']['bootstrap_url'] %>/dcos_install.sh"
+echo "Command: $CMD"
+$CMD
+
+echo 'Uninstalling pkgpanda ...'
+CMD="$sudo -i /opt/mesosphere/bin/pkgpanda uninstall"
+echo "Command: $CMD"
+$CMD
+
+echo 'Removing data directory ...'
+CMD="$sudo rm -rf /opt/mesosphere /etc/mesosphere"
+echo "Command: $CMD"
+$CMD
+
+case "$ROLE" in
+  'master' )
+    if [ $exhibitor_storage_backend != 'static' ]; then
+      CMD="$sudo useradd --system --home-dir /opt/mesosphere --shell /sbin/nologin -c 'DCOS System User' dcos_exhibitor; $sudo chown -R dcos_exhibitor /var/lib/zookeeper"
+      echo "Command: $CMD"
+      $CMD
+    fi
+    ;;
+  'slave' | 'slave_public' )
+<< "#__CO__"
+    # ???: If you have not made explicit disk size reservations, you must create
+    #  a placeholder for the disk reservation file. This prevents the installer
+    #  from building a new disk reservation file that might conflict with your
+    #  stored agent metadata:
+    #    $ sudo mkdir -p /var/lib/dcos
+    #    $ sudo touch /var/lib/dcos/mesos-resources
+    CMD="$sudo mkdir -p /var/lib/dcos; $sudo touch /var/lib/dcos/mesos-resources"
+    echo "Command: $CMD"
+    $CMD
+#__CO__
+    ;;
+  * )
+    ;;
+esac
+
+echo 'Waiting for releasing of service ports ...'
+sleep 60s
+
+echo "Installing DC/OS $ROLE node ..."
+CMD="$sudo bash dcos_install.sh $ROLE"
+echo "Command: $CMD"
+$CMD
+
+case "$ROLE" in
+  'master' )
+    cat << EOM
+Validate the upgrade
+  - Monitor the Exhibitor UI to confirm that the Master rejoins the ZooKeeper
+    quorum successfully (the status indicator will turn green). The Exhibitor
+    UI is available at http://<dcos_master>:8181/.
+  - Verify that curl http://<dcos_master_private_ip>:5050/metrics/snapshot has
+    the metric registrar/log/recovered with a value of 1.
+  - Verify that http://<dcos_master>/mesos indicates that the upgraded master
+    is running Mesos upgraded version.
+EOM
+    ;;
+  'slave' | 'slave_public' )
+    cat << EOM
+Validate the upgrade
+  - Verify that curl http://<dcos_agent_private_ip>:5051/metrics/snapshot has
+    the metric slave/registered with a value of 1.
+  - Monitor the Mesos UI to verify that the upgraded node rejoins the DC/OS
+    cluster and that tasks are reconciled (http://<dcos_master>/mesos).
+EOM
+    ;;
+  * )
+    ;;
+esac
index 3296334..f7cdafe 100644 (file)
 #!/usr/bin/env bash
 
+# https://dcos.io/docs/1.8/administration/installing/custom/uninstall/
+# https://dcos.io/docs/1.8/administration/installing/custom/uninstall/
+
 PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
 
+echo '[WARN] DC/OS does NOT support uninstall yet!'
+echo 'See https://dcos.io/docs/1.8/administration/installing/custom/uninstall/'
+
+usage() {
+  echo 'Usage: uninstall.sh [-y] [-h]'
+  echo 'This script uninstalls DC/OS.'
+  echo
+  echo "Options:"
+  echo "  -h: this help."
+  echo "  -y: always yes."
+  echo
+}
+
+ARGS="$@"
+# Validation
+while getopts 'yh' OPT; do
+  case $OPT in
+    'y' )
+      always_yes=1
+      ;;
+    'h' )
+      usage
+      exit 0
+      ;;
+    '?' )
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+shift $((OPTIND - 1))
+
+echo 'DC/OS on this node will be uninstalled.'
+while true; do
+  if [ "$always_yes" = 1 ]; then
+    break
+  fi
+  echo -n 'Continue the uninstall? [y/N]: '
+  read answer
+  case $answer in
+    'y' | 'yes' )
+      break
+      ;;
+    '' | 'n' | 'no' )
+      echo 'Uninstall was aborted by user.'
+      exit 0
+      ;;
+    * )
+      ;;
+  esac
+done
+
 user=`whoami`
 sudo='sudo'
 if [ $user = 'root' ]; then
   sudo=''
 fi
 
+install_dir=<%= File.dirname(node['dcos-grid']['bootstrap']['genconf_dir']) %>
+
+# for Bootstrap node
+if ls $install_dir | grep 'dcos-genconf.*.tar'; then
+  CMD="$sudo rm ${install_dir}/dcos-genconf.*.tar"
+  echo "Command: $CMD"
+  $CMD
+fi
+
+if ls $install_dir | grep dcos_generate_config.sh; then
+  CMD="$sudo rm ${install_dir}/dcos_generate_config.sh"
+  echo "Command: $CMD"
+  $CMD
+fi
+
+# for Master and Agent nodes
 pkgpanda=/opt/mesosphere/bin/pkgpanda
 if [ -e "$pkgpanda" ]; then
   echo 'Uninstalling DC/OS packages...'
-  $sudo -i $pkgpanda uninstall
+  CMD="$sudo -i $pkgpanda uninstall"
+  echo "Command: $CMD"
+  $CMD
 fi
 
 if [ -e /opt/mesosphere ]; then
   echo 'Remove /opt/mesosphere and /etc/mesosphere ...'
-  $sudo rm -rf /opt/mesosphere /etc/mesosphere
+  CMD="$sudo rm -rf /opt/mesosphere /etc/mesosphere"
+  echo "Command: $CMD"
+  $CMD
 fi
 
 if [ -e /tmp/dcos ]; then
   echo 'Remove /tmp/dcos ...'
-  $sudo rm -rf /tmp/dcos
+  CMD="$sudo rm -rf /tmp/dcos"
+  echo "Command: $CMD"
+  $CMD
 fi
+
+echo 'Uninstalled DC/OS successfully.'
index bf1c9ba..93f130a 100644 (file)
@@ -14,4 +14,7 @@ default_attributes(
 )
 
 override_attributes(
+  'dcos-grid' => {
+    'dcos_cli_upgrade' => true,
+  },
 )
index 35bf946..00c0e78 100644 (file)
@@ -13,8 +13,13 @@ default_attributes(
 
 override_attributes(
   'dcos-grid' => {
-    'dcos_release_url' => 'https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh',
     #'dcos_release_url' => 'https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh',
+    'dcos_release_url' => 'https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh',
+    # 1.8.6
+    #'dcos_release_url' => 'https://downloads.dcos.io/dcos/stable/commit/cfccfbf84bbba30e695ae4887b65db44ff216b1d/dcos_generate_config.sh',
+    # 1.7-open
+    #'dcos_release_url' => 'https://downloads.dcos.io/dcos/EarlyAccess/commit/14509fe1e7899f439527fb39867194c7a425c771/dcos_generate_config.sh',
+    'dcos_cli_release_url' => 'https://downloads.dcos.io/binaries/cli/linux/x86-64/dcos-1.8/dcos',
     'bootstrap' => {
       'ip' => '192.168.56.100',
       'port' => '8080',
@@ -22,8 +27,8 @@ override_attributes(
         'cluster_name' => cluster_name,
         'master_list' => [
           '192.168.56.101',
-          #'192.168.56.102',
-          #'192.168.56.103',
+          '192.168.56.102',
+          '192.168.56.103',
         ],
         'resolvers' => [
           '8.8.8.8',