• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

Grid環境構築用のChefリポジトリです。


Commit MetaInfo

Revision5ad4bd279420debf8d732409388e8acd0b355e9f (tree)
Time2015-11-05 19:26:04
Authorwhitestar <whitestar@gaea...>
Commiterwhitestar

Log Message

add crond and httpd recipes to the commons cookbook.

Change Summary

Incremental Difference

--- a/cookbooks/commons/README.md
+++ b/cookbooks/commons/README.md
@@ -6,7 +6,7 @@ This cookbook contains common utility libraries.
66 Requirements
77 ------------
88
9-Nothing.
9+- OS: Debian family or Red Hat Enterprise Linux family.
1010
1111 Attributes
1212 ----------
@@ -17,10 +17,16 @@ Usage
1717 -----
1818 #### libraries
1919 - `Commons::PackageUtils::get_cron_pkg_name`
20+- `Commons::PackageUtils::get_cron_serv_name`
2021 - `Commons::PackageUtils::get_httpd_pkg_name`
22+- `Commons::PackageUtils::get_httpd_serv_name`
2123 - `Commons::PackageUtils::get_jsvc_pkg_name`
2224 - `Commons::PackageUtils::get_libbz2_pkg_name`
2325
26+#### recipes
27+- `commons::crond` - installs cron package and enables & starts the service.
28+- `commons::httpd` - installs httpd package and enables & starts the service.
29+
2430 License and Authors
2531 -------------------
2632 - Author:: whitestar at osdn.jp
--- a/cookbooks/commons/libraries/package_utils.rb
+++ b/cookbooks/commons/libraries/package_utils.rb
@@ -27,6 +27,14 @@ module Commons
2727 end
2828
2929
30+ def get_cron_serv_name
31+ case node[:platform_family]
32+ when 'debian'then return 'cron'
33+ when 'rhel' then return 'crond'
34+ end
35+ end
36+
37+
3038 def get_httpd_pkg_name
3139 case node[:platform_family]
3240 when 'debian'then return 'apache2'
@@ -35,6 +43,14 @@ module Commons
3543 end
3644
3745
46+ def get_httpd_serv_name
47+ case node[:platform_family]
48+ when 'debian'then return 'apache2'
49+ when 'rhel' then return 'httpd'
50+ end
51+ end
52+
53+
3854 def get_jsvc_pkg_name
3955 case node[:platform_family]
4056 when 'debian' then return 'jsvc'
--- a/cookbooks/commons/metadata.rb
+++ b/cookbooks/commons/metadata.rb
@@ -4,4 +4,4 @@ maintainer_email ''
44 license 'Apache 2.0'
55 description 'Installs/Configures commons'
66 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-version '0.1.0'
7+version '0.2.0'
--- /dev/null
+++ b/cookbooks/commons/recipes/crond.rb
@@ -0,0 +1,32 @@
1+#
2+# Cookbook Name:: commons
3+# Recipe:: crond
4+#
5+# Copyright 2015, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+::Chef::Recipe.send(:include, Commons::PackageUtils)
21+
22+pkg = get_cron_pkg_name
23+resources(:package => pkg) rescue package pkg do
24+ action :install
25+end
26+
27+serv = get_cron_serv_name
28+resources(:service => serv) rescue service serv do
29+ action [:enable, :start]
30+ supports :status => true, :restart => true, :reload => false
31+end
32+
--- /dev/null
+++ b/cookbooks/commons/recipes/httpd.rb
@@ -0,0 +1,32 @@
1+#
2+# Cookbook Name:: commons
3+# Recipe:: httpd
4+#
5+# Copyright 2015, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+::Chef::Recipe.send(:include, Commons::PackageUtils)
21+
22+pkg = get_httpd_pkg_name
23+resources(:package => pkg) rescue package pkg do
24+ action :install
25+end
26+
27+serv = get_httpd_serv_name
28+resources(:service => serv) rescue service serv do
29+ action [:enable, :start]
30+ supports :status => true, :restart => true, :reload => false
31+end
32+
--- a/roles/chef-client.rb
+++ b/roles/chef-client.rb
@@ -18,7 +18,8 @@ name 'chef-client'
1818 description 'Chef Client'
1919
2020 run_list(
21- 'recipe[chef-client::cron]'
21+ 'recipe[commons::crond]',
22+ 'recipe[chef-client::cron]',
2223 )
2324
2425 #env_run_lists()
Show on old repository browser