OSDN Git Service

deprecates the node_commons cookbook and ports all its features to the commons cookbook.
authorwhitestar <whitestar@gaea.test>
Sat, 9 Jan 2016 01:18:49 +0000 (10:18 +0900)
committerwhitestar <whitestar@gaea.test>
Sat, 9 Jan 2016 01:18:49 +0000 (10:18 +0900)
16 files changed:
cookbooks/commons/Berksfile [new file with mode: 0644]
cookbooks/commons/CHANGELOG.md
cookbooks/commons/README.md
cookbooks/commons/metadata.rb
cookbooks/commons/recipes/apt.rb [new file with mode: 0644]
cookbooks/commons/recipes/ntpd.rb [new file with mode: 0644]
cookbooks/commons/recipes/yum-epel.rb [new file with mode: 0644]
cookbooks/commons/spec/recipes/apt_spec.rb [new file with mode: 0644]
cookbooks/commons/spec/recipes/ntpd_spec.rb [new file with mode: 0644]
cookbooks/commons/spec/recipes/yum-epel_spec.rb [new file with mode: 0644]
cookbooks/commons/spec/spec_helper.rb [new file with mode: 0644]
cookbooks/node_commons/CHANGELOG.md
cookbooks/node_commons/README.md
roles/apt.rb
roles/node_commons.rb
roles/yum-epel.rb

diff --git a/cookbooks/commons/Berksfile b/cookbooks/commons/Berksfile
new file mode 100644 (file)
index 0000000..e190d49
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+#grid_chef_repo = 'git://git.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
+
+# for ver. 3.x
+#source 'https://berks-api.io.example.com:6280'
+source 'https://supermarket.chef.io'
+
+metadata
+
index 47e9ff3..c1ab060 100644 (file)
@@ -1,13 +1,14 @@
 commons CHANGELOG
 =================
 
-This file is used to list changes made in each version of the commons cookbook.
+0.3.1
+-----
+- add some recipes.
+-- apt
+-- ntpd
+-- yum-epel
 
 0.1.0
 -----
-- [your_name] - Initial release of commons
-
-- - -
-Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
+- Initial release of commons
 
-The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
index 7ca1fa8..6930d67 100644 (file)
@@ -24,16 +24,19 @@ Usage
 - `Commons::PackageUtils::get_libbz2_pkg_name`
 
 #### recipes
+- `commons::apt` - 
 - `commons::crond` - installs cron package and enables & starts the service.
 - `commons::httpd` - installs httpd package and enables & starts the service.
+- `commons::ntpd` - installs ntpd package and enables & starts the service.
 - `commons::platform_update` - updates all packages for platform.
