From 59983ba6488066eefc2bc229470320907996f6ac Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Tue, 12 Apr 2016 13:18:57 -0500 Subject: [PATCH 01/19] Initial commit --- Berksfile | 3 + attributes/default.rb | 77 +++++++++++++++++++ recipes/default.rb | 63 +++++++++++++++ spec/spec_helper.rb | 2 + spec/unit/recipes/default_spec.rb | 20 +++++ templates/default/config.yaml.erb | 7 ++ .../default/serverspec/default_spec.rb | 9 +++ .../helpers/serverspec/spec_helper.rb | 8 ++ 8 files changed, 189 insertions(+) create mode 100644 Berksfile create mode 100644 attributes/default.rb create mode 100644 recipes/default.rb create mode 100644 spec/spec_helper.rb create mode 100644 spec/unit/recipes/default_spec.rb create mode 100644 templates/default/config.yaml.erb create mode 100644 test/integration/default/serverspec/default_spec.rb create mode 100644 test/integration/helpers/serverspec/spec_helper.rb diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..34fea21 --- /dev/null +++ b/Berksfile @@ -0,0 +1,3 @@ +source 'https://supermarket.chef.io' + +metadata diff --git a/attributes/default.rb b/attributes/default.rb new file mode 100644 index 0000000..04b7229 --- /dev/null +++ b/attributes/default.rb @@ -0,0 +1,77 @@ +# +# Author:: Matt Ray +# Cookbook Name:: mesosphere +# +# Copyright 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. +# + +default['mesosphere']['dcos_version'] = 'stable' +default['mesosphere']['dcos_role'] = 'master' # options are master, slave or slave_public + +default['mesosphere']['cluster_name'] = 'DCOS' +default['mesosphere']['master_discovery'] = 'static' +default['mesosphere']['exhibitor_storage_backend'] = 'static' +default['mesosphere']['bootstrap_url'] = 'file:///opt/dcos_install_tmp' + +# ipv4 only, must be odd number 1-9 +default['mesosphere']['master_list'] = [] +# upstream DNS for MesosDNS +default['mesosphere']['resolvers'] = ['8.8.8.8', '8.8.4.4'] + +# All Possible Parameters / Attrbutes with logical defaults and their dependencies if any + +# Config.yaml Parameters +# EE Only +# $superuser_username = 'admin' +# $superuser_password_hash = undef + +# Exhibitor Storage Backend Dependencies +# $exhibitor_storage_backend:'zookeeper': +# Bootstrap exhibitor using another zk cluster for shared file data +# $exhibitor_zk_hosts = undef # Comma list of $HOST:2181, $HOST:2181... +# $exhibitor_zk_path = '/dcos' + +# $exhibitor_storage_backend: 'shared_filesystem' +# This parameter specifies the absolute path to the folder +# that Exhibitor uses to coordinate its configuration. This should +# be a directory inside of a Network File System (NFS) mount. For +# example, if every master has /fserv mounted via NFS, set as +# exhibitor_fs_config_dir: /fserv/dcos-exhibitor. +# $exhibitor_fs_config_dir = undef + +# exhibitor_storage_backend:'aws_s3' +# $aws_access_key_id = undef +# $aws_region = undef +# $aws_secret_access_key = undef +# $s3_bucket = undef +# # This parameter specifies S3 prefix to be used within your +# # S3 bucket to be used by Exhibito +# $s3_prefix = undef + +# # Master Discovery Dependencies +# # master_discovery:'static' +# $master_list = $::master_list + +# master_discovery: 'vrrp' +# This parameter specifies the virtual router ID of the Keepalived cluster. +# You must use the same virtual router ID across your cluster. +# $keepalived_router_id = undef +# # This parameter specifies the interface that Keepalived uses. +# $keepalived_interface = undef +# # If you've set your auth_type to PASS, this parameter specifies the password +# # that you set for auth_pass in your Keepalived configuration file. +# $keepalived_pass = undef +# # This parameter specifies the VIP in use by your Keepalived cluster. +# $keepalived_virtual_ipaddress = undef diff --git a/recipes/default.rb b/recipes/default.rb new file mode 100644 index 0000000..50e0726 --- /dev/null +++ b/recipes/default.rb @@ -0,0 +1,63 @@ +# +# Cookbook Name:: mesosphere +# Recipe:: default +# +# Copyright 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. +# + +# Prereqs +# 1. Install docker with overlayfs +# 2. CentOS7 or greater supported +docker_service 'default' do + storage_driver 'overlay' +end + +# Pipeline +# 1. Download dcos_generate_config.sh to $HOME +# - Note this link does not have versioning, so using it will always be the latest DCOS. This URL might change in the future, but for now this cookbook will only install the latest stable release. +remote_file "/root/dcos_generate_config.sh" do + source "https://s3.amazonaws.com/downloads.mesosphere.io/dcos/stable/dcos_generate_config.sh" + # owner 'web_admin' + # group 'web_admin' + mode '0755' + # action :create +end + +# 2. mkdir $HOME/genconf && touch $HOME/genconf/config.yaml +directory "/root/genconf" do + # owner 'root' + # group 'root' + mode '0755' + # action :create +end + +# 3. The config file several parameters, some parameters have dependencies. The most basic config.yaml looks like this: +template "/root/genconf/config.yaml" do + source 'config.yaml.erb' + # owner 'root' + # group 'root' + # mode '0644' + # action :create +end + +# 4. Execute --genconf: $HOME/dcos_generate_config.sh --genconf +execute "dcos-genconf" do + command "/root/dcos_generate_config.sh --genconf" + cwd "/root" +end + +# 5. Execute installation: $HOME/genconf/serve/dcos_install.sh $DCOS_ROLE {master | slave | slave_public} + +# This should be enough to get you started, please keep in touch over the next couple of weeks and don't ever hesitate to reach out! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..1dd5126 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb new file mode 100644 index 0000000..454e94d --- /dev/null +++ b/spec/unit/recipes/default_spec.rb @@ -0,0 +1,20 @@ +# +# Cookbook Name:: mesosphere +# Spec:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'mesosphere::default' do + context 'When all attributes are default, on an unspecified platform' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/templates/default/config.yaml.erb b/templates/default/config.yaml.erb new file mode 100644 index 0000000..6a53b48 --- /dev/null +++ b/templates/default/config.yaml.erb @@ -0,0 +1,7 @@ +--- +cluster_name:'<%= node["mesosphere"]["cluster_name"] %>' +master_discovery:'<%= node["mesosphere"]["master_discovery"] %>' +exhibitor_storage_backend:'<%= node["mesosphere"]["exhibitor_storage_backend"] %>' +bootstrap_url:'<%= node["mesosphere"]["bootstrap_url"] %>' +master_list: [<% node["mesosphere"]["master_list"].each do |ip| %>'<%= ip %>', <% end %>] +resolvers: [<% node["mesosphere"]["resolvers"].each do |ip| %>'<%= ip %>', <% end %>] diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb new file mode 100644 index 0000000..0ec4d0b --- /dev/null +++ b/test/integration/default/serverspec/default_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe 'mesosphere::default' do + # Serverspec examples can be found at + # http://serverspec.org/resource_types.html + it 'does something' do + skip 'Replace this with meaningful tests' + end +end diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb new file mode 100644 index 0000000..c1fddf0 --- /dev/null +++ b/test/integration/helpers/serverspec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'serverspec' + +if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil? + set :backend, :exec +else + set :backend, :cmd + set :os, family: 'windows' +end From ab5125036dc35caace3a3df697557b62b4b67c4c Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Tue, 12 Apr 2016 15:32:12 -0500 Subject: [PATCH 02/19] yaml formatting fix --- templates/default/config.yaml.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/config.yaml.erb b/templates/default/config.yaml.erb index 6a53b48..a44c7f9 100644 --- a/templates/default/config.yaml.erb +++ b/templates/default/config.yaml.erb @@ -3,5 +3,5 @@ cluster_name:'<%= node["mesosphere"]["cluster_name"] %>' master_discovery:'<%= node["mesosphere"]["master_discovery"] %>' exhibitor_storage_backend:'<%= node["mesosphere"]["exhibitor_storage_backend"] %>' bootstrap_url:'<%= node["mesosphere"]["bootstrap_url"] %>' -master_list: [<% node["mesosphere"]["master_list"].each do |ip| %>'<%= ip %>', <% end %>] -resolvers: [<% node["mesosphere"]["resolvers"].each do |ip| %>'<%= ip %>', <% end %>] +master_list:[<% node["mesosphere"]["master_list"].each do |ip| %>'<%= ip %>', <% end %>] +resolvers:[<% node["mesosphere"]["resolvers"].each do |ip| %>'<%= ip %>', <% end %>] From 4a246261e3a86b6406e20d16eca29fe91f029cf1 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Wed, 13 Apr 2016 16:27:49 -0500 Subject: [PATCH 03/19] Docker service create & start and try testing channel for dcos_generate_config.sh script --- recipes/default.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index 50e0726..3e1f804 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -22,13 +22,15 @@ # 2. CentOS7 or greater supported docker_service 'default' do storage_driver 'overlay' + action [:create, :start] end # Pipeline # 1. Download dcos_generate_config.sh to $HOME # - Note this link does not have versioning, so using it will always be the latest DCOS. This URL might change in the future, but for now this cookbook will only install the latest stable release. remote_file "/root/dcos_generate_config.sh" do - source "https://s3.amazonaws.com/downloads.mesosphere.io/dcos/stable/dcos_generate_config.sh" + # source "https://s3.amazonaws.com/downloads.mesosphere.io/dcos/stable/dcos_generate_config.sh" + source "https://downloads.mesosphere.io/dcos/testing/continuous/dcos_generate_config.sh" # owner 'web_admin' # group 'web_admin' mode '0755' From 66393601cc9bf1938f54b73c2966e425baec334f Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Thu, 14 Apr 2016 19:10:13 -0500 Subject: [PATCH 04/19] mesosphere->dcos rename and ip-detect support --- .kitchen.yml | 4 +- README.md | 26 ++++++- attributes/default.rb | 70 ++++--------------- files/default/aws | 6 ++ files/default/gce | 6 ++ metadata.rb | 2 +- recipes/_ip-detect.rb | 49 +++++++++++++ recipes/default.rb | 32 ++++----- spec/unit/recipes/default_spec.rb | 5 +- templates/default/config.yaml.erb | 18 +++-- templates/default/ip-detect.erb | 5 ++ .../default/serverspec/default_spec.rb | 2 +- 12 files changed, 137 insertions(+), 88 deletions(-) create mode 100644 files/default/aws create mode 100644 files/default/gce create mode 100644 recipes/_ip-detect.rb create mode 100644 templates/default/ip-detect.erb diff --git a/.kitchen.yml b/.kitchen.yml index 8234213..3eec52e 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -14,5 +14,7 @@ platforms: suites: - name: default run_list: - - recipe[mesosphere::default] + - recipe[dcos::default] attributes: + dcos: + master_list: ['127.0.0.1'] diff --git a/README.md b/README.md index 93057c1..712f8e4 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,39 @@ Description =========== -Manage deployment and configuration of underlying Mesosphere installation. +Manage deployment and configuration of underlying Mesosphere DCOS installation. -Attributes +Requirements +------------ + +Only Red Hat or CentOS 7.x are currently supported. + +Usage ========== +The behavior of this cookbook is managed by attributes documented in the [attributes file](attributes/default.rb). The `node['dcos']['dcos_role']` attribute controls the DCOS role to apply to the node (default is `master`). The `node['dcos']['master_list']` must be set to specify the list of DCOS master node IPv4 addresses to connect at startup. + +you can create a Chef role and apply it to nodes as necessary to specify `master`, `slave` and `slave-public` as appropriate. Any additional configuration should probably be set as override attributes in an Environment to ensure all nodes receive those global settings. + +### Example Role dcos_master.rb ### +````ruby +name "dcos_master" +description "DCOS master role" +run_list "recipe[dcos]" +default_attributes "dcos" => { + "dcos_role" => [ "master" ] + "master_list" => [ "10.0.2.10" ] +} +```` + Recipe ======= default ------- +Installs the prerequisites for the Mesosphere DCOS installation, including packages, groups and Docker with OverlayFS enabled. It then downloads and runs the installation package with the settings configured by the node's attributes. + License and Author ================== diff --git a/attributes/default.rb b/attributes/default.rb index 04b7229..7ac134b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,6 +1,6 @@ # # Author:: Matt Ray -# Cookbook Name:: mesosphere +# Cookbook Name:: dcos # # Copyright 2016 Chef Software, Inc # @@ -17,61 +17,21 @@ # limitations under the License. # -default['mesosphere']['dcos_version'] = 'stable' -default['mesosphere']['dcos_role'] = 'master' # options are master, slave or slave_public +default['dcos']['dcos_version'] = 'stable' +default['dcos']['dcos_role'] = 'master' # options are master, slave or slave_public -default['mesosphere']['cluster_name'] = 'DCOS' -default['mesosphere']['master_discovery'] = 'static' -default['mesosphere']['exhibitor_storage_backend'] = 'static' -default['mesosphere']['bootstrap_url'] = 'file:///opt/dcos_install_tmp' +default['dcos']['cluster_name'] = 'DCOS' +default['dcos']['master_discovery'] = 'static' +default['dcos']['exhibitor_storage_backend'] = 'static' +default['dcos']['bootstrap_url'] = 'file:///opt/dcos_install_tmp' + +# determine how to generate the genconf/ip-detect script +# 'aws' or 'gce' will use the local ipv4 address from the metadata service +# otherwise use 'eth0', 'eth1', etc. and it will get the ipaddress associated +# with node['network']['interface'][VALUE] +default['dcos']['ip-detect'] = 'eth0' # ipv4 only, must be odd number 1-9 -default['mesosphere']['master_list'] = [] +default['dcos']['master_list'] = [] # upstream DNS for MesosDNS -default['mesosphere']['resolvers'] = ['8.8.8.8', '8.8.4.4'] - -# All Possible Parameters / Attrbutes with logical defaults and their dependencies if any - -# Config.yaml Parameters -# EE Only -# $superuser_username = 'admin' -# $superuser_password_hash = undef - -# Exhibitor Storage Backend Dependencies -# $exhibitor_storage_backend:'zookeeper': -# Bootstrap exhibitor using another zk cluster for shared file data -# $exhibitor_zk_hosts = undef # Comma list of $HOST:2181, $HOST:2181... -# $exhibitor_zk_path = '/dcos' - -# $exhibitor_storage_backend: 'shared_filesystem' -# This parameter specifies the absolute path to the folder -# that Exhibitor uses to coordinate its configuration. This should -# be a directory inside of a Network File System (NFS) mount. For -# example, if every master has /fserv mounted via NFS, set as -# exhibitor_fs_config_dir: /fserv/dcos-exhibitor. -# $exhibitor_fs_config_dir = undef - -# exhibitor_storage_backend:'aws_s3' -# $aws_access_key_id = undef -# $aws_region = undef -# $aws_secret_access_key = undef -# $s3_bucket = undef -# # This parameter specifies S3 prefix to be used within your -# # S3 bucket to be used by Exhibito -# $s3_prefix = undef - -# # Master Discovery Dependencies -# # master_discovery:'static' -# $master_list = $::master_list - -# master_discovery: 'vrrp' -# This parameter specifies the virtual router ID of the Keepalived cluster. -# You must use the same virtual router ID across your cluster. -# $keepalived_router_id = undef -# # This parameter specifies the interface that Keepalived uses. -# $keepalived_interface = undef -# # If you've set your auth_type to PASS, this parameter specifies the password -# # that you set for auth_pass in your Keepalived configuration file. -# $keepalived_pass = undef -# # This parameter specifies the VIP in use by your Keepalived cluster. -# $keepalived_virtual_ipaddress = undef +default['dcos']['resolvers'] = ['8.8.8.8', '8.8.4.4'] diff --git a/files/default/aws b/files/default/aws new file mode 100644 index 0000000..4ed6aab --- /dev/null +++ b/files/default/aws @@ -0,0 +1,6 @@ +#!/bin/sh +# Example ip-detect script using an external authority +# Uses the AWS Metadata Service to get the node's internal +# ipv4 address + +curl -fsSL http://169.254.169.254/latest/meta-data/local-ipv4 diff --git a/files/default/gce b/files/default/gce new file mode 100644 index 0000000..cbcee8e --- /dev/null +++ b/files/default/gce @@ -0,0 +1,6 @@ +#!/bin/sh +# Example ip-detect script using an external authority +# Uses the GCE metadata server to get the node's internal +# ipv4 address + +curl -fsSl -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/network-interfaces/0/ip diff --git a/metadata.rb b/metadata.rb index 7b2da03..3362eb5 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,4 +1,4 @@ -name 'mesosphere' +name 'dcos' maintainer 'Chef Software, Inc.' maintainer_email 'partnereng@chef.io' license 'Apache 2.0' diff --git a/recipes/_ip-detect.rb b/recipes/_ip-detect.rb new file mode 100644 index 0000000..f9374ed --- /dev/null +++ b/recipes/_ip-detect.rb @@ -0,0 +1,49 @@ +# +# Cookbook Name:: dcos +# Recipe:: _ip-detect +# +# Copyright 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. +# + +# generates a genconf/ip-detect script based on the node['dcos']['ip-detect'] attribute +# https://docs.mesosphere.com/archived-dcos-enterprise-edition/installing-enterprise-edition-1-5/create-a-script-for-ip-address-discovery/ + +if node['dcos']['ip-detect'].eql? 'aws' + cookbook_file '/root/genconf/ip-detect' do + source 'aws' + mode '0755' + end +elsif node['dcos']['ip-detect'].eql? 'gce' + cookbook_file '/root/genconf/ip-detect' do + source 'gce' + mode '0755' + end +else + # find the ipaddress for that interface + addresses = node['network']['interfaces'][node['dcos']['ip-detect']]['addresses'] + addresses.select do |ip, data| + if data['family'].eql?('inet') + + template '/root/genconf/ip-detect' do + source 'ip-detect.erb' + mode '0755' + variables({ + :ip => ip + }) + end + + end + end +end diff --git a/recipes/default.rb b/recipes/default.rb index 3e1f804..0845d24 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: mesosphere +# Cookbook Name:: dcos # Recipe:: default # # Copyright 2016, Chef Software, Inc. @@ -18,43 +18,37 @@ # # Prereqs -# 1. Install docker with overlayfs -# 2. CentOS7 or greater supported +package 'unzip' + +package 'ipset' + +group 'nogroup' + +# Install docker with overlayfs docker_service 'default' do storage_driver 'overlay' action [:create, :start] end -# Pipeline -# 1. Download dcos_generate_config.sh to $HOME -# - Note this link does not have versioning, so using it will always be the latest DCOS. This URL might change in the future, but for now this cookbook will only install the latest stable release. +# Download dcos_generate_config.sh to $HOME +# Note this link does not have versioning, so using it will always be the latest DCOS. This URL might change in the future, but for now this cookbook will only install the latest stable release. remote_file "/root/dcos_generate_config.sh" do # source "https://s3.amazonaws.com/downloads.mesosphere.io/dcos/stable/dcos_generate_config.sh" source "https://downloads.mesosphere.io/dcos/testing/continuous/dcos_generate_config.sh" - # owner 'web_admin' - # group 'web_admin' mode '0755' - # action :create end -# 2. mkdir $HOME/genconf && touch $HOME/genconf/config.yaml directory "/root/genconf" do - # owner 'root' - # group 'root' mode '0755' - # action :create end -# 3. The config file several parameters, some parameters have dependencies. The most basic config.yaml looks like this: template "/root/genconf/config.yaml" do source 'config.yaml.erb' - # owner 'root' - # group 'root' - # mode '0644' - # action :create end -# 4. Execute --genconf: $HOME/dcos_generate_config.sh --genconf +# generate the /root/genconf/ip-detect script +include_recipe 'dcos::_ip-detect' + execute "dcos-genconf" do command "/root/dcos_generate_config.sh --genconf" cwd "/root" diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 454e94d..ff18572 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -1,12 +1,11 @@ # -# Cookbook Name:: mesosphere +# Cookbook Name:: dcos # Spec:: default # -# Copyright (c) 2016 The Authors, All Rights Reserved. require 'spec_helper' -describe 'mesosphere::default' do +describe 'dcos::default' do context 'When all attributes are default, on an unspecified platform' do let(:chef_run) do runner = ChefSpec::ServerRunner.new diff --git a/templates/default/config.yaml.erb b/templates/default/config.yaml.erb index a44c7f9..f1e7ee1 100644 --- a/templates/default/config.yaml.erb +++ b/templates/default/config.yaml.erb @@ -1,7 +1,13 @@ --- -cluster_name:'<%= node["mesosphere"]["cluster_name"] %>' -master_discovery:'<%= node["mesosphere"]["master_discovery"] %>' -exhibitor_storage_backend:'<%= node["mesosphere"]["exhibitor_storage_backend"] %>' -bootstrap_url:'<%= node["mesosphere"]["bootstrap_url"] %>' -master_list:[<% node["mesosphere"]["master_list"].each do |ip| %>'<%= ip %>', <% end %>] -resolvers:[<% node["mesosphere"]["resolvers"].each do |ip| %>'<%= ip %>', <% end %>] +cluster_name: '<%= node["dcos"]["cluster_name"] %>' +master_discovery: '<%= node["dcos"]["master_discovery"] %>' +exhibitor_storage_backend: '<%= node["dcos"]["exhibitor_storage_backend"] %>' +bootstrap_url: '<%= node["dcos"]["bootstrap_url"] %>' +master_list: +<% node["dcos"]["master_list"].each do |ip| %> + - <%= ip %> +<% end %> +resolvers: +<% node["dcos"]["resolvers"].each do |ip| %> + - <%= ip %> +<% end %> diff --git a/templates/default/ip-detect.erb b/templates/default/ip-detect.erb new file mode 100644 index 0000000..c27d8b9 --- /dev/null +++ b/templates/default/ip-detect.erb @@ -0,0 +1,5 @@ +#!/bin/sh + +# generated by the _ip-detect recipe based on the interface specified + +echo '<%= @ip %>' diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 0ec4d0b..d381294 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'mesosphere::default' do +describe 'dcos::default' do # Serverspec examples can be found at # http://serverspec.org/resource_types.html it 'does something' do From b94ff59bc339a89795e869df68e5c7d1c450ff72 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Thu, 14 Apr 2016 22:44:21 -0500 Subject: [PATCH 05/19] Add support for calling dcos_install.sh --- recipes/default.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index 0845d24..5c1eba3 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -51,9 +51,20 @@ execute "dcos-genconf" do command "/root/dcos_generate_config.sh --genconf" + user "root" cwd "/root" + not_if do + File.exist?('/root/genconf/cluster_packages.json') + end end -# 5. Execute installation: $HOME/genconf/serve/dcos_install.sh $DCOS_ROLE {master | slave | slave_public} +file "/root/genconf/serve/dcos_install.sh" do + mode '0755' +end -# This should be enough to get you started, please keep in touch over the next couple of weeks and don't ever hesitate to reach out! +# Execute installation: $HOME/genconf/serve/dcos_install.sh $DCOS_ROLE {master | slave | slave_public} +execute 'dcos_install' do + command "/root/genconf/serve/dcos_install.sh #{node['dcos']['dcos_role']}" + user "root" + cwd "/root" +end From 29a341c1955d0f69c7d1cec3d074ae330bb335ca Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 13:05:40 -0500 Subject: [PATCH 06/19] fix dcos launch with selinux and firewalld disabling --- attributes/default.rb | 2 +- metadata.rb | 1 + recipes/default.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 7ac134b..0454457 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -23,7 +23,7 @@ default['dcos']['cluster_name'] = 'DCOS' default['dcos']['master_discovery'] = 'static' default['dcos']['exhibitor_storage_backend'] = 'static' -default['dcos']['bootstrap_url'] = 'file:///opt/dcos_install_tmp' +default['dcos']['bootstrap_url'] = 'file:///root/genconf/serve' # determine how to generate the genconf/ip-detect script # 'aws' or 'gce' will use the local ipv4 address from the metadata service diff --git a/metadata.rb b/metadata.rb index 3362eb5..6725828 100644 --- a/metadata.rb +++ b/metadata.rb @@ -12,3 +12,4 @@ supports 'scientific' depends 'docker', '~> 2.0' +depends 'selinux', '~> 0.9.0' diff --git a/recipes/default.rb b/recipes/default.rb index 5c1eba3..9ca466a 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -18,6 +18,14 @@ # # Prereqs +selinux_state "SELinux Permissive" do + action :permissive +end + +service 'firewalld' do + action [:stop, :disable] +end + package 'unzip' package 'ipset' From d5256f0108f8182ddcf45456aaa480c2d2e3eff9 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 15:42:17 -0500 Subject: [PATCH 07/19] FC023 fix for conditional attributes --- recipes/_ip-detect.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/recipes/_ip-detect.rb b/recipes/_ip-detect.rb index f9374ed..c41a06b 100644 --- a/recipes/_ip-detect.rb +++ b/recipes/_ip-detect.rb @@ -34,16 +34,15 @@ # find the ipaddress for that interface addresses = node['network']['interfaces'][node['dcos']['ip-detect']]['addresses'] addresses.select do |ip, data| - if data['family'].eql?('inet') - - template '/root/genconf/ip-detect' do - source 'ip-detect.erb' - mode '0755' - variables({ - :ip => ip - }) - end + template '/root/genconf/ip-detect' do + source 'ip-detect.erb' + only_if { data['family'].eql?('inet') } + mode '0755' + variables({ + :ip => ip + }) end + end end From 26d628ded73da4d7856f95068bb72616c0d5247c Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 15:43:44 -0500 Subject: [PATCH 08/19] FC064 and FC065 fixes for adding source_url and issues_url to metadata.rb --- metadata.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metadata.rb b/metadata.rb index 6725828..718cf51 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,6 +6,9 @@ long_description 'Installs/Configures Mesosphere' version '0.1.0' +source_url 'https://github.com/chef-partners/dcos-cookbook' if respond_to?(:source_url) +issues_url 'https://github.com/chef-partners/dcos-cookbook/issues' if respond_to?(:issues_url) + supports 'centos' supports 'oracle' supports 'redhat' From 2b69ccaafca3b67a90405e7e450393948b977ae8 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 16:39:40 -0500 Subject: [PATCH 09/19] TravisCI support --- .travis.yml | 21 +++++++++++++++++++++ README.md | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f731bf0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: ruby +sudo: false + +addons: + apt: + sources: + - chef-current-precise + packages: + - chefdk + +# Ensure we make ChefDK's Ruby the default +before_script: + - eval "$(/opt/chefdk/bin/chef shell-init bash)" +script: + - /opt/chefdk/embedded/bin/chef --version + - /opt/chefdk/embedded/bin/rubocop --version + - /opt/chefdk/embedded/bin/rubocop + - /opt/chefdk/embedded/bin/foodcritic --version + - /opt/chefdk/embedded/bin/foodcritic . --exclude spec + - /opt/chefdk/embedded/bin/rspec --version + - /opt/chefdk/embedded/bin/rspec diff --git a/README.md b/README.md index 712f8e4..180c3b0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/chef-partners/dcos-cookbook.svg?branch=master)](https://travis-ci.org/chef-partners/dcos-cookbook) + Description =========== From 76ed1ad7a10aa4269fc1a0a8a4e54764f828da6a Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 16:54:09 -0500 Subject: [PATCH 10/19] RuboCop --- .rubocop.yml | 4 ++++ attributes/default.rb | 2 +- metadata.rb | 6 ++++-- recipes/_ip-detect.rb | 11 ++++------- recipes/default.rb | 35 +++++++++++++++++------------------ 5 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3fbd52f --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,4 @@ +# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts. +Style/FileName: + Exclude: + - 'recipes/_ip-detect.rb' diff --git a/attributes/default.rb b/attributes/default.rb index 0454457..b833878 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -18,7 +18,7 @@ # default['dcos']['dcos_version'] = 'stable' -default['dcos']['dcos_role'] = 'master' # options are master, slave or slave_public +default['dcos']['dcos_role'] = 'master' # 'master', 'slave' or 'slave_public' default['dcos']['cluster_name'] = 'DCOS' default['dcos']['master_discovery'] = 'static' diff --git a/metadata.rb b/metadata.rb index 718cf51..77ead45 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,8 +6,10 @@ long_description 'Installs/Configures Mesosphere' version '0.1.0' -source_url 'https://github.com/chef-partners/dcos-cookbook' if respond_to?(:source_url) -issues_url 'https://github.com/chef-partners/dcos-cookbook/issues' if respond_to?(:issues_url) +source_url 'https://github.com/chef-partners/dcos-cookbook' if + respond_to?(:source_url) +issues_url 'https://github.com/chef-partners/dcos-cookbook/issues' if + respond_to?(:issues_url) supports 'centos' supports 'oracle' diff --git a/recipes/_ip-detect.rb b/recipes/_ip-detect.rb index c41a06b..ad118da 100644 --- a/recipes/_ip-detect.rb +++ b/recipes/_ip-detect.rb @@ -17,7 +17,7 @@ # limitations under the License. # -# generates a genconf/ip-detect script based on the node['dcos']['ip-detect'] attribute +# generates a genconf/ip-detect script based on the node['dcos']['ip-detect'] # https://docs.mesosphere.com/archived-dcos-enterprise-edition/installing-enterprise-edition-1-5/create-a-script-for-ip-address-discovery/ if node['dcos']['ip-detect'].eql? 'aws' @@ -32,17 +32,14 @@ end else # find the ipaddress for that interface - addresses = node['network']['interfaces'][node['dcos']['ip-detect']]['addresses'] + interface = node['dcos']['ip-detect'] + addresses = node['network']['interfaces'][interface]['addresses'] addresses.select do |ip, data| - template '/root/genconf/ip-detect' do source 'ip-detect.erb' only_if { data['family'].eql?('inet') } mode '0755' - variables({ - :ip => ip - }) + variables(ip: ip) end - end end diff --git a/recipes/default.rb b/recipes/default.rb index 9ca466a..94a7fce 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -18,7 +18,7 @@ # # Prereqs -selinux_state "SELinux Permissive" do +selinux_state 'SELinux Permissive' do action :permissive end @@ -34,45 +34,44 @@ # Install docker with overlayfs docker_service 'default' do - storage_driver 'overlay' - action [:create, :start] + storage_driver 'overlay' + action [:create, :start] end -# Download dcos_generate_config.sh to $HOME -# Note this link does not have versioning, so using it will always be the latest DCOS. This URL might change in the future, but for now this cookbook will only install the latest stable release. -remote_file "/root/dcos_generate_config.sh" do - # source "https://s3.amazonaws.com/downloads.mesosphere.io/dcos/stable/dcos_generate_config.sh" - source "https://downloads.mesosphere.io/dcos/testing/continuous/dcos_generate_config.sh" +# Note this link does not have versioning, so using it will always be the latest +# DCOS from 'testing' and this URL might change in the future. +# https://s3.amazonaws.com/downloads.mesosphere.io/dcos/stable/dcos_generate_config.sh +remote_file '/root/dcos_generate_config.sh' do + source 'https://downloads.mesosphere.io/dcos/testing/continuous/dcos_generate_config.sh' mode '0755' end -directory "/root/genconf" do +directory '/root/genconf' do mode '0755' end -template "/root/genconf/config.yaml" do +template '/root/genconf/config.yaml' do source 'config.yaml.erb' end # generate the /root/genconf/ip-detect script include_recipe 'dcos::_ip-detect' -execute "dcos-genconf" do - command "/root/dcos_generate_config.sh --genconf" - user "root" - cwd "/root" +execute 'dcos-genconf' do + command '/root/dcos_generate_config.sh --genconf' + user 'root' + cwd '/root' not_if do File.exist?('/root/genconf/cluster_packages.json') end end -file "/root/genconf/serve/dcos_install.sh" do +file '/root/genconf/serve/dcos_install.sh' do mode '0755' end -# Execute installation: $HOME/genconf/serve/dcos_install.sh $DCOS_ROLE {master | slave | slave_public} execute 'dcos_install' do command "/root/genconf/serve/dcos_install.sh #{node['dcos']['dcos_role']}" - user "root" - cwd "/root" + user 'root' + cwd '/root' end From b42f1852b7117c3abfb92907cc23a5f3e28603d9 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 17:27:13 -0500 Subject: [PATCH 11/19] add an eth0 --- spec/unit/recipes/default_spec.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index ff18572..74b179a 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -6,12 +6,25 @@ require 'spec_helper' describe 'dcos::default' do - context 'When all attributes are default, on an unspecified platform' do + context 'Default behavior, assume eth0' do let(:chef_run) do runner = ChefSpec::ServerRunner.new + node.set['network']['interfaces']['eth0']['addresses'] = + { + '1.2.3.4' => + { + 'family' => 'inet', + 'netmask' => '255.255.255.0', + 'broadcast' => '192.168.1.255' + } + } runner.converge(described_recipe) end + it 'installs unzip' do + expect(chef_run).to install_package('unzip') + end + it 'converges successfully' do expect { chef_run }.to_not raise_error end From 1f3c66a05e00df687658629482764b673276eae0 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 17:31:25 -0500 Subject: [PATCH 12/19] make rubocop happy --- spec/unit/recipes/default_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 74b179a..5e1a70c 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -8,17 +8,17 @@ describe 'dcos::default' do context 'Default behavior, assume eth0' do let(:chef_run) do - runner = ChefSpec::ServerRunner.new - node.set['network']['interfaces']['eth0']['addresses'] = - { - '1.2.3.4' => + ChefSpec::SoloRunner.new do |node| + node.set['network']['interfaces']['eth0']['addresses'] = { - 'family' => 'inet', - 'netmask' => '255.255.255.0', - 'broadcast' => '192.168.1.255' + '1.2.3.4' => + { + 'family' => 'inet', + 'netmask' => '255.255.255.0', + 'broadcast' => '192.168.1.255' + } } - } - runner.converge(described_recipe) + end.converge(described_recipe) end it 'installs unzip' do From 60af165c24ec163eca72743af4782a731f27cbf6 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Fri, 15 Apr 2016 17:42:25 -0500 Subject: [PATCH 13/19] more unit tests --- spec/unit/recipes/default_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 5e1a70c..7c2fc4d 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -21,10 +21,35 @@ end.converge(described_recipe) end + it 'stops service firewalld' do + expect(chef_run).to stop_service('firewalld') + end + + it 'disables service firewalld' do + expect(chef_run).to disable_service('firewalld') + end + it 'installs unzip' do expect(chef_run).to install_package('unzip') end + it 'installs ipset' do + expect(chef_run).to install_package('ipset') + end + + it 'creates group[nogroup]' do + expect(chef_run).to create_group('nogroup') + end + + # docker_service + # remote_file + # directory + # template + # include_recipe + # execute + # file + # execute + it 'converges successfully' do expect { chef_run }.to_not raise_error end From 801938c8cb28b805fd9cb85beba031669ad22235 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Mon, 18 Apr 2016 17:46:28 -0500 Subject: [PATCH 14/19] file permissions test, remove line lengths from rubocop --- .rubocop.yml | 4 +++- README.md | 32 ++++++++++++++++++++++++++++--- spec/unit/recipes/default_spec.rb | 6 +++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3fbd52f..d53c800 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ -# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts. Style/FileName: Exclude: - 'recipes/_ip-detect.rb' + +LineLength: + Enabled: false diff --git a/README.md b/README.md index 180c3b0..28a1d8c 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,12 @@ Only Red Hat or CentOS 7.x are currently supported. Usage ========== -The behavior of this cookbook is managed by attributes documented in the [attributes file](attributes/default.rb). The `node['dcos']['dcos_role']` attribute controls the DCOS role to apply to the node (default is `master`). The `node['dcos']['master_list']` must be set to specify the list of DCOS master node IPv4 addresses to connect at startup. +The behavior of this cookbook is managed by attributes documented in the [attributes file](attributes/default.rb). The `node['dcos']['dcos_role']` attribute controls the DCOS role to apply to the node (default is `master`). The `node['dcos']['master_list']` must be set to specify the list of DCOS master node IPv4 addresses to connect at startup (this must be an odd number of masters). -you can create a Chef role and apply it to nodes as necessary to specify `master`, `slave` and `slave-public` as appropriate. Any additional configuration should probably be set as override attributes in an Environment to ensure all nodes receive those global settings. +Roles +---------- + +You can create a Chef Role and apply it to nodes as necessary to specify `master`, `slave` and `slave-public` as appropriate. Any additional configuration should probably be set as override attributes in an Environment to ensure all nodes receive those global settings. ### Example Role dcos_master.rb ### ````ruby @@ -23,7 +26,18 @@ name "dcos_master" description "DCOS master role" run_list "recipe[dcos]" default_attributes "dcos" => { - "dcos_role" => [ "master" ] + "dcos_role" => "master" + "master_list" => [ "10.0.2.10" ] +} +```` + +### Example Role dcos_slave.rb ### +````ruby +name "dcos_slave" +description "DCOS slave role" +run_list "recipe[dcos]" +default_attributes "dcos" => { + "dcos_role" => "slave" "master_list" => [ "10.0.2.10" ] } ```` @@ -36,6 +50,18 @@ default Installs the prerequisites for the Mesosphere DCOS installation, including packages, groups and Docker with OverlayFS enabled. It then downloads and runs the installation package with the settings configured by the node's attributes. +Testing +======= + +ChefSpec +-------- + +InSpec +------ + +Test Kitchen +------------ + License and Author ================== diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 7c2fc4d..c64f5d7 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -47,7 +47,11 @@ # template # include_recipe # execute - # file + + it 'sets permissions on dcos_install.sh' do + expect(chef_run).to create_file('/root/genconf/serve/dcos_install.sh').with(mode: '0755') + end + # execute it 'converges successfully' do From 2cdc3f492c668ebde68ac9f17a439d5e4e4793ee Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Mon, 18 Apr 2016 21:46:50 -0500 Subject: [PATCH 15/19] directory and execute tests --- spec/unit/recipes/default_spec.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index c64f5d7..488119a 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -43,16 +43,25 @@ # docker_service # remote_file - # directory + + it 'creates genconf directory' do + expect(chef_run).to create_directory('/root/genconf').with(mode: '0755') + end + # template # include_recipe - # execute + + it 'dcos-genconf' do + expect(chef_run).to run_execute('dcos-genconf').with(user: 'root') + end it 'sets permissions on dcos_install.sh' do expect(chef_run).to create_file('/root/genconf/serve/dcos_install.sh').with(mode: '0755') end - # execute + it 'dcos_install' do + expect(chef_run).to run_execute('dcos-genconf').with(user: 'root') + end it 'converges successfully' do expect { chef_run }.to_not raise_error From 5bfffa831aecf6d91a2b7da18a3da65fc9b0cd7c Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Mon, 18 Apr 2016 22:12:39 -0500 Subject: [PATCH 16/19] add safeguards for multiple runs --- recipes/default.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/default.rb b/recipes/default.rb index 94a7fce..8d1c962 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -68,10 +68,14 @@ file '/root/genconf/serve/dcos_install.sh' do mode '0755' + subscribes :create, 'execute[dcos-genconf]', :immediately + action :nothing end execute 'dcos_install' do command "/root/genconf/serve/dcos_install.sh #{node['dcos']['dcos_role']}" user 'root' cwd '/root' + subscribes :run, 'file[/root/genconf/serve/dcos_install.sh]', :immediately + action :nothing end From ed848c2bd106995e88c7eb0de5abdf15165e0262 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Mon, 18 Apr 2016 22:17:14 -0500 Subject: [PATCH 17/19] clean up test coverage --- spec/unit/recipes/default_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 488119a..b823a26 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -41,17 +41,19 @@ expect(chef_run).to create_group('nogroup') end - # docker_service - # remote_file + it 'creates remote_file[dcos_generate_config.sh]' do + expect(chef_run).to create_remote_file('/root/dcos_generate_config.sh').with(mode: '0755') + end - it 'creates genconf directory' do + it 'creates directory[genconf]' do expect(chef_run).to create_directory('/root/genconf').with(mode: '0755') end - # template - # include_recipe + it 'creates template[config.yaml]' do + expect(chef_run).to create_template('/root/genconf/config.yaml') + end - it 'dcos-genconf' do + it 'executes[dcos-genconf]' do expect(chef_run).to run_execute('dcos-genconf').with(user: 'root') end @@ -59,7 +61,7 @@ expect(chef_run).to create_file('/root/genconf/serve/dcos_install.sh').with(mode: '0755') end - it 'dcos_install' do + it 'executes[dcos_install]' do expect(chef_run).to run_execute('dcos-genconf').with(user: 'root') end From d4bb3da19f218a4eea8f8232d56ed138327e598f Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Mon, 18 Apr 2016 22:46:08 -0500 Subject: [PATCH 18/19] more testing details --- .kitchen.local.yml.example | 70 ++++++++++++++++++++++++++++++++++++++ README.md | 3 ++ 2 files changed, 73 insertions(+) create mode 100644 .kitchen.local.yml.example diff --git a/.kitchen.local.yml.example b/.kitchen.local.yml.example new file mode 100644 index 0000000..7a3e3f6 --- /dev/null +++ b/.kitchen.local.yml.example @@ -0,0 +1,70 @@ +--- +driver: + name: gce + project: chef-marketplace-dev + zone: us-central1-a + preemptible: true + email: matt@chef.io + tags: + - mesosphere + - test-kitchen + service_account_scopes: + - devstorage.read_write + - userinfo.email + +transport: + username: mray + ssh_key: + - ~/.ssh/google_compute_engine + +platforms: + - name: centos-7.2 + driver: + image_name: centos-7 + +suites: + - name: default + run_list: + - recipe[dcos::default] + attributes: + dcos: + master_list: ['127.0.0.1'] + - name: gm1 + run_list: + - recipe[dcos::default] + attributes: + dcos: + ip-detect: 'gce' + dcos_role: 'master' + master_list: ['10.240.0.2', '10.240.0.3', '10.240.0.4'] + - name: gm2 + run_list: + - recipe[dcos::default] + attributes: + dcos: + ip-detect: 'gce' + dcos_role: 'master' + master_list: ['10.240.0.2', '10.240.0.3', '10.240.0.4'] + - name: gm3 + run_list: + - recipe[dcos::default] + attributes: + dcos: + dcos_role: 'master' + master_list: ['10.240.0.2', '10.240.0.3', '10.240.0.4'] + - name: gs1 + run_list: + - recipe[dcos::default] + attributes: + dcos: + ip-detect: 'gce' + dcos_role: 'slave' + master_list: ['10.240.0.2', '10.240.0.3', '10.240.0.4'] + - name: gs2 + run_list: + - recipe[dcos::default] + attributes: + dcos: + ip-detect: 'gce' + dcos_role: 'slave' + master_list: ['10.240.0.2', '10.240.0.3', '10.240.0.4'] diff --git a/README.md b/README.md index 28a1d8c..7ea1325 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,15 @@ Testing ChefSpec -------- +There is basic coverage for the default recipe. InSpec ------ +TBD Test Kitchen ------------ +The included [.kitchen.yml](.kitchen.yml) runs the default master deployment in a generic fashion. The included [.kitchen.local.yml.example](.kitchen.local.yml.example) shows alternate settings for running multi-master with slaves on GCE (you will have to rename and update accordingly). License and Author ================== From 499c4fe03dbda372c54037aaa20bb199470db546 Mon Sep 17 00:00:00 2001 From: Matt Ray Date: Mon, 18 Apr 2016 22:47:01 -0500 Subject: [PATCH 19/19] remove permissions test --- spec/unit/recipes/default_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index b823a26..84ac316 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -57,10 +57,6 @@ expect(chef_run).to run_execute('dcos-genconf').with(user: 'root') end - it 'sets permissions on dcos_install.sh' do - expect(chef_run).to create_file('/root/genconf/serve/dcos_install.sh').with(mode: '0755') - end - it 'executes[dcos_install]' do expect(chef_run).to run_execute('dcos-genconf').with(user: 'root') end