+- `commons::yum-epel` - 
 
 License and Authors
 -------------------
 - Author:: whitestar at osdn.jp
 
 ```text
-Copyright 2013-2015, whitestar
+Copyright 2013-2016, whitestar
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
index 807dd79..299f71f 100644 (file)
@@ -4,5 +4,16 @@ maintainer_email ''
 license          'Apache 2.0'
 description      'Installs/Configures commons'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version          '0.3.0'
+version          '0.3.1'
+
+%w{ debian ubuntu centos redhat fedora }.each do |os|
+  supports os
+end
+
+# local cookbooks
+
+# external cookbooks
+depends          'apt'
+depends          'yum', '>= 3.0'
+depends          'yum-epel'
 
diff --git a/cookbooks/commons/recipes/apt.rb b/cookbooks/commons/recipes/apt.rb
new file mode 100644 (file)
index 0000000..46e2380
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# Cookbook Name:: commons
+# Recipe:: apt
+#
+# 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.
+#
+
+if node[:platform_family] == 'debian' then
+  # "If a recipe is included more than once in a recipe, only the first
+  # inclusion will be processed and any subsequent inclusion will be ignored."
+  # from http://docs.opscode.com/essentials_cookbook_recipes_in_recipes.html
+  include_recipe 'apt::default'
+end
+
diff --git a/cookbooks/commons/recipes/ntpd.rb b/cookbooks/commons/recipes/ntpd.rb
new file mode 100644 (file)
index 0000000..d0ac3dc
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# Cookbook Name:: commons
+# Recipe:: ntpd
+#
+# 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.
+#
+
+pkg = 'ntp'
+resources(:package => pkg) rescue package pkg do
+  action :install
+end
+
+serv = value_for_platform_family(
+  'debian' => 'ntp',
+  'rhel'   => 'ntpd'
+)
+
+resources(:service => serv) rescue service serv do
+  action [:enable, :start]
+  supports :status => true, :restart => true, :reload => false
+end
+
diff --git a/cookbooks/commons/recipes/yum-epel.rb b/cookbooks/commons/recipes/yum-epel.rb
new file mode 100644 (file)
index 0000000..f3cee11
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# Cookbook Name:: node_commons
+# Recipe:: yum-epel
+#
+# 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.
+#
+
+if node[:platform_family] == 'rhel' then
+  # "If a recipe is included more than once in a recipe, only the first
+  # inclusion will be processed and any subsequent inclusion will be ignored."
+  # from http://docs.opscode.com/essentials_cookbook_recipes_in_recipes.html
+  include_recipe 'yum-epel::default'
+end
+
diff --git a/cookbooks/commons/spec/recipes/apt_spec.rb b/cookbooks/commons/spec/recipes/apt_spec.rb
new file mode 100644 (file)
index 0000000..6530953
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# Cookbook Name:: commons
+# Recipe Spec:: apt_spec
+#
+# 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.
+#
+
+require_relative '../spec_helper'
+
+describe 'commons::apt' do
+  let(:chef_run_on_debian) {
+    ChefSpec::SoloRunner.new(platform: 'debian', version: '7.6').
+      converge(described_recipe)
+  }
+
+  it 'includes apt::default recipe.' do
+    expect(chef_run_on_debian).to include_recipe('apt::default')
+  end
+
+  let(:chef_run_on_rhel) {
+    ChefSpec::SoloRunner.new(platform: 'centos', version: '7.0').
+      converge(described_recipe)
+  }
+
+  it 'does not include apt::default recipe.' do
+    expect(chef_run_on_rhel).to_not include_recipe('apt::default')
+  end
+end
+
diff --git a/cookbooks/commons/spec/recipes/ntpd_spec.rb b/cookbooks/commons/spec/recipes/ntpd_spec.rb
new file mode 100644 (file)
index 0000000..6dff33d
--- /dev/null
@@ -0,0 +1,51 @@
+#
+# Cookbook Name:: commons
+# Recipe Spec:: ntpd_spec
+#
+# 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.
+#
+
+require_relative '../spec_helper'
+
+describe 'commons::ntpd' do
+  let(:chef_run_on_debian) {
+    ChefSpec::SoloRunner.new(platform: 'debian', version: '7.6').
+      converge(described_recipe)
+  }
+
+  it 'installs ntp package.' do
+    expect(chef_run_on_debian).to install_package('ntp')
+  end
+
+  it 'enables ntp service.' do
+    expect(chef_run_on_debian).to enable_service('ntp')
+    expect(chef_run_on_debian).to start_service('ntp')
+  end
+
+  let(:chef_run_on_rhel) {
+    ChefSpec::SoloRunner.new(platform: 'centos', version: '7.0').
+      converge(described_recipe)
+  }
+
+  it 'installs ntp package.' do
+    expect(chef_run_on_rhel).to install_package('ntp')
+  end
+
+  it 'enables ntpd service.' do
+    expect(chef_run_on_rhel).to enable_service('ntpd')
+    expect(chef_run_on_rhel).to start_service('ntpd')
+  end
+end
+
diff --git a/cookbooks/commons/spec/recipes/yum-epel_spec.rb b/cookbooks/commons/spec/recipes/yum-epel_spec.rb
new file mode 100644 (file)
index 0000000..1cb941b
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# Cookbook Name:: commons
+# Recipe Spec:: yum-epel_spec
+#
+# 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.
+#
+
+require_relative '../spec_helper'
+
+describe 'commons::yum-epel' do
+  let(:chef_run_on_debian) {
+    ChefSpec::SoloRunner.new(platform: 'debian', version: '7.6').
+      converge(described_recipe)
+  }
+
+  it 'does not include yum-epel recipe.' do
+    expect(chef_run_on_debian).to_not include_recipe('yum-epel::default')
+  end
+
+  let(:chef_run_on_rhel) {
+    ChefSpec::SoloRunner.new(platform: 'centos', version: '7.0').
+      converge(described_recipe)
+  }
+
+  it 'includes yum-epel recipe.' do
+    expect(chef_run_on_rhel).to include_recipe('yum-epel::default')
+  end
+end
+
diff --git a/cookbooks/commons/spec/spec_helper.rb b/cookbooks/commons/spec/spec_helper.rb
new file mode 100644 (file)
index 0000000..c6996d6
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# Cookbook Name:: commons
+# Recipe Spec:: spec_helper
+#
+# 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.
+#
+
+# Added by ChefSpec
+require 'chefspec'
+
+# Uncomment to use ChefSpec's Berkshelf extension
+require 'chefspec/berkshelf'
+
+ChefSpec::Coverage.start!
+
+RSpec.configure do |config|
+  # Specify the path for Chef Solo to find cookbooks
+  #config.cookbook_path = "#{File.dirname(__FILE__)}/../../cookbooks"
+
+  # Specify the path for Chef Solo to find roles
+  # config.role_path = '/var/roles'
+
+  # Specify the Chef log_level (default: :warn)
+  # config.log_level = :debug
+
+  # Specify the path to a local JSON file with Ohai data
+  # config.path = 'ohai.json'
+
+  # Specify the operating platform to mock Ohai data from
+  # config.platform = 'ubuntu'
+
+  # Specify the operating version to mock Ohai data from
+  # config.version = '12.04'
+end
+
index 9b51420..daaa293 100644 (file)
@@ -1,12 +1,10 @@
 # CHANGELOG for node_commons
 
-This file is used to list changes made in each version of node_commons.
+## 0.1.1:
+
+* Deprecated release.
 
 ## 0.1.0:
 
 * Initial release of node_commons
 
-- - -
-Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
-
-The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
index 70f0eda..3a4864e 100644 (file)
@@ -1,6 +1,8 @@
 node_commons Cookbook
 =====================
 
+**DEPRECATED**: All features were moved to the `commons` cookbook.
+
 This cookbook contains common role recipes for each node.
 
 Requirements
@@ -27,7 +29,7 @@ License and Authors
 - Author:: whitestar at osdn.jp
 
 ```text
-Copyright 2013-2015, whitestar
+Copyright 2013-2016, whitestar
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
index ee448fe..7667133 100644 (file)
@@ -2,7 +2,7 @@ name 'apt'
 description 'APT management tools. this role does nothing in other platforms than Debian.'
 
 run_list(
-  'recipe[node_commons::apt]'
+  'recipe[commons::apt]'
 )
 
 #env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
index fbf5afa..377944c 100644 (file)
@@ -4,7 +4,7 @@ description 'Node common role.'
 run_list(
   'role[apt]',
   'role[security_update]',
-  'recipe[node_commons]',
+  'recipe[commons::ntpd]',
 )
 
 #env_run_lists()
index 35c7c2b..f0f040b 100644 (file)
@@ -3,7 +3,7 @@ description 'Extra Packages for Enterprise Linux. this role does nothing in othe
 
 run_list(
   'recipe[yum]',  # for loading default attributes.
-  'recipe[node_commons::yum-epel]'
+  'recipe[commons::yum-epel]'
 )
 
 #env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []