• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Révisione5dda46c390d2fb4dcc057959de7f3faf28a4041 (tree)
l'heure2013-06-04 21:42:31
Auteurwhitestar <whitestar@gaea...>
Commiterwhitestar

Message de Log

Import chef-client version 2.2.4

Change Summary

Modification

--- /dev/null
+++ b/cookbooks/chef-client/.gitignore
@@ -0,0 +1,14 @@
1+.vagrant
2+Berksfile.lock
3+Gemfile.lock
4+*~
5+*#
6+.#*
7+\#*#
8+.*.sw[a-z]
9+*.un~
10+.bundle
11+.cache
12+.kitchen
13+bin
14+.kitchen.local.yml
--- /dev/null
+++ b/cookbooks/chef-client/.kitchen.yml
@@ -0,0 +1,94 @@
1+---
2+driver_plugin: vagrant
3+platforms:
4+- name: ubuntu-12.04
5+ driver_config:
6+ box: canonical-ubuntu-12.04
7+ box_url: http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box
8+ require_chef_omnibus: 11.4.0
9+- name: ubuntu-10.04
10+ driver_config:
11+ box: opscode-ubuntu-10.04
12+ box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_chef-11.2.0.box
13+ require_chef_omnibus: 11.4.0
14+- name: centos-6.3
15+ driver_config:
16+ box: opscode-centos-6.3
17+ box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.3_chef-11.2.0.box
18+ require_chef_omnibus: 11.4.0
19+- name: centos-5.8
20+ driver_config:
21+ box: opscode-centos-5.8
22+ box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.8_chef-11.2.0.box
23+ require_chef_omnibus: 11.4.0
24+
25+suites:
26+- name: config
27+ run_list:
28+ - recipe[chef-client::config]
29+ attributes: {}
30+- name: service_init
31+ run_list:
32+ - recipe[minitest-handler]
33+ - recipe[chef-client::config]
34+ - recipe[chef-client_test::service_init]
35+ - recipe[chef-client::service]
36+ attributes: { chef_client: { init_style: "init" } }
37+- name: service_runit
38+ run_list:
39+ - recipe[minitest-handler]
40+ - recipe[runit]
41+ - recipe[chef-client_test::service_runit]
42+ - recipe[chef-client::service]
43+ attributes: { chef_client: { init_style: "runit" } }
44+- name: cron
45+ run_list:
46+ - recipe[chef-client::cron]
47+ attributes: {}
48+- name: delete_validation
49+ run_list:
50+ - recipe[chef-client::delete_validation]
51+- name: cook-2092
52+ run_list:
53+ - recipe[minitest-handler]
54+ - recipe[chef-client_test::cook-2092]
55+ - recipe[chef-client::config]
56+ attributes:
57+ chef_client:
58+ log_file: "client.log"
59+- name: cook-2169-root
60+ run_list:
61+ - recipe[minitest-handler]
62+ - recipe[chef-client_test::cook-2169-root]
63+ - recipe[chef-client::cron]
64+ attributes: {}
65+- name: cook-2169-chef
66+ run_list:
67+ - recipe[minitest-handler]
68+ - recipe[chef-client_test::cook-2169-chef]
69+ - recipe[chef-client::cron]
70+ attributes: {}
71+- name: cook-2086
72+ run_list:
73+ - recipe[minitest-handler]
74+ - recipe[chef-client_test::cook-2086]
75+ - recipe[chef-client::cron]
76+ attributes:
77+ chef_client:
78+ environment_variables: "FOO=BAR"
79+- name: cook-2317
80+ run_list:
81+ - recipe[minitest-handler]
82+ - recipe[chef-client_test::cook-2317]
83+ attributes:
84+ ohai:
85+ disabled_plugins: ["passwd"]
86+- name: cook-1951
87+ run_list:
88+ - recipe[minitest-handler]
89+ - recipe[chef-client::config]
90+ - recipe[chef-client_test::cook-1951]
91+ attributes:
92+ chef_client:
93+ init_style: "init"
94+ daemon_options: ["-E cook-1951"]
\ No newline at end of file
--- /dev/null
+++ b/cookbooks/chef-client/Berksfile
@@ -0,0 +1,10 @@
1+site :opscode
2+
3+metadata
4+
5+group :integration do
6+ cookbook "minitest-handler"
7+ cookbook "runit"
8+ cookbook "apt"
9+ cookbook "chef-client_test", :path => "./test/cookbooks/chef-client_test"
10+end
--- /dev/null
+++ b/cookbooks/chef-client/CHANGELOG.md
@@ -0,0 +1,157 @@
1+## v2.2.4
2+
3+### Bug
4+
5+- [COOK-2687]: chef-client::service doesn't work on SLES 11
6+- [COOK-2689]: chef-client service recipe on windows fails to start
7+- [COOK-2700]: chef-client cookbook should have more splay
8+- [COOK-2952]: chef-client cookbook has foodcritic failures
9+
10+### Sub-task
11+
12+- [COOK-2823]: Chef-client SMF manifest should set locale to UTF-8
13+
14+## v2.2.2:
15+
16+* [COOK-2393] - chef-client::delete_validation checks for chef-server
17+ in the path, on chef 11, needs to check for chef-server-ctl
18+* [COOK-2410] - chef-client::service doesn't always start the
19+ chef-client daemon
20+* [COOK-2413] - Deprecation warning when using Chef::Mixin::Language
21+ in chef-client cookbook under chef 11.x
22+* [COOK-2446] - Typo: the chef-client executable has a hyphen
23+* [COOK-2492] - Ruby System("") call that includes an '&' on Ubuntu
24+ has odd behavior.
25+* [COOK-2536] - On Freebsd - chef-client group values in helper
26+ library should be set to "wheel" vs [ "wheel" ]
27+
28+## v2.2.0:
29+
30+* [COOK-2317] - Provide the ability to add disabled ohai plugins in a
31+ managed chef config
32+* [COOK-2255] - Chef-Client Cookbook init.d script under ubuntu
33+
34+## v2.1.10:
35+
36+* [COOK-2316] - Permissions for SMF init type break Solaris 10
37+
38+## v2.1.8:
39+
40+* [COOK-2192] - Add option to use cron_d resource for cron management
41+* [COOK-2261] - pin runit dependency
42+
43+## v2.1.6:
44+
45+* [COOK-1978] - make cron output location configurable
46+* [COOK-2169] - use helper library to make path permissions consistent
47+* [COOK-2170] - test filename cleanup (dev repository only)
48+
49+## v2.1.4:
50+
51+* [COOK-2108] - corrected Chef and Ohai version requirements in README
52+
53+## v2.1.2:
54+
55+* [COOK-2071] - chef-client breaks on value_for_platform_family b/c of
56+ unneeded version
57+* [COOK-2072] - chef-client on mac should not attempt to create
58+ directory nil
59+* [COOK-2086] - Allow the passing of an enviornment variables to
60+ node['chef-client']['bin']
61+* [COOK-2092] - chef-client run fails because quotes in log_path cause
62+ File resource to fail
63+
64+## v2.1.0:
65+
66+* [COOK-1755] - Don't delete the validation key on systems that have a
67+ 'chef-server' binary in the default $PATH
68+* [COOK-1898] - Support Handlers and Cache Options with Attributes
69+* [COOK-1923] - support chef-client::cron on Solaris/SmartOS
70+* [COOK-1924] - use splay for size of random offset in
71+ chef-client::cron
72+* [COOK-1927] - unknown node[:fqdn] prevents bootstrap if
73+ chef-client::cron is in runlist
74+* [COOK-1951] - Add an attribute for additional daemon options to pass
75+ to the chef-client service
76+* [COOK-2004] - in attributes, "init" style claims to handle fedora,
77+ but service.rb missing a clause
78+* [COOK-2017] - Support alternate chef-client locations in Mac OS X
79+ Launchd service plist
80+* [COOK-2052] - Log files are set to insecure default
81+
82+## v2.0.2:
83+
84+* Remove a stray comma that caused syntax error on some versions of Ruby.
85+
86+## v2.0.0:
87+
88+This version uses platform_family attribute, making the cookbook incompatible
89+with older versions of Chef/Ohai, hence the major version bump.
90+
91+* [COOK-635] - Allow configuration of path to chef-client binary in init script
92+* [COOK-985] - set correct permissions on run and log directory for chef-servers using this cookbook
93+* [COOK-1379] - Register chef-client as a launchd service on Mac OS X (Server)
94+* [COOK-1574] - config recipe doesn't work on Windows
95+* [COOK-1586] - add SmartOS support
96+* [COOK-1633] - chef-client doesn't recognise Oracle Linux, a Redhat family member
97+* [COOK-1634] - chef-client init is missing for Scientific Linux
98+* [COOK-1664] - corrected permissions in cron recipe (related to COOK-985)
99+* [COOK-1729] - support windows task
100+* [COOK-1788] - `init_style` upstart only works on Ubuntu
101+* [COOK-1861] - Minor styling fix for consistency in chef-client
102+* [COOK-1862] - add `name` attribute to metadata.rb
103+
104+## v1.2.0:
105+
106+This version of the cookbook also adds minitest and test-kitchen
107+support.
108+
109+* [COOK-599] - chef-client::config recipe breaks folder permissions of
110+ chef-server::rubygems-install recipe on same node
111+* [COOK-1111] - doesn't work out of the box with knife bootstrap
112+ windows
113+* [COOK-1161] - allow setting log file and environment in client.rb
114+* [COOK-1203] - allow PATH setting for cron
115+* [COOK-1254] - service silently fails on ubuntu 12.04 with ruby 1.9.3
116+* [COOK-1309] - cron recipe expects SANE_PATHS constant
117+* [COOK-1345] - preformat log location before sending to template
118+* [COOK-1377] - allow client.rb to require gems
119+* [COOK-1419] - add init script for SUSE
120+* [COOK-1463] - Add verbose_logging knob for config recipe, client.rb
121+ template
122+* [COOK-1506] - set an attribute for server_url
123+* [COOK-1566] - remove random splay for unique sleep number
124+
125+## v1.1.4:
126+
127+* [COOK-599] - don't break folder permissions if chef-server recipe is present
128+
129+## v1.1.2:
130+
131+* [COOK-1039] - support mac_os_x_server
132+
133+## v1.1.0:
134+
135+* [COOK-909] - trigger upstart on correct event
136+* [COOK-795] - add windows support with winsw
137+* [COOK-798] - added recipe to run chef-client as a cron job
138+* [COOK-986] - don't delete the validation.pem if chef-server recipe
139+ is detected
140+
141+## v1.0.4:
142+
143+* [COOK-670] - Added Solaris service-installation support for chef-client cookbook.
144+* [COOK-781] - chef-client service recipe fails with chef 0.9.x
145+
146+## v1.0.2:
147+
148+* [CHEF-2491] init scripts should implement reload
149+
150+## v1.0.0:
151+
152+* [COOK-204] chef::client pid template doesn't match package expectations
153+* [COOK-491] service config/defaults should not be pulled from Chef gem
154+* [COOK-525] Tell bluepill to daemonize chef-client command
155+* [COOK-554] Typo in backup_path
156+* [COOK-609] chef-client cookbook fails if init_type is set to upstart and chef is installed from deb
157+* [COOK-635] Allow configuration of path to chef-client binary in init script
--- /dev/null
+++ b/cookbooks/chef-client/CONTRIBUTING
@@ -0,0 +1,29 @@
1+If you would like to contribute, please open a ticket in JIRA:
2+
3+* http://tickets.opscode.com
4+
5+Create the ticket in the COOK project and use the cookbook name as the
6+component.
7+
8+For all code contributions, we ask that contributors sign a
9+contributor license agreement (CLA). Instructions may be found here:
10+
11+* http://wiki.opscode.com/display/chef/How+to+Contribute
12+
13+When contributing changes to individual cookbooks, please do not
14+modify the version number in the metadata.rb. Also please do not
15+update the CHANGELOG.md for a new version. Not all changes to a
16+cookbook may be merged and released in the same versions. Opscode will
17+handle the version updates during the release process. You are welcome
18+to correct typos or otherwise make updates to documentation in the
19+README.
20+
21+If a contribution adds new platforms or platform versions, indicate
22+such in the body of the commit message(s), and update the relevant
23+COOK ticket. When writing commit messages, it is helpful for others if
24+you indicate the COOK ticket. For example:
25+
26+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
27+
28+In the ticket itself, it is also helpful if you include log output of
29+a successful Chef run, but this is not absolutely required.
--- /dev/null
+++ b/cookbooks/chef-client/LICENSE
@@ -0,0 +1,201 @@
1+ Apache License
2+ Version 2.0, January 2004
3+ http://www.apache.org/licenses/
4+
5+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+1. Definitions.
8+
9+ "License" shall mean the terms and conditions for use, reproduction,
10+ and distribution as defined by Sections 1 through 9 of this document.
11+
12+ "Licensor" shall mean the copyright owner or entity authorized by
13+ the copyright owner that is granting the License.
14+
15+ "Legal Entity" shall mean the union of the acting entity and all
16+ other entities that control, are controlled by, or are under common
17+ control with that entity. For the purposes of this definition,
18+ "control" means (i) the power, direct or indirect, to cause the
19+ direction or management of such entity, whether by contract or
20+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21+ outstanding shares, or (iii) beneficial ownership of such entity.
22+
23+ "You" (or "Your") shall mean an individual or Legal Entity
24+ exercising permissions granted by this License.
25+
26+ "Source" form shall mean the preferred form for making modifications,
27+ including but not limited to software source code, documentation
28+ source, and configuration files.
29+
30+ "Object" form shall mean any form resulting from mechanical
31+ transformation or translation of a Source form, including but
32+ not limited to compiled object code, generated documentation,
33+ and conversions to other media types.
34+
35+ "Work" shall mean the work of authorship, whether in Source or
36+ Object form, made available under the License, as indicated by a
37+ copyright notice that is included in or attached to the work
38+ (an example is provided in the Appendix below).
39+
40+ "Derivative Works" shall mean any work, whether in Source or Object
41+ form, that is based on (or derived from) the Work and for which the
42+ editorial revisions, annotations, elaborations, or other modifications
43+ represent, as a whole, an original work of authorship. For the purposes
44+ of this License, Derivative Works shall not include works that remain
45+ separable from, or merely link (or bind by name) to the interfaces of,
46+ the Work and Derivative Works thereof.
47+
48+ "Contribution" shall mean any work of authorship, including
49+ the original version of the Work and any modifications or additions
50+ to that Work or Derivative Works thereof, that is intentionally
51+ submitted to Licensor for inclusion in the Work by the copyright owner
52+ or by an individual or Legal Entity authorized to submit on behalf of
53+ the copyright owner. For the purposes of this definition, "submitted"
54+ means any form of electronic, verbal, or written communication sent
55+ to the Licensor or its representatives, including but not limited to
56+ communication on electronic mailing lists, source code control systems,
57+ and issue tracking systems that are managed by, or on behalf of, the
58+ Licensor for the purpose of discussing and improving the Work, but
59+ excluding communication that is conspicuously marked or otherwise
60+ designated in writing by the copyright owner as "Not a Contribution."
61+
62+ "Contributor" shall mean Licensor and any individual or Legal Entity
63+ on behalf of whom a Contribution has been received by Licensor and
64+ subsequently incorporated within the Work.
65+
66+2. Grant of Copyright License. Subject to the terms and conditions of
67+ this License, each Contributor hereby grants to You a perpetual,
68+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+ copyright license to reproduce, prepare Derivative Works of,
70+ publicly display, publicly perform, sublicense, and distribute the
71+ Work and such Derivative Works in Source or Object form.
72+
73+3. Grant of Patent License. Subject to the terms and conditions of
74+ this License, each Contributor hereby grants to You a perpetual,
75+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76+ (except as stated in this section) patent license to make, have made,
77+ use, offer to sell, sell, import, and otherwise transfer the Work,
78+ where such license applies only to those patent claims licensable
79+ by such Contributor that are necessarily infringed by their
80+ Contribution(s) alone or by combination of their Contribution(s)
81+ with the Work to which such Contribution(s) was submitted. If You
82+ institute patent litigation against any entity (including a
83+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84+ or a Contribution incorporated within the Work constitutes direct
85+ or contributory patent infringement, then any patent licenses
86+ granted to You under this License for that Work shall terminate
87+ as of the date such litigation is filed.
88+
89+4. Redistribution. You may reproduce and distribute copies of the
90+ Work or Derivative Works thereof in any medium, with or without
91+ modifications, and in Source or Object form, provided that You
92+ meet the following conditions:
93+
94+ (a) You must give any other recipients of the Work or
95+ Derivative Works a copy of this License; and
96+
97+ (b) You must cause any modified files to carry prominent notices
98+ stating that You changed the files; and
99+
100+ (c) You must retain, in the Source form of any Derivative Works
101+ that You distribute, all copyright, patent, trademark, and
102+ attribution notices from the Source form of the Work,
103+ excluding those notices that do not pertain to any part of
104+ the Derivative Works; and
105+
106+ (d) If the Work includes a "NOTICE" text file as part of its
107+ distribution, then any Derivative Works that You distribute must
108+ include a readable copy of the attribution notices contained
109+ within such NOTICE file, excluding those notices that do not
110+ pertain to any part of the Derivative Works, in at least one
111+ of the following places: within a NOTICE text file distributed
112+ as part of the Derivative Works; within the Source form or
113+ documentation, if provided along with the Derivative Works; or,
114+ within a display generated by the Derivative Works, if and
115+ wherever such third-party notices normally appear. The contents
116+ of the NOTICE file are for informational purposes only and
117+ do not modify the License. You may add Your own attribution
118+ notices within Derivative Works that You distribute, alongside
119+ or as an addendum to the NOTICE text from the Work, provided
120+ that such additional attribution notices cannot be construed
121+ as modifying the License.
122+
123+ You may add Your own copyright statement to Your modifications and
124+ may provide additional or different license terms and conditions
125+ for use, reproduction, or distribution of Your modifications, or
126+ for any such Derivative Works as a whole, provided Your use,
127+ reproduction, and distribution of the Work otherwise complies with
128+ the conditions stated in this License.
129+
130+5. Submission of Contributions. Unless You explicitly state otherwise,
131+ any Contribution intentionally submitted for inclusion in the Work
132+ by You to the Licensor shall be under the terms and conditions of
133+ this License, without any additional terms or conditions.
134+ Notwithstanding the above, nothing herein shall supersede or modify
135+ the terms of any separate license agreement you may have executed
136+ with Licensor regarding such Contributions.
137+
138+6. Trademarks. This License does not grant permission to use the trade
139+ names, trademarks, service marks, or product names of the Licensor,
140+ except as required for reasonable and customary use in describing the
141+ origin of the Work and reproducing the content of the NOTICE file.
142+
143+7. Disclaimer of Warranty. Unless required by applicable law or
144+ agreed to in writing, Licensor provides the Work (and each
145+ Contributor provides its Contributions) on an "AS IS" BASIS,
146+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147+ implied, including, without limitation, any warranties or conditions
148+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149+ PARTICULAR PURPOSE. You are solely responsible for determining the
150+ appropriateness of using or redistributing the Work and assume any
151+ risks associated with Your exercise of permissions under this License.
152+
153+8. Limitation of Liability. In no event and under no legal theory,
154+ whether in tort (including negligence), contract, or otherwise,
155+ unless required by applicable law (such as deliberate and grossly
156+ negligent acts) or agreed to in writing, shall any Contributor be
157+ liable to You for damages, including any direct, indirect, special,
158+ incidental, or consequential damages of any character arising as a
159+ result of this License or out of the use or inability to use the
160+ Work (including but not limited to damages for loss of goodwill,
161+ work stoppage, computer failure or malfunction, or any and all
162+ other commercial damages or losses), even if such Contributor
163+ has been advised of the possibility of such damages.
164+
165+9. Accepting Warranty or Additional Liability. While redistributing
166+ the Work or Derivative Works thereof, You may choose to offer,
167+ and charge a fee for, acceptance of support, warranty, indemnity,
168+ or other liability obligations and/or rights consistent with this
169+ License. However, in accepting such obligations, You may act only
170+ on Your own behalf and on Your sole responsibility, not on behalf
171+ of any other Contributor, and only if You agree to indemnify,
172+ defend, and hold each Contributor harmless for any liability
173+ incurred by, or claims asserted against, such Contributor by reason
174+ of your accepting any such warranty or additional liability.
175+
176+END OF TERMS AND CONDITIONS
177+
178+APPENDIX: How to apply the Apache License to your work.
179+
180+ To apply the Apache License to your work, attach the following
181+ boilerplate notice, with the fields enclosed by brackets "[]"
182+ replaced with your own identifying information. (Don't include
183+ the brackets!) The text should be enclosed in the appropriate
184+ comment syntax for the file format. We also recommend that a
185+ file or class name and description of purpose be included on the
186+ same "printed page" as the copyright notice for easier
187+ identification within third-party archives.
188+
189+Copyright [yyyy] [name of copyright owner]
190+
191+Licensed under the Apache License, Version 2.0 (the "License");
192+you may not use this file except in compliance with the License.
193+You may obtain a copy of the License at
194+
195+ http://www.apache.org/licenses/LICENSE-2.0
196+
197+Unless required by applicable law or agreed to in writing, software
198+distributed under the License is distributed on an "AS IS" BASIS,
199+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200+See the License for the specific language governing permissions and
201+limitations under the License.
--- /dev/null
+++ b/cookbooks/chef-client/README.md
@@ -0,0 +1,289 @@
1+Description
2+===========
3+
4+This cookbook is used to configure a system as a Chef Client.
5+
6+Requirements
7+============
8+
9+Chef 0.10.10 and Ohai 0.6.12 are required due to the use of
10+`platform_family`.
11+
12+Platforms
13+---------
14+
15+The following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error.
16+
17+* Debian family (Debian, Ubuntu etc)
18+* Red Hat family (Redhat, CentOS, Oracle etc)
19+* Fedora family
20+* SUSE distributions (OpenSUSE, SLES, etc)
21+* ArchLinux
22+* FreeBSD
23+* Mac OS X
24+* Mac OS X Server
25+
26+Opscode Cookbooks
27+-----------------
28+
29+The `chef-client::cron` recipe requires the `cron_d` LWRP from Opscode's cron cookbook, so that is a dependency, otherwise the cron recipe will fail to converge.
30+
31+Other cookbooks can be used with this cookbook but they are not explicitly required. The default settings in this cookbook do not require their use. The other cookbooks (on community.opsocde.com) are:
32+
33+* bluepill
34+* daemontools
35+* runit
36+
37+See __USAGE__ below.
38+
39+Attributes
40+==========
41+
42+* `node["chef_client"]["interval"]` - Sets `Chef::Config[:interval]` via command-line option for number of seconds between chef-client daemon runs. Default 1800.
43+* `node["chef_client"]["splay"]` - Sets `Chef::Config[:splay]` via command-line option for a random amount of seconds to add to interval. Default 20.
44+* `node["chef_client"]["log_dir"]` - Sets directory used in `Chef::Config[:log_location]` via command-line option to a location where chef-client should log output. Default "/var/log/chef".
45+* `node["chef_client"]["conf_dir"]` - Sets directory used via command-line option to a location where chef-client search for the client config file . Default "/etc/chef".
46+* `node["chef_client"]["bin"]` - Sets the full path to the `chef-client` binary. Mainly used to set a specific path if multiple versions of chef-client exist on a system or the bin has been installed in a non-sane path. Default "/usr/bin/chef-client".
47+* `node["chef_client"]["server_url"]` - Sets `Chef::Config[:chef_server_url]` in the config file to the Chef Server URI. Default "http://localhost:4000". See __USAGE__.
48+* `node["chef_client"]["validation_client_name"]` - Sets `Chef::Config[:validation_client_name]` in the config file to the name of the validation client. Default "chef-validator". See __USAGE__.
49+* `node["chef_client"]["init_style"]` - Sets up the client service based on the style of init system to use. Default is based on platform and falls back to "none". See __USAGE__.
50+* `node["chef_client"]["run_path"]` - Directory location where chef-client should write the PID file. Default based on platform, falls back to "/var/run".
51+* `node["chef_client"]["cache_path"]` - Directory location for `Chef::Config[:file_cache_path]` where chef-client will cache various files. Default is based on platform, falls back to "/var/chef/cache".
52+* `node["chef_client"]["backup_path"]` - Directory location for `Chef::Config[:file_backup_path]` where chef-client will backup templates and cookbook files. Default is based on platform, falls back to "/var/chef/backup".
53+* `node["chef_client"]["cron"]["minute"]` - The hour that chef-client will run as a cron task, only applicable if the you set "cron" as the "init_style"
54+* `node["chef_client"]["cron"]["hour"]` - The hour that chef-client will run as a cron task, only applicable if the you set "cron" as the "init_style"
55+* `node["chef_client"]["cron"]["environment_variables"]` - Environment variables to pass to chef-client's execution (e.g. SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt chef-client)
56+* `node["chef_client"]["cron"]["log_file"]` - Location to capture the chef-client output.
57+* `node["chef_client"]["cron"]["use_cron_d"]` - If true, use the "cron_d" LWRP (https://github.com/opscode-cookbooks/cron). If false (default), use the cron resource built-in to Chef.
58+* `node["chef_client"]["load_gems"]` - Hash of gems to load into chef via the client.rb file
59+* `node["chef_client"]["report_handlers"]` - Array of Hashes that contain a class and arguments element appended in the client.rb file. ex: `{:class => "MyHandler", :arguments => [true]}
60+* `node["chef_client"]["exception_handlers"]` - Array of Hashes that contain a class and arguments element appended in the client.rb file. ex: `{:class => "MyHandler", :arguments => [true]}
61+* `node["chef_client"]["checksum_cache_skip_expires"]` - true or false value used in the `cache_options` section of the client.rb file.
62+* `node["chef_client"]["checksum_cache_path"]` - file system path used in the `cache_options` section of the client.rb file.
63+* `node["chef_client"]["launchd_mode"]` - (Only for Mac OS X) if set to "daemon", runs chef-client with `-d` and `-s` options; defaults to "interval"
64+* `node["chef_client"]["daemon_options"]` - An array of additional options to pass to the chef-client service, empty by default, and must be an array if specified.
65+* `node["ohai"]["disabled_plugins"]` - An array of ohai plugins to disable, empty by default, and must be an array if specified.
66+
67+Recipes
68+=======
69+
70+This section describes the recipes in the cookbook and how to use them in your environment.
71+
72+config
73+------
74+
75+Sets up the `/etc/chef/client.rb` config file from a template and reloads the configuration for the current chef-client run.
76+
77+service
78+-------
79+
80+Use this recipe on systems that should have a `chef-client` daemon running, such as when Knife bootstrap was used to install Chef on a new system.
81+
82+This recipe sets up the `chef-client` service depending on the `init_style` attribute (see above). The following init styles are supported:
83+
84+* init - uses the init script included in the chef gem, supported on debian and redhat family distributions.
85+* upstart - uses the upstart job included in the chef gem, supported on ubuntu.
86+* arch - uses the init script included in this cookbook for ArchLinux, supported on arch.
87+* runit - sets up the service under runit, supported on ubuntu, debian and gentoo.
88+* bluepill - sets up the service under bluepill. As bluepill is a pure ruby process monitor, this should work on any platform.
89+* daemontools - sets up the service under daemontools, supported on debian, ubuntu and arch
90+* launchd - sets up the service under launchd, supported on Mac OS X & Mac OS X Server. (this requires Chef >= 0.10.10)
91+* bsd - prints a message about how to update BSD systems to enable the chef-client service, supported on Free/OpenBSD.
92+
93+default
94+-------
95+
96+Includes the `chef-client::service` recipe by default.
97+
98+delete_validation
99+-----------------
100+
101+Use this recipe to delete the validation certificate (default `/etc/chef/validation.pem`) when using a `chef-client` after the client has been validated and authorized to connect to the server.
102+
103+Beware if using this on your Chef Server. First copy the validation.pem certificate file to another location, such as your knife configuration directory (`~/.chef`) or [Chef Repository](http://wiki.opscode.com/display/chef/Chef+Repository).
104+
105+cron
106+----
107+
108+Use this recipe to run chef-client as a cron job rather than as a
109+service. The cron job runs after random delay that is between 0 and 90
110+seconds to ensure that the chef-clients don't attempt to connect to
111+the chef-server at the exact same time. You should set
112+node["chef_client"]["init_style"] = "none" when you use this mode but
113+it is not required.
114+
115+
116+
117+USAGE
118+=====
119+
120+Create a `base` role that will represent the base configuration for any system that includes managing aspects of the chef-client. Add recipes to the run list of the role, customize the attributes, and apply the role to nodes. For example, the following role (Ruby DSL) will set the init style to `init`, delete the validation certificate (as the client would already be authenticated) and set up the chef-client as a service using the init style.
121+
122+ name "base"
123+ description "Base role applied to all nodes"
124+ override_attributes(
125+ "chef_client" => {
126+ "init_style" => "init"
127+ }
128+ )
129+ run_list(
130+ "recipe[chef-client::delete_validation]",
131+ "recipe[chef-client::config]",
132+ "recipe[chef-client::service]"
133+ )
134+
135+The `chef-client::config` recipe is only required with init style `init` (default setting for the attribute on debian/redhat family platforms, because the init script doesn't include the `pid_file` option which is set in the config.
136+
137+The default Chef Server will be `http://localhost:4000` which is the `Chef::Config[:chef_server_url]` default value. To use the config recipe with the Opscode Platform, for example, add the following to the `override_attributes`
138+
139+ override_attributes(
140+ "chef_client" => {
141+ "server_url" => "https://api.opscode.com/organizations/ORGNAME",
142+ "validation_client_name" => "ORGNAME-validator"
143+ }
144+ )
145+
146+Where ORGNAME is your Opscode Platform organization name. Be sure to add these attributes to the role if modifying per the section below.
147+
148+You can also set all of the `Chef::Config` http proxy related settings. By default Chef will not use a proxy.
149+
150+ override_attributes(
151+ "chef_client" => {
152+ "http_proxy" => "http://proxy.vmware.com:3128",
153+ "https_proxy" => "http://proxy.vmware.com:3128",
154+ "http_proxy_user" => "my_username",
155+ "http_proxy_pass" => "Awe_some_Pass_Word!",
156+ "no_proxy" => "*.vmware.com,10.*"
157+ }
158+ )
159+
160+Alternate Init Styles
161+---------------------
162+
163+The alternate init styles available are:
164+
165+* runit
166+* bluepill
167+* daemontools
168+* none -- should be specified if you are running chef-client as cron job
169+
170+For usage, see below.
171+
172+# Runit
173+
174+To use runit, download the cookbook from the cookbook site.
175+
176+ knife cookbook site vendor runit -d
177+
178+Change the `init_style` to runit in the base role and add the runit recipe to the role's run list:
179+
180+ name "base"
181+ description "Base role applied to all nodes"
182+ override_attributes(
183+ "chef_client" => {
184+ "init_style" => "runit"
185+ }
186+ )
187+ run_list(
188+ "recipe[chef-client::delete_validation]",
189+ "recipe[runit]",
190+ "recipe[chef-client]"
191+ )
192+
193+The `chef-client` recipe will create the chef-client service configured with runit. The runit run script will be located in `/etc/sv/chef-client/run`. The output log will be in the runit service directory, `/etc/sv/chef-client/log/main/current`.
194+
195+# Bluepill
196+
197+To use bluepill, download the cookbook from the cookbook site.
198+
199+ knife cookbook site vendor bluepill -d
200+
201+Change the `init_style` to runit in the base role and add the bluepill recipe to the role's run list:
202+
203+ name "base"
204+ description "Base role applied to all nodes"
205+ override_attributes(
206+ "chef_client" => {
207+ "init_style" => "bluepill"
208+ }
209+ )
210+ run_list(
211+ "recipe[chef-client::delete_validation]",
212+ "recipe[bluepill]",
213+ "recipe[chef-client]"
214+ )
215+
216+The `chef-client` recipe will create the chef-client service configured with bluepill. The bluepill "pill" will be located in `/etc/bluepill/chef-client.pill`. The output log will be to client.log file in the `node["chef_client"]["log_dir"]` location, `/var/log/chef/client` by default.
217+
218+# Daemontools
219+
220+To use daemontools, download the cookbook from the cookbook site.
221+
222+ knife cookbook site vendor daemontools -d
223+
224+Change the `init_style` to runit in the base role and add the daemontools recipe to the role's run list:
225+
226+ name "base"
227+ description "Base role applied to all nodes"
228+ override_attributes(
229+ "chef_client" => {
230+ "init_style" => "daemontools"
231+ }
232+ )
233+ run_list(
234+ "recipe[chef-client::delete_validation]",
235+ "recipe[daemontools]",
236+ "recipe[chef-client]"
237+ )
238+
239+The `chef-client` recipe will create the chef-client service configured under daemontools. It uses the same sv run scripts as the runit recipe. The run script will be located in `/etc/sv/chef-client/run`. The output log will be in the daemontools service directory, `/etc/sv/chef-client/log/main/current`.
240+
241+# Launchd
242+
243+On Mac OS X and Mac OS X Server, the default service implementation is "launchd". Launchd support for the service resource is only supported from Chef 0.10.10 onwards.
244+An error message will be logged if you try to use the launchd service for chef-client on a Chef version that does not contain this launchd support.
245+
246+Since launchd can run a service in interval mode, by default chef-client is not started in daemon mode like on Debian or Ubuntu. Keep this in mind when you look at your process list and check for a running chef process! If you wish to run chef-client in daemon mode, set attribute `chef_client.launchd_mode` to "daemon".
247+
248+Templates
249+=========
250+
251+chef-client.pill.erb
252+--------------------
253+
254+Bluepill configuration for the chef-client service.
255+
256+client.rb.erb
257+-------------
258+
259+Configuration for the client, lands in directory specified by `node["chef_client"]["conf_dir"]` (`/etc/chef/client.rb` by default).
260+
261+`sv-chef-client-*run.erb`
262+-------------------------
263+
264+Runit and Daemontools run script for chef-client service and logs.
265+
266+Logs will be located in the `node["chef_client"]["log_dir"]`.
267+
268+com.opscode.chef-client.plist
269+-----------------------------
270+
271+Launchd configuration file for chef-client as a true Mac service. The template accepts the `node["chef_client"]["interval"]` value.
272+
273+License and Author
274+==================
275+
276+Author:: Joshua Timberman (<joshua@opscode.com>)
277+Author:: Seth Chisamore (<schisamo@opscode.com>)
278+Copyright:: 2010-2012, Opscode, Inc.
279+
280+Licensed under the Apache License, Version 2.0 (the "License");
281+you may not use this file except in compliance with the License.
282+You may obtain a copy of the License at
283+
284+ http://www.apache.org/licenses/LICENSE-2.0
285+
286+Unless required by applicable law or agreed to in writing, software
287+distributed under the License is distributed on an "AS IS" BASIS,
288+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
289+See the License for the specific language governing permissions and
--- /dev/null
+++ b/cookbooks/chef-client/TESTING.md
@@ -0,0 +1,25 @@
1+This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
2+
3+1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
4+2. You must have Vagrant 1.1 installed.
5+3. You must have a "sane" Ruby 1.9.3 environment.
6+
7+Once the above requirements are met, install the additional requirements:
8+
9+Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
10+
11+ vagrant plugin install vagrant-berkshelf
12+ gem install berkshelf
13+
14+Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
15+
16+ gem install test-kitchen --pre
17+
18+Install the Vagrant driver for Test Kitchen.
19+
20+ gem install kitchen-vagrant
21+
22+Once the above are installed, you should be able to run Test Kitchen:
23+
24+ kitchen list
25+ kitchen test
--- /dev/null
+++ b/cookbooks/chef-client/attributes/default.rb
@@ -0,0 +1,112 @@
1+#
2+# Author:: Joshua Timberman (<joshua@opscode.com>)
3+# Author:: Seth Chisamore (<schisamo@opscode.com>)
4+# Cookbook Name:: chef
5+# Attributes:: default
6+#
7+# Copyright 2008-2011, Opscode, Inc
8+#
9+# Licensed under the Apache License, Version 2.0 (the "License");
10+# you may not use this file except in compliance with the License.
11+# You may obtain a copy of the License at
12+#
13+# http://www.apache.org/licenses/LICENSE-2.0
14+#
15+# Unless required by applicable law or agreed to in writing, software
16+# distributed under the License is distributed on an "AS IS" BASIS,
17+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+# See the License for the specific language governing permissions and
19+# limitations under the License.
20+
21+require 'rbconfig'
22+
23+default["chef_client"]["interval"] = "1800"
24+default["chef_client"]["splay"] = "300"
25+default["chef_client"]["log_dir"] = "/var/log/chef"
26+default["chef_client"]["log_file"] = nil
27+default["chef_client"]["log_level"] = :info
28+default["chef_client"]["verbose_logging"] = true
29+default["chef_client"]["conf_dir"] = "/etc/chef"
30+default["chef_client"]["bin"] = "/usr/bin/chef-client"
31+default["chef_client"]["server_url"] = "http://localhost:4000"
32+default["chef_client"]["validation_client_name"] = "chef-validator"
33+default["chef_client"]["cron"] = {
34+ "minute" => "0",
35+ "hour" => "*/4",
36+ "path" => nil,
37+ "environment_variables" => nil,
38+ "log_file" => "/dev/null",
39+ "use_cron_d" => false
40+}
41+default["chef_client"]["environment"] = nil
42+default["chef_client"]["load_gems"] = {}
43+default["chef_client"]["report_handlers"] = []
44+default["chef_client"]["exception_handlers"] = []
45+default["chef_client"]["checksum_cache_skip_expires"] = true
46+default["chef_client"]["daemon_options"] = []
47+default["ohai"]["disabled_plugins"] = [] #Sets disabled_plugins to empty array
48+
49+case node['platform_family']
50+when "arch"
51+ default["chef_client"]["init_style"] = "arch"
52+ default["chef_client"]["run_path"] = "/var/run/chef"
53+ default["chef_client"]["cache_path"] = "/var/cache/chef"
54+ default["chef_client"]["backup_path"] = "/var/lib/chef"
55+when "debian","rhel","fedora","suse"
56+ default["chef_client"]["init_style"] = "init"
57+ default["chef_client"]["run_path"] = "/var/run/chef"
58+ default["chef_client"]["cache_path"] = "/var/cache/chef"
59+ default["chef_client"]["backup_path"] = "/var/lib/chef"
60+when "openbsd","freebsd"
61+ default["chef_client"]["init_style"] = "bsd"
62+ default["chef_client"]["run_path"] = "/var/run"
63+ default["chef_client"]["cache_path"] = "/var/chef/cache"
64+ default["chef_client"]["backup_path"] = "/var/chef/backup"
65+# don't use bsd paths per COOK-1379
66+when "mac_os_x","mac_os_x_server"
67+ default["chef_client"]["init_style"] = "launchd"
68+ default["chef_client"]["log_dir"] = "/Library/Logs/Chef"
69+ # Launchd doesn't use pid files
70+ default["chef_client"]["run_path"] = "/var/run/chef"
71+ default["chef_client"]["cache_path"] = "/Library/Caches/Chef"
72+ default["chef_client"]["backup_path"] = "/Library/Caches/Chef/Backup"
73+ # Set to "daemon" if you want chef-client to run
74+ # continuously with the -d and -s options, or leave
75+ # as "interval" if you want chef-client to be run
76+ # periodically by launchd
77+ default["chef_client"]["launchd_mode"] = "interval"
78+when "openindiana","opensolaris","nexentacore","solaris2"
79+ default["chef_client"]["init_style"] = "smf"
80+ default["chef_client"]["run_path"] = "/var/run/chef"
81+ default["chef_client"]["cache_path"] = "/var/chef/cache"
82+ default["chef_client"]["backup_path"] = "/var/chef/backup"
83+ default["chef_client"]["method_dir"] = "/lib/svc/method"
84+ default["chef_client"]["bin_dir"] = "/usr/bin"
85+when "smartos"
86+ default["chef_client"]["init_style"] = "smf"
87+ default["chef_client"]["run_path"] = "/var/run/chef"
88+ default["chef_client"]["cache_path"] = "/var/chef/cache"
89+ default["chef_client"]["backup_path"] = "/var/chef/backup"
90+ default["chef_client"]["method_dir"] = "/opt/local/lib/svc/method"
91+ default["chef_client"]["bin_dir"] = "/opt/local/bin"
92+when "windows"
93+ default["chef_client"]["init_style"] = "winsw"
94+ default["chef_client"]["conf_dir"] = "C:/chef"
95+ default["chef_client"]["run_path"] = "#{node["chef_client"]["conf_dir"]}/run"
96+ default["chef_client"]["cache_path"] = "#{node["chef_client"]["conf_dir"]}/cache"
97+ default["chef_client"]["backup_path"] = "#{node["chef_client"]["conf_dir"]}/backup"
98+ default["chef_client"]["log_dir"] = "#{node["chef_client"]["conf_dir"]}/log"
99+ default["chef_client"]["bin"] = "C:/opscode/chef/bin/chef-client"
100+ #Required for minsw wrapper
101+ default["chef_client"]["ruby_bin"] = File.join(RbConfig::CONFIG['bindir'], "ruby.exe")
102+ default["chef_client"]["winsw_url"] = "http://repo1.maven.org/maven2/com/sun/winsw/winsw/1.9/winsw-1.9-bin.exe"
103+ default["chef_client"]["winsw_dir"] = "C:/chef/bin"
104+ default["chef_client"]["winsw_exe"] = "chef-client.exe"
105+else
106+ default["chef_client"]["init_style"] = "none"
107+ default["chef_client"]["run_path"] = "/var/run"
108+ default["chef_client"]["cache_path"] = "/var/chef/cache"
109+ default["chef_client"]["backup_path"] = "/var/chef/backup"
110+end
111+
112+default["chef_client"]["checksum_cache_path"] = "#{node["chef_client"]["cache_path"]}/checksums"
--- /dev/null
+++ b/cookbooks/chef-client/files/default/tests/minitest/config_test.rb
@@ -0,0 +1,24 @@
1+#
2+# Copyright 2012, Opscode, Inc.
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+require File.expand_path('../support/helpers', __FILE__)
18+
19+describe 'chef-client::config' do
20+ include Helpers::ChefClient
21+ it 'creates the client config file' do
22+ file("#{node['chef_client']['conf_dir']}/client.rb").must_exist
23+ end
24+end
--- /dev/null
+++ b/cookbooks/chef-client/files/default/tests/minitest/cron_test.rb
@@ -0,0 +1,29 @@
1+#
2+# Copyright 2012, Opscode, Inc.
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+require File.expand_path('../support/helpers', __FILE__)
18+
19+describe 'chef-client::cron' do
20+ include Helpers::ChefClient
21+ it 'creates the cron job for chef-client' do
22+ cron("chef-client").must_exist
23+ end
24+
25+ it 'creates the cron command' do
26+ cron("chef-client").command.
27+ must_match %r{/bin/sleep \d+; /usr/bin/chef-client &> /dev/null}
28+ end
29+end
--- /dev/null
+++ b/cookbooks/chef-client/files/default/tests/minitest/delete_validation_test.rb
@@ -0,0 +1,24 @@
1+#
2+# Copyright 2012, Opscode, Inc.
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+require File.expand_path('../support/helpers', __FILE__)
18+
19+describe 'chef-client::delete_validation' do
20+ include Helpers::ChefClient
21+ it 'deletes the validation key file' do
22+ file(Chef::Config[:validation_key]).wont_exist
23+ end
24+end
--- /dev/null
+++ b/cookbooks/chef-client/files/default/tests/minitest/service_test.rb
@@ -0,0 +1,24 @@
1+#
2+# Copyright 2012, Opscode, Inc.
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+require File.expand_path('../support/helpers', __FILE__)
18+
19+describe 'chef-client::service' do
20+ include Helpers::ChefClient
21+ it "starts the chef-client service" do
22+ service("chef-client").must_be_running
23+ end
24+end
--- /dev/null
+++ b/cookbooks/chef-client/files/default/tests/minitest/support/helpers.rb
@@ -0,0 +1,23 @@
1+#
2+# Copyright 2012, Opscode, Inc.
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+module Helpers
18+ module ChefClient
19+ include MiniTest::Chef::Assertions
20+ include MiniTest::Chef::Context
21+ include MiniTest::Chef::Resources
22+ end
23+end
--- /dev/null
+++ b/cookbooks/chef-client/libraries/helpers.rb
@@ -0,0 +1,72 @@
1+#
2+# Author:: John Dewey (<john@dewey.ws>)
3+# Cookbook Name:: chef-client
4+# Library:: helpers
5+#
6+# Copyright 2012, John Dewey
7+#
8+# Licensed under the Apache License, Version 2.0 (the "License");
9+# you may not use this file except in compliance with the License.
10+# You may obtain a copy of the License at
11+#
12+# http://www.apache.org/licenses/LICENSE-2.0
13+#
14+# Unless required by applicable law or agreed to in writing, software
15+# distributed under the License is distributed on an "AS IS" BASIS,
16+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+# See the License for the specific language governing permissions and
18+# limitations under the License.
19+
20+module Opscode
21+ module ChefClient
22+ module Helpers
23+ if Chef::VERSION >= '11.0.0'
24+ include Chef::DSL::PlatformIntrospection
25+ else
26+ include Chef::Mixin::Language
27+ end
28+
29+ def chef_server?
30+ if node["platform"] == "windows"
31+ node.recipe?("chef-server")
32+ else
33+ Chef::Log.debug("Node has Chef Server Recipe? #{node.recipe?("chef-server")}")
34+ Chef::Log.debug("Node has Chef Server Executable? #{system("which chef-server > /dev/null ")}")
35+ Chef::Log.debug("Node has Chef Server Ctl Executable? #{system("which chef-server-ctl > /dev/null")}")
36+ node.recipe?("chef-server") || system("which chef-server > /dev/null ") || system("which chef-server-ctl > /dev/null")
37+ end
38+ end
39+
40+ def create_directories
41+ return if node["platform"] == "windows"
42+
43+ server = chef_server?
44+ Chef::Log.debug("Chef Server? #{server}")
45+
46+ %w{run_path cache_path backup_path log_dir conf_dir}.each do |key|
47+ directory node["chef_client"][key] do
48+ recursive true
49+ if key == "log_dir"
50+ mode 00750
51+ else
52+ mode 00755
53+ end
54+ if server
55+ owner "chef"
56+ group "chef"
57+ else
58+ owner value_for_platform(
59+ ["windows"] => { "default" => "Administrator" },
60+ "default" => "root"
61+ )
62+ group value_for_platform_family(
63+ ["openbsd", "freebsd", "mac_os_x"] => "wheel",
64+ "default" => "root"
65+ )
66+ end
67+ end
68+ end
69+ end
70+ end
71+ end
72+end
--- /dev/null
+++ b/cookbooks/chef-client/metadata.json
@@ -0,0 +1,50 @@
1+{
2+ "name": "chef-client",
3+ "description": "Manages aspects of only chef-client",
4+ "long_description": "Description\n===========\n\nThis cookbook is used to configure a system as a Chef Client.\n\nRequirements\n============\n\nChef 0.10.10 and Ohai 0.6.12 are required due to the use of\n`platform_family`.\n\nPlatforms\n---------\n\nThe following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error.\n\n* Debian family (Debian, Ubuntu etc)\n* Red Hat family (Redhat, CentOS, Oracle etc)\n* Fedora family\n* SUSE distributions (OpenSUSE, SLES, etc)\n* ArchLinux\n* FreeBSD\n* Mac OS X\n* Mac OS X Server\n\nOpscode Cookbooks\n-----------------\n\nThe `chef-client::cron` recipe requires the `cron_d` LWRP from Opscode's cron cookbook, so that is a dependency, otherwise the cron recipe will fail to converge.\n\nOther cookbooks can be used with this cookbook but they are not explicitly required. The default settings in this cookbook do not require their use. The other cookbooks (on community.opsocde.com) are:\n\n* bluepill\n* daemontools\n* runit\n\nSee __USAGE__ below.\n\nAttributes\n==========\n\n* `node[\"chef_client\"][\"interval\"]` - Sets `Chef::Config[:interval]` via command-line option for number of seconds between chef-client daemon runs. Default 1800.\n* `node[\"chef_client\"][\"splay\"]` - Sets `Chef::Config[:splay]` via command-line option for a random amount of seconds to add to interval. Default 20.\n* `node[\"chef_client\"][\"log_dir\"]` - Sets directory used in `Chef::Config[:log_location]` via command-line option to a location where chef-client should log output. Default \"/var/log/chef\".\n* `node[\"chef_client\"][\"conf_dir\"]` - Sets directory used via command-line option to a location where chef-client search for the client config file . Default \"/etc/chef\".\n* `node[\"chef_client\"][\"bin\"]` - Sets the full path to the `chef-client` binary. Mainly used to set a specific path if multiple versions of chef-client exist on a system or the bin has been installed in a non-sane path. Default \"/usr/bin/chef-client\".\n* `node[\"chef_client\"][\"server_url\"]` - Sets `Chef::Config[:chef_server_url]` in the config file to the Chef Server URI. Default \"http://localhost:4000\". See __USAGE__.\n* `node[\"chef_client\"][\"validation_client_name\"]` - Sets `Chef::Config[:validation_client_name]` in the config file to the name of the validation client. Default \"chef-validator\". See __USAGE__.\n* `node[\"chef_client\"][\"init_style\"]` - Sets up the client service based on the style of init system to use. Default is based on platform and falls back to \"none\". See __USAGE__.\n* `node[\"chef_client\"][\"run_path\"]` - Directory location where chef-client should write the PID file. Default based on platform, falls back to \"/var/run\".\n* `node[\"chef_client\"][\"cache_path\"]` - Directory location for `Chef::Config[:file_cache_path]` where chef-client will cache various files. Default is based on platform, falls back to \"/var/chef/cache\".\n* `node[\"chef_client\"][\"backup_path\"]` - Directory location for `Chef::Config[:file_backup_path]` where chef-client will backup templates and cookbook files. Default is based on platform, falls back to \"/var/chef/backup\".\n* `node[\"chef_client\"][\"cron\"][\"minute\"]` - The hour that chef-client will run as a cron task, only applicable if the you set \"cron\" as the \"init_style\"\n* `node[\"chef_client\"][\"cron\"][\"hour\"]` - The hour that chef-client will run as a cron task, only applicable if the you set \"cron\" as the \"init_style\"\n* `node[\"chef_client\"][\"cron\"][\"environment_variables\"]` - Environment variables to pass to chef-client's execution (e.g. SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt chef-client)\n* `node[\"chef_client\"][\"cron\"][\"log_file\"]` - Location to capture the chef-client output.\n* `node[\"chef_client\"][\"cron\"][\"use_cron_d\"]` - If true, use the \"cron_d\" LWRP (https://github.com/opscode-cookbooks/cron). If false (default), use the cron resource built-in to Chef.\n* `node[\"chef_client\"][\"load_gems\"]` - Hash of gems to load into chef via the client.rb file\n* `node[\"chef_client\"][\"report_handlers\"]` - Array of Hashes that contain a class and arguments element appended in the client.rb file. ex: `{:class => \"MyHandler\", :arguments => [true]}\n* `node[\"chef_client\"][\"exception_handlers\"]` - Array of Hashes that contain a class and arguments element appended in the client.rb file. ex: `{:class => \"MyHandler\", :arguments => [true]}\n* `node[\"chef_client\"][\"checksum_cache_skip_expires\"]` - true or false value used in the `cache_options` section of the client.rb file.\n* `node[\"chef_client\"][\"checksum_cache_path\"]` - file system path used in the `cache_options` section of the client.rb file.\n* `node[\"chef_client\"][\"launchd_mode\"]` - (Only for Mac OS X) if set to \"daemon\", runs chef-client with `-d` and `-s` options; defaults to \"interval\"\n* `node[\"chef_client\"][\"daemon_options\"]` - An array of additional options to pass to the chef-client service, empty by default, and must be an array if specified.\n* `node[\"ohai\"][\"disabled_plugins\"]` - An array of ohai plugins to disable, empty by default, and must be an array if specified.\n\nRecipes\n=======\n\nThis section describes the recipes in the cookbook and how to use them in your environment.\n\nconfig\n------\n\nSets up the `/etc/chef/client.rb` config file from a template and reloads the configuration for the current chef-client run.\n\nservice\n-------\n\nUse this recipe on systems that should have a `chef-client` daemon running, such as when Knife bootstrap was used to install Chef on a new system.\n\nThis recipe sets up the `chef-client` service depending on the `init_style` attribute (see above). The following init styles are supported:\n\n* init - uses the init script included in the chef gem, supported on debian and redhat family distributions.\n* upstart - uses the upstart job included in the chef gem, supported on ubuntu.\n* arch - uses the init script included in this cookbook for ArchLinux, supported on arch.\n* runit - sets up the service under runit, supported on ubuntu, debian and gentoo.\n* bluepill - sets up the service under bluepill. As bluepill is a pure ruby process monitor, this should work on any platform.\n* daemontools - sets up the service under daemontools, supported on debian, ubuntu and arch\n* launchd - sets up the service under launchd, supported on Mac OS X & Mac OS X Server. (this requires Chef >= 0.10.10)\n* bsd - prints a message about how to update BSD systems to enable the chef-client service, supported on Free/OpenBSD.\n\ndefault\n-------\n\nIncludes the `chef-client::service` recipe by default.\n\ndelete_validation\n-----------------\n\nUse this recipe to delete the validation certificate (default `/etc/chef/validation.pem`) when using a `chef-client` after the client has been validated and authorized to connect to the server.\n\nBeware if using this on your Chef Server. First copy the validation.pem certificate file to another location, such as your knife configuration directory (`~/.chef`) or [Chef Repository](http://wiki.opscode.com/display/chef/Chef+Repository).\n\ncron\n----\n\nUse this recipe to run chef-client as a cron job rather than as a\nservice. The cron job runs after random delay that is between 0 and 90\nseconds to ensure that the chef-clients don't attempt to connect to\nthe chef-server at the exact same time. You should set\nnode[\"chef_client\"][\"init_style\"] = \"none\" when you use this mode but\nit is not required.\n\n\n\nUSAGE\n=====\n\nCreate a `base` role that will represent the base configuration for any system that includes managing aspects of the chef-client. Add recipes to the run list of the role, customize the attributes, and apply the role to nodes. For example, the following role (Ruby DSL) will set the init style to `init`, delete the validation certificate (as the client would already be authenticated) and set up the chef-client as a service using the init style.\n\n name \"base\"\n description \"Base role applied to all nodes\"\n override_attributes(\n \"chef_client\" => {\n \"init_style\" => \"init\"\n }\n )\n run_list(\n \"recipe[chef-client::delete_validation]\",\n \"recipe[chef-client::config]\",\n \"recipe[chef-client::service]\"\n )\n\nThe `chef-client::config` recipe is only required with init style `init` (default setting for the attribute on debian/redhat family platforms, because the init script doesn't include the `pid_file` option which is set in the config.\n\nThe default Chef Server will be `http://localhost:4000` which is the `Chef::Config[:chef_server_url]` default value. To use the config recipe with the Opscode Platform, for example, add the following to the `override_attributes`\n\n override_attributes(\n \"chef_client\" => {\n \"server_url\" => \"https://api.opscode.com/organizations/ORGNAME\",\n \"validation_client_name\" => \"ORGNAME-validator\"\n }\n )\n\nWhere ORGNAME is your Opscode Platform organization name. Be sure to add these attributes to the role if modifying per the section below.\n\nYou can also set all of the `Chef::Config` http proxy related settings. By default Chef will not use a proxy.\n\n override_attributes(\n \"chef_client\" => {\n \"http_proxy\" => \"http://proxy.vmware.com:3128\",\n \"https_proxy\" => \"http://proxy.vmware.com:3128\",\n \"http_proxy_user\" => \"my_username\",\n \"http_proxy_pass\" => \"Awe_some_Pass_Word!\",\n \"no_proxy\" => \"*.vmware.com,10.*\"\n }\n )\n\nAlternate Init Styles\n---------------------\n\nThe alternate init styles available are:\n\n* runit\n* bluepill\n* daemontools\n* none -- should be specified if you are running chef-client as cron job\n\nFor usage, see below.\n\n# Runit\n\nTo use runit, download the cookbook from the cookbook site.\n\n knife cookbook site vendor runit -d\n\nChange the `init_style` to runit in the base role and add the runit recipe to the role's run list:\n\n name \"base\"\n description \"Base role applied to all nodes\"\n override_attributes(\n \"chef_client\" => {\n \"init_style\" => \"runit\"\n }\n )\n run_list(\n \"recipe[chef-client::delete_validation]\",\n \"recipe[runit]\",\n \"recipe[chef-client]\"\n )\n\nThe `chef-client` recipe will create the chef-client service configured with runit. The runit run script will be located in `/etc/sv/chef-client/run`. The output log will be in the runit service directory, `/etc/sv/chef-client/log/main/current`.\n\n# Bluepill\n\nTo use bluepill, download the cookbook from the cookbook site.\n\n knife cookbook site vendor bluepill -d\n\nChange the `init_style` to runit in the base role and add the bluepill recipe to the role's run list:\n\n name \"base\"\n description \"Base role applied to all nodes\"\n override_attributes(\n \"chef_client\" => {\n \"init_style\" => \"bluepill\"\n }\n )\n run_list(\n \"recipe[chef-client::delete_validation]\",\n \"recipe[bluepill]\",\n \"recipe[chef-client]\"\n )\n\nThe `chef-client` recipe will create the chef-client service configured with bluepill. The bluepill \"pill\" will be located in `/etc/bluepill/chef-client.pill`. The output log will be to client.log file in the `node[\"chef_client\"][\"log_dir\"]` location, `/var/log/chef/client` by default.\n\n# Daemontools\n\nTo use daemontools, download the cookbook from the cookbook site.\n\n knife cookbook site vendor daemontools -d\n\nChange the `init_style` to runit in the base role and add the daemontools recipe to the role's run list:\n\n name \"base\"\n description \"Base role applied to all nodes\"\n override_attributes(\n \"chef_client\" => {\n \"init_style\" => \"daemontools\"\n }\n )\n run_list(\n \"recipe[chef-client::delete_validation]\",\n \"recipe[daemontools]\",\n \"recipe[chef-client]\"\n )\n\nThe `chef-client` recipe will create the chef-client service configured under daemontools. It uses the same sv run scripts as the runit recipe. The run script will be located in `/etc/sv/chef-client/run`. The output log will be in the daemontools service directory, `/etc/sv/chef-client/log/main/current`.\n\n# Launchd\n\nOn Mac OS X and Mac OS X Server, the default service implementation is \"launchd\". Launchd support for the service resource is only supported from Chef 0.10.10 onwards.\nAn error message will be logged if you try to use the launchd service for chef-client on a Chef version that does not contain this launchd support.\n\nSince launchd can run a service in interval mode, by default chef-client is not started in daemon mode like on Debian or Ubuntu. Keep this in mind when you look at your process list and check for a running chef process! If you wish to run chef-client in daemon mode, set attribute `chef_client.launchd_mode` to \"daemon\".\n\nTemplates\n=========\n\nchef-client.pill.erb\n--------------------\n\nBluepill configuration for the chef-client service.\n\nclient.rb.erb\n-------------\n\nConfiguration for the client, lands in directory specified by `node[\"chef_client\"][\"conf_dir\"]` (`/etc/chef/client.rb` by default).\n\n`sv-chef-client-*run.erb`\n-------------------------\n\nRunit and Daemontools run script for chef-client service and logs.\n\nLogs will be located in the `node[\"chef_client\"][\"log_dir\"]`.\n\ncom.opscode.chef-client.plist\n-----------------------------\n\nLaunchd configuration file for chef-client as a true Mac service. The template accepts the `node[\"chef_client\"][\"interval\"]` value.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\nCopyright:: 2010-2012, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\n",
5+ "maintainer": "Opscode, Inc.",
6+ "maintainer_email": "cookbooks@opscode.com",
7+ "license": "Apache 2.0",
8+ "platforms": {
9+ "ubuntu": ">= 0.0.0",
10+ "debian": ">= 0.0.0",
11+ "redhat": ">= 0.0.0",
12+ "centos": ">= 0.0.0",
13+ "fedora": ">= 0.0.0",
14+ "oracle": ">= 0.0.0",
15+ "suse": ">= 0.0.0",
16+ "freebsd": ">= 0.0.0",
17+ "openbsd": ">= 0.0.0",
18+ "mac_os_x": ">= 0.0.0",
19+ "mac_os_x_server": ">= 0.0.0",
20+ "windows": ">= 0.0.0"
21+ },
22+ "dependencies": {
23+ "cron": ">= 0.0.0"
24+ },
25+ "recommendations": {
26+ },
27+ "suggestions": {
28+ "bluepill": ">= 0.0.0",
29+ "daemontools": ">= 0.0.0",
30+ "runit": "<= 0.16.2"
31+ },
32+ "conflicting": {
33+ },
34+ "providing": {
35+ },
36+ "replacing": {
37+ },
38+ "attributes": {
39+ },
40+ "groupings": {
41+ },
42+ "recipes": {
43+ "chef-client": "Includes the service recipe by default.",
44+ "chef-client::config": "Configures the client.rb from a template.",
45+ "chef-client::service": "Sets up a client daemon to run periodically",
46+ "chef-client::delete_validation": "Deletes validation.pem after client registers",
47+ "chef-client::cron": "Runs chef-client as a cron job rather than as a service"
48+ },
49+ "version": "2.2.4"
50+}
\ No newline at end of file
--- /dev/null
+++ b/cookbooks/chef-client/metadata.rb
@@ -0,0 +1,21 @@
1+name "chef-client"
2+maintainer "Opscode, Inc."
3+maintainer_email "cookbooks@opscode.com"
4+license "Apache 2.0"
5+description "Manages aspects of only chef-client"
6+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7+version "2.2.4"
8+recipe "chef-client", "Includes the service recipe by default."
9+recipe "chef-client::config", "Configures the client.rb from a template."
10+recipe "chef-client::service", "Sets up a client daemon to run periodically"
11+recipe "chef-client::delete_validation", "Deletes validation.pem after client registers"
12+recipe "chef-client::cron", "Runs chef-client as a cron job rather than as a service"
13+
14+%w{ ubuntu debian redhat centos fedora oracle suse freebsd openbsd mac_os_x mac_os_x_server windows }.each do |os|
15+ supports os
16+end
17+
18+suggests "bluepill"
19+suggests "daemontools"
20+suggests "runit", "<= 0.16.2"
21+depends "cron"
--- /dev/null
+++ b/cookbooks/chef-client/recipes/config.rb
@@ -0,0 +1,91 @@
1+#
2+# Author:: Joshua Timberman (<joshua@opscode.com>)
3+# Author:: Joshua Sierles (<joshua@37signals.com>)
4+# Author:: Seth Chisamore (<schisamo@opscode.com>)
5+# Cookbook Name:: chef-client
6+# Recipe:: config
7+#
8+# Copyright 2008-2011, Opscode, Inc
9+# Copyright 2009, 37signals
10+#
11+# Licensed under the Apache License, Version 2.0 (the "License");
12+# you may not use this file except in compliance with the License.
13+# You may obtain a copy of the License at
14+#
15+# http://www.apache.org/licenses/LICENSE-2.0
16+#
17+# Unless required by applicable law or agreed to in writing, software
18+# distributed under the License is distributed on an "AS IS" BASIS,
19+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+# See the License for the specific language governing permissions and
21+# limitations under the License.
22+
23+class ::Chef::Recipe
24+ include ::Opscode::ChefClient::Helpers
25+end
26+
27+root_user = value_for_platform(
28+ ["windows"] => { "default" => "Administrator" },
29+ "default" => "root"
30+)
31+
32+root_group = value_for_platform(
33+ ["openbsd", "freebsd", "mac_os_x", "mac_os_x_server"] => { "default" => "wheel" },
34+ ["windows"] => { "default" => "Administrators" },
35+ "default" => "root"
36+)
37+
38+chef_node_name = Chef::Config[:node_name] == node["fqdn"] ? false : Chef::Config[:node_name]
39+log_path = case node["chef_client"]["log_file"]
40+ when String
41+ File.join(node["chef_client"]["log_dir"], node["chef_client"]["log_file"])
42+ else
43+ 'STDOUT'
44+ end
45+
46+# libraries/helpers.rb method to DRY directory creation resources
47+create_directories
48+
49+if log_path != "STDOUT"
50+ file log_path do
51+ mode 00640
52+ end
53+end
54+
55+chef_requires = []
56+node["chef_client"]["load_gems"].each do |gem_name, gem_info_hash|
57+ gem_info_hash ||= {}
58+ chef_gem gem_name do
59+ action gem_info_hash[:action] || :install
60+ version gem_info_hash[:version] if gem_info_hash[:version]
61+ end
62+ chef_requires.push(gem_info_hash[:require_name] || gem_name)
63+end
64+
65+ohai_disabled_plugins = node['ohai']['disabled_plugins'].inspect
66+
67+template "#{node["chef_client"]["conf_dir"]}/client.rb" do
68+ source "client.rb.erb"
69+ owner root_user
70+ group root_group
71+ mode 00644
72+ variables(
73+ :chef_node_name => chef_node_name,
74+ :chef_log_location => log_path == "STDOUT" ? "STDOUT" : "'#{log_path}'",
75+ :chef_log_level => node["chef_client"]["log_level"] || :info,
76+ :chef_environment => node["chef_client"]["environment"],
77+ :chef_requires => chef_requires,
78+ :chef_verbose_logging => node["chef_client"]["verbose_logging"],
79+ :chef_report_handlers => node["chef_client"]["report_handlers"],
80+ :chef_exception_handlers => node["chef_client"]["exception_handlers"],
81+ :ohai_disabled_plugins => ohai_disabled_plugins
82+ )
83+ notifies :create, "ruby_block[reload_client_config]"
84+end
85+
86+ruby_block "reload_client_config" do
87+ block do
88+ Chef::Config.from_file("#{node["chef_client"]["conf_dir"]}/client.rb")
89+ end
90+ action :nothing
91+end
--- /dev/null
+++ b/cookbooks/chef-client/recipes/cron.rb
@@ -0,0 +1,116 @@
1+#
2+# Author:: Joshua Timberman (<joshua@opscode.com>)
3+# Author:: Seth Chisamore (<schisamo@opscode.com>)
4+# Author:: Bryan Berry (<bryan.berry@gmail.com>)
5+# Cookbook Name:: chef-client
6+# Recipe:: cron
7+#
8+# Copyright 2009-2011, Opscode, Inc.
9+#
10+# Licensed under the Apache License, Version 2.0 (the "License");
11+# you may not use this file except in compliance with the License.
12+# You may obtain a copy of the License at
13+#
14+# http://www.apache.org/licenses/LICENSE-2.0
15+#
16+# Unless required by applicable law or agreed to in writing, software
17+# distributed under the License is distributed on an "AS IS" BASIS,
18+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+# See the License for the specific language governing permissions and
20+# limitations under the License.
21+#
22+
23+require "digest/md5"
24+
25+class ::Chef::Recipe
26+ include ::Opscode::ChefClient::Helpers
27+end
28+
29+# COOK-635 account for alternate gem paths
30+# try to use the bin provided by the node attribute
31+if ::File.executable?(node["chef_client"]["bin"])
32+ client_bin = node["chef_client"]["bin"]
33+ # search for the bin in some sane paths
34+elsif Chef::Client.const_defined?('SANE_PATHS') && (chef_in_sane_path=Chef::Client::SANE_PATHS.map{|p| p="#{p}/chef-client";p if ::File.executable?(p)}.compact.first) && chef_in_sane_path
35+ client_bin = chef_in_sane_path
36+ # last ditch search for a bin in PATH
37+elsif (chef_in_path=%x{which chef-client}.chomp) && ::File.executable?(chef_in_path)
38+ client_bin = chef_in_path
39+else
40+ raise "Could not locate the chef-client bin in any known path. Please set the proper path by overriding node['chef_client']['bin'] in a role."
41+end
42+
43+# libraries/helpers.rb method to DRY directory creation resources
44+create_directories
45+
46+dist_dir, conf_dir = value_for_platform_family(
47+ ["debian"] => ["debian", "default"],
48+ ["rhel"] => ["redhat", "sysconfig"]
49+ )
50+
51+# let's create the service file so the :disable action doesn't fail
52+case node['platform_family']
53+when "arch","debian","rhel","fedora","suse","openbsd","freebsd"
54+ template "/etc/init.d/chef-client" do
55+ source "#{dist_dir}/init.d/chef-client.erb"
56+ mode 0755
57+ variables(
58+ :client_bin => client_bin
59+ )
60+ end
61+
62+ template "/etc/#{conf_dir}/chef-client" do
63+ source "#{dist_dir}/#{conf_dir}/chef-client.erb"
64+ mode 0644
65+ end
66+
67+ service "chef-client" do
68+ supports :status => true, :restart => true
69+ action [:disable, :stop]
70+ end
71+
72+when "openindiana","opensolaris","nexentacore","solaris2","smartos"
73+ service "chef-client" do
74+ supports :status => true, :restart => true
75+ action [:disable, :stop]
76+ provider Chef::Provider::Service::Solaris
77+ ignore_failure true
78+ end
79+end
80+
81+
82+# Generate a uniformly distributed unique number to sleep.
83+checksum = Digest::MD5.hexdigest(node['fqdn'] || 'unknown-hostname')
84+sleep_time = checksum.to_s.hex % node['chef_client']['splay'].to_i
85+env = node['chef_client']['cron']['environment_variables']
86+log_file = node["chef_client"]["cron"]["log_file"]
87+
88+# If "use_cron_d" is set to true, delete the cron entry that uses the cron
89+# resource built in to Chef and instead use the cron_d LWRP.
90+if node['chef_client']['cron']['use_cron_d']
91+ cron "chef-client" do
92+ action :delete
93+ end
94+
95+ cron_d "chef-client" do
96+ minute node['chef_client']['cron']['minute']
97+ hour node['chef_client']['cron']['hour']
98+ path node['chef_client']['cron']['path'] if node['chef_client']['cron']['path']
99+ user "root"
100+ shell "/bin/bash"
101+ command "/bin/sleep #{sleep_time}; #{env} #{client_bin} &> #{log_file}"
102+ end
103+else
104+ cron_d "chef-client" do
105+ action :delete
106+ end
107+
108+ cron "chef-client" do
109+ minute node['chef_client']['cron']['minute']
110+ hour node['chef_client']['cron']['hour']
111+ path node['chef_client']['cron']['path'] if node['chef_client']['cron']['path']
112+ user "root"
113+ shell "/bin/bash"
114+ command "/bin/sleep #{sleep_time}; #{env} #{client_bin} &> #{log_file}"
115+ end
116+end
--- /dev/null
+++ b/cookbooks/chef-client/recipes/default.rb
@@ -0,0 +1,20 @@
1+#
2+# Cookbook Name:: chef-client
3+# Recipe:: default
4+#
5+# Copyright 2010, Opscode, Inc.
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+include_recipe "chef-client::service"
--- /dev/null
+++ b/cookbooks/chef-client/recipes/delete_validation.rb
@@ -0,0 +1,30 @@
1+#
2+# Author:: Joshua Timberman <joshua@opscode.com>
3+# Cookbook Name:: chef
4+# Recipe:: delete_validation
5+#
6+# Copyright 2010, Opscode, Inc
7+#
8+# Licensed under the Apache License, Version 2.0 (the "License");
9+# you may not use this file except in compliance with the License.
10+# You may obtain a copy of the License at
11+#
12+# http://www.apache.org/licenses/LICENSE-2.0
13+#
14+# Unless required by applicable law or agreed to in writing, software
15+# distributed under the License is distributed on an "AS IS" BASIS,
16+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+# See the License for the specific language governing permissions and
18+# limitations under the License.
19+
20+class ::Chef::Recipe
21+ include ::Opscode::ChefClient::Helpers
22+end
23+
24+unless chef_server?
25+ file Chef::Config[:validation_key] do
26+ action :delete
27+ backup false
28+ only_if { ::File.exists?(Chef::Config[:client_key]) }
29+ end
30+end
--- /dev/null
+++ b/cookbooks/chef-client/recipes/service.rb
@@ -0,0 +1,297 @@
1+#
2+# Author:: Joshua Timberman (<joshua@opscode.com>)
3+# Author:: Seth Chisamore (<schisamo@opscode.com>)
4+# Cookbook Name:: chef-client
5+# Recipe:: service
6+#
7+# Copyright 2009-2011, Opscode, Inc.
8+#
9+# Licensed under the Apache License, Version 2.0 (the "License");
10+# you may not use this file except in compliance with the License.
11+# You may obtain a copy of the License at
12+#
13+# http://www.apache.org/licenses/LICENSE-2.0
14+#
15+# Unless required by applicable law or agreed to in writing, software
16+# distributed under the License is distributed on an "AS IS" BASIS,
17+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+# See the License for the specific language governing permissions and
19+# limitations under the License.
20+#
21+
22+class ::Chef::Recipe
23+ include ::Opscode::ChefClient::Helpers
24+end
25+
26+require 'chef/version_constraint'
27+require 'chef/exceptions'
28+
29+root_group = value_for_platform_family(
30+ ["openbsd", "freebsd", "mac_os_x"] => "wheel",
31+ "default" => "root"
32+)
33+
34+if node["platform"] == "windows"
35+ existence_check = :exists?
36+# Where will also return files that have extensions matching PATHEXT (e.g.
37+# *.bat). We don't want the batch file wrapper, but the actual script.
38+ which = 'set PATHEXT=.exe & where'
39+ Chef::Log.debug "Using exists? and 'where', since we're on Windows"
40+else
41+ existence_check = :executable?
42+ which = 'which'
43+ Chef::Log.debug "Using executable? and 'which' since we're on Linux"
44+end
45+
46+# COOK-635 account for alternate gem paths
47+# try to use the bin provided by the node attribute
48+if ::File.send(existence_check, node["chef_client"]["bin"])
49+ client_bin = node["chef_client"]["bin"]
50+ Chef::Log.debug "Using chef-client bin from node attributes: #{client_bin}"
51+# search for the bin in some sane paths
52+elsif Chef::Client.const_defined?('SANE_PATHS') && (chef_in_sane_path=Chef::Client::SANE_PATHS.map{|p| p="#{p}/chef-client";p if ::File.send(existence_check, p)}.compact.first) && chef_in_sane_path
53+ client_bin = chef_in_sane_path
54+ Chef::Log.debug "Using chef-client bin from sane path: #{client_bin}"
55+# last ditch search for a bin in PATH
56+elsif (chef_in_path=%x{#{which} chef-client}.chomp) && ::File.send(existence_check, chef_in_path)
57+ client_bin = chef_in_path
58+ Chef::Log.debug "Using chef-client bin from system path: #{client_bin}"
59+else
60+ raise "Could not locate the chef-client bin in any known path. Please set the proper path by overriding node['chef_client']['bin'] in a role."
61+end
62+
63+node.set["chef_client"]["bin"] = client_bin
64+
65+# libraries/helpers.rb method to DRY directory creation resources
66+create_directories
67+
68+case node["chef_client"]["init_style"]
69+when "init"
70+
71+ #argh?
72+ dist_dir, conf_dir = value_for_platform_family(
73+ ["debian"] => ["debian", "default"],
74+ ["fedora"] => ["redhat", "sysconfig"],
75+ ["rhel"] => ["redhat", "sysconfig"],
76+ ["suse"] => ["suse", "sysconfig"]
77+ )
78+
79+ template "/etc/init.d/chef-client" do
80+ source "#{dist_dir}/init.d/chef-client.erb"
81+ mode 0755
82+ variables(
83+ :client_bin => client_bin
84+ )
85+ notifies :restart, "service[chef-client]", :delayed
86+ end
87+
88+ template "/etc/#{conf_dir}/chef-client" do
89+ source "#{dist_dir}/#{conf_dir}/chef-client.erb"
90+ mode 0644
91+ notifies :restart, "service[chef-client]", :delayed
92+ end
93+
94+ service "chef-client" do
95+ supports :status => true, :restart => true
96+ action [:enable, :start]
97+ end
98+
99+when "smf"
100+ directory node['chef_client']['method_dir'] do
101+ action :create
102+ owner "root"
103+ group "bin"
104+ mode "0755"
105+ recursive true
106+ end
107+
108+ local_path = ::File.join(Chef::Config[:file_cache_path], "/")
109+ template "#{node['chef_client']['method_dir']}/chef-client" do
110+ source "solaris/chef-client.erb"
111+ owner "root"
112+ group "root"
113+ mode "0755"
114+ notifies :restart, "service[chef-client]"
115+ end
116+
117+ template(local_path + "chef-client.xml") do
118+ source "solaris/manifest.xml.erb"
119+ owner "root"
120+ group "root"
121+ mode "0644"
122+ notifies :run, "execute[load chef-client manifest]", :immediately
123+ end
124+
125+ execute "load chef-client manifest" do
126+ action :nothing
127+ command "svccfg import #{local_path}chef-client.xml"
128+ notifies :restart, "service[chef-client]"
129+ end
130+
131+ service "chef-client" do
132+ action [:enable, :start]
133+ provider Chef::Provider::Service::Solaris
134+ end
135+
136+when "upstart"
137+
138+ upstart_job_dir = "/etc/init"
139+ upstart_job_suffix = ".conf"
140+
141+ case node["platform"]
142+ when "ubuntu"
143+ if (8.04..9.04).include?(node["platform_version"].to_f)
144+ upstart_job_dir = "/etc/event.d"
145+ upstart_job_suffix = ""
146+ end
147+ end
148+
149+ template "#{upstart_job_dir}/chef-client#{upstart_job_suffix}" do
150+ source "debian/init/chef-client.conf.erb"
151+ mode 0644
152+ variables(
153+ :client_bin => client_bin
154+ )
155+ notifies :restart, "service[chef-client]", :delayed
156+ end
157+
158+ service "chef-client" do
159+ provider Chef::Provider::Service::Upstart
160+ action [:enable,:start]
161+ end
162+
163+when "arch"
164+
165+ template "/etc/rc.d/chef-client" do
166+ source "rc.d/chef-client.erb"
167+ mode 0755
168+ variables(
169+ :client_bin => client_bin
170+ )
171+ notifies :restart, "service[chef-client]", :delayed
172+ end
173+
174+ template "/etc/conf.d/chef-client.conf" do
175+ source "conf.d/chef-client.conf.erb"
176+ mode 0644
177+ notifies :restart, "service[chef-client]", :delayed
178+ end
179+
180+ service "chef-client" do
181+ action [:enable, :start]
182+ end
183+
184+when "runit"
185+
186+ include_recipe "runit"
187+ runit_service "chef-client"
188+
189+when "bluepill"
190+
191+ directory node["chef_client"]["run_path"] do
192+ recursive true
193+ owner "root"
194+ group root_group
195+ mode 0755
196+ end
197+
198+ include_recipe "bluepill"
199+
200+ template "#{node["bluepill"]["conf_dir"]}/chef-client.pill" do
201+ source "chef-client.pill.erb"
202+ mode 0644
203+ notifies :restart, "bluepill_service[chef-client]", :delayed
204+ end
205+
206+ bluepill_service "chef-client" do
207+ action [:enable,:load,:start]
208+ end
209+
210+when "daemontools"
211+
212+ include_recipe "daemontools"
213+
214+ directory "/etc/sv/chef-client" do
215+ recursive true
216+ owner "root"
217+ group root_group
218+ mode 0755
219+ end
220+
221+ daemontools_service "chef-client" do
222+ directory "/etc/sv/chef-client"
223+ template "chef-client"
224+ action [:enable,:start]
225+ log true
226+ end
227+
228+when "winsw"
229+
230+ directory node["chef_client"]["winsw_dir"] do
231+ action :create
232+ end
233+
234+ template "#{node["chef_client"]["winsw_dir"]}/chef-client.xml" do
235+ source "chef-client.xml.erb"
236+ notifies :run, "execute[restart chef-client using winsw wrapper]", :delayed
237+ end
238+
239+ winsw_path = File.join(node["chef_client"]["winsw_dir"], node["chef_client"]["winsw_exe"])
240+ remote_file winsw_path do
241+ source node["chef_client"]["winsw_url"]
242+ not_if { File.exists?(winsw_path) }
243+ end
244+
245+ # Chef client service fails to start if the logs folder is not already created.
246+ directory node["chef_client"]["log_dir"] do
247+ action :create
248+ end
249+
250+ # Work-around for CHEF-2541
251+ # Should be replaced by a service :restart action
252+ # in Chef 0.10.6
253+ execute "restart chef-client using winsw wrapper" do
254+ command "#{winsw_path} restart"
255+ not_if { WMI::Win32_Service.find(:first, :conditions => {:name => "chef-client"}).nil? }
256+ action :nothing
257+ end
258+
259+ execute "Install chef-client service using winsw" do
260+ command "#{winsw_path} install"
261+ only_if { WMI::Win32_Service.find(:first, :conditions => {:name => "chef-client"}).nil? }
262+ end
263+
264+ service "chef-client" do
265+ action :start
266+ end
267+
268+when "launchd"
269+
270+ version_checker = Chef::VersionConstraint.new(">= 0.10.10")
271+ mac_service_supported = version_checker.include?(node['chef_packages']['chef']['version'])
272+
273+ if mac_service_supported
274+ template "/Library/LaunchDaemons/com.opscode.chef-client.plist" do
275+ source "com.opscode.chef-client.plist.erb"
276+ mode 0644
277+ variables(
278+ :launchd_mode => node["chef_client"]["launchd_mode"],
279+ :client_bin => client_bin
280+ )
281+ end
282+
283+ service "chef-client" do
284+ service_name "com.opscode.chef-client"
285+ provider Chef::Provider::Service::Macosx
286+ action :start
287+ end
288+ else
289+ log("Mac OS X Service provider is only supported in Chef >= 0.10.10") { level :warn }
290+ end
291+
292+when "bsd"
293+ log "You specified service style 'bsd'. You will need to set up your rc.local file."
294+ log "Hint: chef-client -i #{node["chef_client"]["client_interval"]} -s #{node["chef_client"]["client_splay"]}"
295+else
296+ log "Could not determine service init style, manual intervention required to start up the chef-client service."
297+end
--- /dev/null
+++ b/cookbooks/chef-client/recipes/task.rb
@@ -0,0 +1,66 @@
1+#
2+# Author:: Paul Mooring (<paul@opscode.com>)
3+# Cookbook Name:: chef
4+# Recipe:: task
5+#
6+# Copyright 2011, Opscode, Inc.
7+#
8+# Licensed under the Apache License, Version 2.0 (the "License");
9+# you may not use this file except in compliance with the License.
10+# You may obtain a copy of the License at
11+#
12+# http://www.apache.org/licenses/LICENSE-2.0
13+#
14+# Unless required by applicable law or agreed to in writing, software
15+# distributed under the License is distributed on an "AS IS" BASIS,
16+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+# See the License for the specific language governing permissions and
18+# limitations under the License.
19+#
20+
21+class ::Chef::Recipe
22+ include ::Opscode::ChefClient::Helpers
23+end
24+
25+unless node["platform"] == "windows"
26+ return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe"
27+end
28+
29+# COOK-635 account for alternate gem paths
30+# try to use the bin provided by the node attribute
31+if ::File.exists?(node["chef_client"]["bin"])
32+ client_bin = node["chef_client"]["bin"]
33+ Chef::Log.debug "Using chef-client bin from node attributes: #{client_bin}"
34+# search for the bin in some sane paths
35+elsif Chef::Client.const_defined?('SANE_PATHS')
36+ chef_in_sane_path = Chef::Client::SANE_PATHS.map do |p|
37+ p="#{p}/chef-client"
38+ p if ::File.exists?(p)
39+ end.compact.first
40+
41+ unless chef_in_sane_path.nil?
42+ client_bin = chef_in_sane_path
43+ Chef::Log.debug "Using chef-client bin from sane path: #{client_bin}"
44+ end
45+# last ditch search for a bin in PATH
46+elsif (chef_in_path=%x{set PATHEXT=.exe & where chef-client}.chomp) && ::File.exists?(chef_in_path)
47+ client_bin = chef_in_path
48+ Chef::Log.debug "Using chef-client bin from system path: #{client_bin}"
49+else
50+ raise "Could not locate the chef-client bin in any known path. Please set the proper path by overriding node['chef_client']['bin'] in a role."
51+end
52+
53+node.set["chef_client"]["bin"] = client_bin
54+
55+# libraries/helpers.rb method to DRY directory creation resources
56+create_directories
57+
58+windows_task "chef-client" do
59+ run_level :highest
60+ command "#{node['chef_client']['ruby_bin']} #{node['chef_client']['bin']} \
61+ -L #{File.join(node['chef_client']['log_dir'], 'client.log')} \
62+ -c #{File.join(node['chef_client']['conf_dir'], 'client.rb')} -s #{node['chef_client']['splay']}"
63+ frequency :minute
64+ frequency_modifier(node['chef_client']['interval'].to_i / 60)
65+end
66+
--- /dev/null
+++ b/cookbooks/chef-client/templates/arch/conf.d/chef-client.conf.erb
@@ -0,0 +1,5 @@
1+LOGFILE=<%= node["chef_client"]["log_dir"] %>/client.log
2+CONFIG=<%= node["chef_client"]["conf_dir"] %>/client.rb
3+INTERVAL=<%= node["chef_client"]["interval"] %>
4+SPLAY=<%= node["chef_client"]["splay"] %>
5+CHEF_CLIENT_ARGS="-L $LOGFILE -d -c $CONFIG -i $INTERVAL -s $SPLAY <%= node["chef_client"]["daemon_options"].join(' ') %>"
--- /dev/null
+++ b/cookbooks/chef-client/templates/arch/rc.d/chef-client.erb
@@ -0,0 +1,76 @@
1+#!/bin/bash
2+#
3+# Copyright (c) 2009-2010 Opscode, Inc <legal@opscode.com>
4+#
5+# Licensed under the Apache License, Version 2.0 (the "License");
6+# you may not use this file except in compliance with the License.
7+# You may obtain a copy of the License at
8+#
9+# http://www.apache.org/licenses/LICENSE-2.0
10+#
11+# Unless required by applicable law or agreed to in writing, software
12+# distributed under the License is distributed on an "AS IS" BASIS,
13+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+# See the License for the specific language governing permissions and
15+# limitations under the License.
16+#
17+
18+daemon_bin="<%= @client_bin %>"
19+daemon_name=$(basename $daemon_bin)
20+PIDF="<%= node["chef_client"]["run_path"] %>/$daemon_name.pid"
21+
22+. /etc/rc.conf
23+. /etc/rc.d/functions
24+. /etc/conf.d/$daemon_name.conf
25+
26+get_pid() {
27+ pidof -o %PPID $daemon_name
28+}
29+
30+case "$1" in
31+ start)
32+ stat_busy "Starting $daemon_name"
33+ PID=$(get_pid)
34+ if [ -z "$PID" ]; then
35+ [ -f $PIDF ] && rm -f $PIDF
36+ $daemon_bin --pid $PIDF $CHEF_CLIENT_ARGS
37+ if [ $? -gt 0 ]; then
38+ stat_fail
39+ exit 1
40+ else
41+ echo $(get_pid) > $PIDF
42+ add_daemon $daemon_name
43+ stat_done
44+ fi
45+ else
46+ stat_fail
47+ exit 1
48+ fi
49+ ;;
50+
51+ stop)
52+ stat_busy "Stopping $daemon_name daemon"
53+ PID=$(get_pid)
54+ [ ! -z "$PID" ] && kill $PID &> /dev/null
55+ if [ $? -gt 0 ]; then
56+ stat_fail
57+ exit 1
58+ else
59+ rm -f $PIDF &>/dev/null
60+ rm_daemon $daemon_name
61+ stat_done
62+ fi
63+ ;;
64+
65+ restart)
66+ $0 stop
67+ sleep 3
68+ $0 start
69+ ;;
70+ status)
71+ stat_busy "Checking $daemon_name status";
72+ ck_status $daemon_name
73+ ;;
74+ *)
75+ echo "usage: $) {start|stop|restart|status}"
76+esac
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/chef-client.pill.erb
@@ -0,0 +1,14 @@
1+Bluepill.application("chef-client") do |app|
2+
3+ app.process("chef-client") do |process|
4+ process.pid_file = "<%= node["chef_client"]["run_path"] %>/chef-client.pid"
5+ process.working_dir = "/"
6+ process.start_command = "env PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin<% if node["languages"]["ruby"]["gems_dir"] %>:<%= node["languages"]["ruby"]["gems_dir"] %>/bin<% end -%> chef-client -i <%= node["chef_client"]["interval"] %> -s <%= node["chef_client"]["splay"] %> -P <%= node["chef_client"]["run_path"] %>/chef-client.pid <%= node["chef_client"]["daemon_options"].join(' ') %>"
7+ process.stdout = process.stderr = "<%= node["chef_client"]["log_dir"] %>/client.log"
8+ process.start_grace_time = 5.seconds
9+ process.stop_grace_time = 5.seconds
10+ process.restart_grace_time = 30.seconds
11+ process.daemonize = true
12+ end
13+
14+end
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/client.rb.erb
@@ -0,0 +1,68 @@
1+<% unless @chef_requires.empty? %>
2+<%= @chef_requires.inspect %>.each do |lib|
3+ begin
4+ require lib
5+ rescue LoadError
6+ Chef::Log.warn "Failed to load #{lib}. This should be resolved after a chef run."
7+ end
8+end
9+<% end %>
10+
11+log_level :<%= @chef_log_level.to_s %>
12+log_location <%= @chef_log_location %>
13+verbose_logging <%= @chef_verbose_logging %>
14+
15+<% if node.attribute?("chef_client") && node["chef_client"]["server_url"] -%>
16+chef_server_url "<%= node["chef_client"]["server_url"] %>"
17+<% else -%>
18+chef_server_url "<%= Chef::Config[:chef_server_url] %>"
19+<% end -%>
20+validation_client_name "<%= node["chef_client"]["validation_client_name"] %>"
21+<% if @chef_node_name -%>
22+node_name "<%= @chef_node_name %>"
23+<% else -%>
24+# Using default node name
25+<% end -%>
26+
27+file_backup_path "<%= node["chef_client"]["backup_path"] %>"
28+file_cache_path "<%= node["chef_client"]["cache_path"] %>"
29+cache_options({ :path => "<%= node["chef_client"]["checksum_cache_path"] %>", :skip_expires => <%= node["chef_client"]["checksum_cache_skip_expires"] %> })
30+<% unless %w{ runit bluepill daemontools }.include?(node["chef_client"]["init_style"]) -%>
31+
32+pid_file "<%= node["chef_client"]["run_path"] %>/client.pid"
33+<% end -%>
34+<%= "http_proxy \"#{node["chef_client"]["http_proxy"]}\"\n" unless node["chef_client"]["http_proxy"].nil? -%>
35+<%= "https_proxy \"#{node["chef_client"]["https_proxy"]}\"\n" unless node["chef_client"]["https_proxy"].nil? -%>
36+<%= "http_proxy_user \"#{node["chef_client"]["http_proxy_user"]}\"\n" unless node["chef_client"]["http_proxy_user"].nil? -%>
37+<%= "http_proxy_pass \"#{node["chef_client"]["http_proxy_pass"]}\"\n" unless node["chef_client"]["http_proxy_pass"].nil? -%>
38+<%= "no_proxy \"#{node["chef_client"]["no_proxy"]}\"\n" unless node["chef_client"]["no_proxy"].nil? -%>
39+<% unless node["chef_client"]["http_proxy"].nil? -%>
40+
41+# set the proxy env variable so rubygems works correctly
42+ENV['http_proxy'] = "<%= node["chef_client"]["http_proxy"] %>"
43+ENV['HTTP_PROXY'] = "<%= node["chef_client"]["http_proxy"] %>"
44+<% end -%>
45+<% if node.attribute?("ohai") && node["ohai"].attribute?("plugin_path") -%>
46+
47+Ohai::Config[:plugin_path] << "<%= node["ohai"]["plugin_path"] %>"
48+<% end -%>
49+
50+<% unless @ohai_disabled_plugins.empty? %>
51+Ohai::Config[:disabled_plugins] = <%= @ohai_disabled_plugins %>
52+<% end -%>
53+
54+<% if @chef_environment %>
55+environment "<%= @chef_environment %>"
56+<% end %>
57+
58+<% unless @chef_report_handlers.empty? %>
59+ <% @chef_report_handlers.each do |handler| %>
60+ report_handlers << <%= handler["class"] %>.new(<%= handler["arguments"].join(',') %>)
61+ <% end %>
62+<% end %>
63+
64+<% unless @chef_exception_handlers.empty? %>
65+ <% @chef_exception_handlers.each do |handler| %>
66+ exception_handlers << <%= handler["class"] %>.new(<%= handler["arguments"].join(',') %>)
67+ <% end %>
68+<% end %>
\ No newline at end of file
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/com.opscode.chef-client.plist.erb
@@ -0,0 +1,32 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+<plist version="1.0">
4+
5+<dict>
6+ <key>Label</key>
7+ <string>com.opscode.chef-client</string>
8+<%- if @launchd_mode == "interval" %>
9+ <key>Program</key>
10+ <string><%= @client_bin %></string>
11+ <key>StartInterval</key>
12+ <integer><%= node["chef_client"]["interval"] %></integer>
13+ <key>RunAtLoad</key>
14+ <true/>
15+<%- else %>
16+ <key>ProgramArguments</key>
17+ <array>
18+ <string><%= @client_bin %></string>
19+ <string>-i <%= node["chef_client"]["interval"] %></string>
20+ <string>-s <%= node["chef_client"]["splay"] %></string>
21+ <% node["chef_client"]["daemon_options"].each do |option| -%>
22+ <string><%= option %></string>
23+ <% end -%>
24+ </array>
25+<%- end %>
26+ <key>UserName</key>
27+ <string>root</string>
28+ <key>StandardOutPath</key>
29+ <string><%= node["chef_client"]["log_dir"] %>/client.log</string>
30+</dict>
31+
32+</plist>
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/debian/default/chef-client.erb
@@ -0,0 +1,4 @@
1+LOGFILE=<%= node["chef_client"]["log_dir"] %>/client.log
2+CONFIG=<%= node["chef_client"]["conf_dir"] %>/client.rb
3+INTERVAL=<%= node["chef_client"]["interval"] %>
4+SPLAY=<%= node["chef_client"]["splay"] %>
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/debian/init.d/chef-client.erb
@@ -0,0 +1,210 @@
1+#! /bin/sh
2+### BEGIN INIT INFO
3+# Provides: chef-client
4+# Required-Start: $remote_fs $network
5+# Required-Stop: $remote_fs $network
6+# Default-Start: 2 3 4 5
7+# Default-Stop: 0 1 6
8+# Short-Description: Start a chef-client.
9+### END INIT INFO
10+#
11+# Copyright (c) 2009-2010 Opscode, Inc, <legal@opscode.com>
12+#
13+# chef-client Startup script for chef-client.
14+# chkconfig: - 99 02
15+# description: starts up chef-client in daemon mode.
16+
17+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18+DAEMON=<%= @client_bin %>
19+NAME=chef-client
20+DESC=chef-client
21+PIDFILE=<%= node["chef_client"]["run_path"] %>/client.pid
22+
23+test -x $DAEMON || exit 1
24+
25+. /lib/lsb/init-functions
26+
27+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
28+
29+if [ ! -d /var/run/chef ]; then
30+ mkdir /var/run/chef
31+fi
32+
33+DAEMON_OPTS="-d -P $PIDFILE -c $CONFIG -i $INTERVAL -s $SPLAY <%= node["chef_client"]["daemon_options"].join(' ') %>"
34+
35+if [ ! -z $LOGFILE ]; then
36+ DAEMON_OPTS="${DAEMON_OPTS} -L $LOGFILE"
37+fi
38+
39+running_pid() {
40+ pid=$1
41+ name=$2
42+ [ -z "$pid" ] && return 1
43+ [ ! -d /proc/$pid ] && return 1
44+ cmd=`cat /proc/$pid/cmdline | tr '\000' '\n' | awk 'NR==2'`
45+ [ "$cmd" != "$name" ] && return 1
46+ return 0
47+}
48+
49+running() {
50+ [ ! -f "$PIDFILE" ] && return 1
51+ pid=`cat $PIDFILE`
52+ running_pid $pid $DAEMON || return 1
53+ return 0
54+}
55+
56+start_server() {
57+ if [ -z "$DAEMONUSER" ] ; then
58+ start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
59+ errcode=$?
60+ else
61+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
62+ --chuid $DAEMONUSER \
63+ --exec $DAEMON -- $DAEMON_OPTS
64+ errcode=$?
65+ fi
66+ return $errcode
67+}
68+
69+stop_server() {
70+ if [ -z "$DAEMONUSER" ] ; then
71+ killproc -p $PIDFILE $DAEMON
72+ errcode=$?
73+ else
74+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
75+ --user $DAEMONUSER \
76+ --exec $DAEMON
77+ errcode=$?
78+ fi
79+ return $errcode
80+}
81+
82+reload_server() {
83+ if [ -z "$DAEMONUSER" ] ; then
84+ killproc -p $PIDFILE $DAEMON -HUP
85+ errcode=$?
86+ else
87+ start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE \
88+ --user $DAEMONUSER \
89+ --exec $DAEMON
90+ errcode=$?
91+ fi
92+ return $errcode
93+}
94+
95+run_server() {
96+ if [ -z "$DAEMONUSER" ] ; then
97+ killproc -p $PIDFILE $DAEMON -USR1
98+ errcode=$?
99+ else
100+ start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE \
101+ --user $DAEMONUSER \
102+ --exec $DAEMON
103+ errcode=$?
104+ fi
105+ return $errcode
106+}
107+
108+force_stop() {
109+ [ ! -e "$PIDFILE" ] && return
110+ if running ; then
111+ /bin/kill -15 $pid
112+ sleep "$DIETIME"s
113+ if running ; then
114+ /bin/kill -9 $pid
115+ sleep "$DIETIME"s
116+ if running ; then
117+ echo "Cannot kill $NAME (pid=$pid)!"
118+ exit 1
119+ fi
120+ fi
121+ fi
122+ rm -f $PIDFILE
123+}
124+
125+case "$1" in
126+ start)
127+ log_daemon_msg "Starting $DESC " "$NAME"
128+ if running ; then
129+ log_progress_msg "apparently already running"
130+ log_end_msg 0
131+ exit 0
132+ fi
133+ if start_server ; then
134+ [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
135+ if running ; then
136+ log_end_msg 0
137+ else
138+ log_end_msg 1
139+ fi
140+ else
141+ log_end_msg 1
142+ fi
143+ ;;
144+ stop)
145+ log_daemon_msg "Stopping $DESC" "$NAME"
146+ if running ; then
147+ errcode=0
148+ stop_server || errcode=$?
149+ log_end_msg $errcode
150+ else
151+ log_progress_msg "apparently not running"
152+ log_end_msg 0
153+ exit 0
154+ fi
155+ ;;
156+ force-stop)
157+ $0 stop
158+ if running; then
159+ log_daemon_msg "Stopping (force) $DESC" "$NAME"
160+ errcode=0
161+ force_stop || errcode=$?
162+ log_end_msg $errcode
163+ fi
164+ ;;
165+ restart|force-reload)
166+ log_daemon_msg "Restarting $DESC" "$NAME"
167+ errcode=0
168+ stop_server || errcode=$?
169+ [ -n "$DIETIME" ] && sleep $DIETIME
170+ start_server || errcode=$?
171+ [ -n "$STARTTIME" ] && sleep $STARTTIME
172+ running || errcode=$?
173+ log_end_msg $errcode
174+ ;;
175+ status)
176+ log_daemon_msg "Checking status of $DESC" "$NAME"
177+ if running ; then
178+ log_progress_msg "running"
179+ log_end_msg 0
180+ else
181+ log_progress_msg "apparently not running"
182+ log_end_msg 1
183+ exit 3
184+ fi
185+ ;;
186+ reload)
187+ if running; then
188+ log_daemon_msg "Reloading $DESC" "$NAME"
189+ errcode=0
190+ reload_server || errcode=$?
191+ log_end_msg $errcode
192+ fi
193+ ;;
194+ run)
195+ if running; then
196+ log_daemon_msg "Triggering run of $DESC" "$NAME"
197+ errcode=0
198+ run_server || errcode=$?
199+ log_end_msg $errcode
200+ fi
201+ ;;
202+ *)
203+ N=/etc/init.d/$NAME
204+ echo "Usage: $N {start|stop|force-stop|restart|force-reload|status|run}" >&2
205+ exit 1
206+ ;;
207+esac
208+
209+exit 0
210+
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/debian/init/chef-client.conf.erb
@@ -0,0 +1,17 @@
1+# chef-client - Chef Configuration Management Client
2+#
3+# Chef Client provides the Chef configuration management daemon
4+
5+description "Chef Client"
6+
7+start on net-device-up
8+stop on runlevel [!2345]
9+
10+respawn
11+respawn limit 5 30
12+
13+pre-start script
14+ test -x <%= @client_bin %> || { stop; exit 0; }
15+end script
16+
17+exec <%= @client_bin %> -i <%= node["chef_client"]["interval"] %> -L <%= node["chef_client"]["log_dir"] %>/client.log <%= node["chef_client"]["daemon_options"].join(' ') %>
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/redhat/init.d/chef-client.erb
@@ -0,0 +1,110 @@
1+#!/bin/bash
2+#
3+# chef-client Startup script for the Chef client
4+#
5+# chkconfig: - 98 02
6+# description: Client component of the Chef systems integration framework.
7+
8+### BEGIN INIT INFO
9+# Provides: chef-client
10+# Required-Start: $local_fs $network $remote_fs
11+# Required-Stop: $local_fs $network $remote_fs
12+# Should-Start: $named $time
13+# Should-Stop: $named $time
14+# Short-Description: Startup script for the Chef client
15+# Description: Client component of the Chef systems integration framework.
16+### END INIT INFO
17+
18+# Source function library
19+. /etc/init.d/functions
20+
21+exec="<%= @client_bin %>"
22+prog="chef-client"
23+
24+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
25+
26+config=${CONFIG-/etc/chef/client.rb}
27+pidfile=${PIDFILE-/var/run/chef/client.pid}
28+lockfile=${LOCKFILE-/var/lock/subsys/$prog}
29+logfile=${LOGFILE-/var/log/chef/client.log}
30+interval=${INTERVAL-1800}
31+splay=${SPLAY-20}
32+options=${OPTIONS-}
33+
34+start() {
35+ [ -x $exec ] || exit 5
36+ [ -f $config ] || exit 6
37+ echo -n $"Starting $prog: "
38+ daemon $exec -d -c "$config" -L "$logfile" -P "$pidfile" -i "$interval" -s "$splay" "$options"
39+ retval=$?
40+ echo
41+ [ $retval -eq 0 ] && touch $lockfile
42+ return $retval
43+}
44+
45+stop() {
46+ echo -n $"Stopping $prog: "
47+ killproc -p $pidfile $exec
48+ retval=$?
49+ echo
50+ [ $retval -eq 0 ] && rm -f $lockfile
51+ return $retval
52+}
53+
54+restart () {
55+ stop
56+ start
57+}
58+
59+reload() {
60+ echo -n $"Reloading $prog: "
61+ killproc -p $pidfile $exec -HUP
62+ retval=$?
63+ echo
64+ return $retval
65+}
66+
67+force_reload() {
68+ restart
69+}
70+
71+rh_status() {
72+ # run checks to determine if the service is running or use generic status
73+ status -p $pidfile $prog
74+}
75+
76+rh_status_q() {
77+ rh_status >/dev/null 2>&1
78+}
79+
80+case "$1" in
81+ start)
82+ rh_status_q && exit 0
83+ $1
84+ ;;
85+ stop)
86+ rh_status_q || exit 0
87+ $1
88+ ;;
89+ restart)
90+ $1
91+ ;;
92+ reload)
93+ rh_status_q || exit 7
94+ $1
95+ ;;
96+ force-reload)
97+ force_reload
98+ ;;
99+ status)
100+ rh_status
101+ ;;
102+ condrestart|try-restart)
103+ rh_status_q || exit 0
104+ restart
105+ ;;
106+ *)
107+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
108+ exit 2
109+esac
110+exit $?
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/redhat/sysconfig/chef-client.erb
@@ -0,0 +1,15 @@
1+# Configuration file for the chef-client service
2+
3+CONFIG=<%= node["chef_client"]["conf_dir"] %>/client.rb
4+PIDFILE=<%= node["chef_client"]["run_path"] %>/client.pid
5+#LOCKFILE=/var/lock/subsys/chef-client
6+LOGFILE=<%= node["chef_client"]["log_dir"] %>/client.log
7+# Sleep interval between runs.
8+# This value is in seconds.
9+INTERVAL=<%= node["chef_client"]["interval"] %>
10+# Maximum amount of random delay before starting a run. Prevents every client
11+# from contacting the server at the exact same time.
12+# This value is in seconds.
13+SPLAY=<%= node["chef_client"]["splay"] %>
14+# Any additional chef-client options.
15+OPTIONS="<%= node["chef_client"]["daemon_options"].join(' ') %>"
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/solaris/chef-client.erb
@@ -0,0 +1,78 @@
1+#!/bin/bash
2+####################################################################
3+# COOKBOOK NAME: chef-client
4+# RECIPE: default
5+# DESCRIPTION: chef-client start/stop script for Solaris SMF
6+#
7+####################################################################
8+# (C)2011 DigiTar, All Rights Reserved
9+# Distributed under the BSD License
10+#
11+# Redistribution and use in source and binary forms, with or without modification,
12+# are permitted provided that the following conditions are met:
13+#
14+# * Redistributions of source code must retain the above copyright notice,
15+# this list of conditions and the following disclaimer.
16+# * Redistributions in binary form must reproduce the above copyright notice,
17+# this list of conditions and the following disclaimer in the documentation
18+# and/or other materials provided with the distribution.
19+# * Neither the name of DigiTar nor the names of its contributors may be
20+# used to endorse or promote products derived from this software without
21+# specific prior written permission.
22+#
23+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
24+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26+# SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
32+# DAMAGE.
33+#
34+####################################################################
35+
36+. /lib/svc/share/smf_include.sh
37+
38+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
39+DAEMON=<%= node["chef_client"]["bin_dir"] %>/chef-client
40+NAME=chef-client
41+DESC=chef-client
42+PIDFILE=<%= node["chef_client"]["run_path"] %>/client.pid
43+LOGFILE=<%= node["chef_client"]["log_dir"] %>/client.log
44+CONFIG=<%= node["chef_client"]["conf_dir"] %>/client.rb
45+INTERVAL=<%= node["chef_client"]["interval"] %>
46+SPLAY=<%= node["chef_client"]["splay"] %>
47+
48+DAEMON_OPTS="-d -P $PIDFILE -L $LOGFILE -c $CONFIG -i $INTERVAL -s $SPLAY <%= node["chef_client"]["daemon_options"].join(' ') %>"
49+
50+if [ ! -d <%= node["chef_client"]["run_path"] %> ]; then
51+ mkdir <%= node["chef_client"]["run_path"] %>
52+fi
53+
54+case "$1" in
55+'start')
56+$DAEMON $DAEMON_OPTS
57+;;
58+
59+'stop')
60+kill `cat $PIDFILE`
61+;;
62+
63+'refresh')
64+kill -1 `cat $PIDFILE`
65+;;
66+
67+'restart')
68+kill `cat $PIDFILE`
69+$DAEMON $DAEMON_OPTS
70+;;
71+
72+*)
73+echo $"Usage: $0 (start|stop|restart|refresh)"
74+exit 1
75+;;
76+
77+esac
78+exit $SMF_EXIT_OK
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/solaris/manifest.xml.erb
@@ -0,0 +1,109 @@
1+<?xml version="1.0"?>
2+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
3+
4+<service_bundle type='manifest' name='chef-client'>
5+
6+<service
7+ name='application/management/chef-client'
8+ type='service'
9+ version='1'>
10+
11+ <create_default_instance enabled='false' />
12+
13+ <single_instance />
14+
15+ <dependency
16+ name='milestone'
17+ grouping='require_all'
18+ restart_on='none'
19+ type='service'>
20+ <service_fmri value='svc:/milestone/sysconfig' />
21+ </dependency>
22+
23+ <!-- Need / & /usr filesystems mounted, /var mounted read/write -->
24+ <dependency
25+ name='fs-local'
26+ type='service'
27+ grouping='require_all'
28+ restart_on='none'>
29+ <service_fmri value='svc:/system/filesystem/local' />
30+ </dependency>
31+
32+ <dependency
33+ name='name-services'
34+ grouping='optional_all'
35+ restart_on='none'
36+ type='service'>
37+ <service_fmri value='svc:/milestone/name-services' />
38+ </dependency>
39+
40+ <dependency
41+ name='network'
42+ grouping='require_all'
43+ restart_on='restart'
44+ type='service'>
45+ <service_fmri value='svc:/milestone/network' />
46+ </dependency>
47+
48+ <dependency
49+ name='config-file'
50+ grouping='require_all'
51+ restart_on='refresh'
52+ type='path'>
53+ <service_fmri
54+ value='file://localhost/etc/chef/client.rb' />
55+ </dependency>
56+
57+ <exec_method
58+ type='method'
59+ name='start'
60+ exec='<%= node['chef_client']['method_dir'] %>/chef-client %m'
61+ timeout_seconds='60'>
62+ <method_context>
63+ <method_environment>
64+ <envvar name="LANG" value="en_US.UTF-8"/>
65+ <envvar name="LC_ALL" value="en_US.UTF-8"/>
66+ </method_environment>
67+ </method_context>
68+ </exec_method>
69+
70+ <exec_method
71+ type='method'
72+ name='stop'
73+ exec='<%= node['chef_client']['method_dir'] %>/chef-client %m'
74+ timeout_seconds='60'>
75+ </exec_method>
76+
77+ <exec_method
78+ type='method'
79+ name='refresh'
80+ exec='<%= node['chef_client']['method_dir'] %>/chef-client %m'
81+ timeout_seconds='60'>
82+ </exec_method>
83+
84+ <exec_method
85+ type='method'
86+ name='restart'
87+ exec='<%= node['chef_client']['method_dir'] %>/chef-client %m'
88+ timeout_seconds='60'>
89+ </exec_method>
90+
91+ <property_group name='general' type='framework'>
92+ <!-- to start/stop chef-client -->
93+ <propval name='action_authorization' type='astring'
94+ value='solaris.smf.manage.chef-client' />
95+
96+ </property_group>
97+
98+ <template>
99+ <common_name>
100+ <loctext xml:lang='C'>
101+ chef-client Chef Client
102+ </loctext>
103+ </common_name>
104+
105+ </template>
106+
107+</service>
108+
109+</service_bundle>
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/suse/init.d/chef-client.erb
@@ -0,0 +1,144 @@
1+#!/bin/sh
2+### BEGIN INIT INFO
3+# Provides: chef-client
4+# Required-Start: $syslog $remote_fs
5+# Should-Start: $time
6+# Required-Stop: $syslog $remote_fs
7+# Should-Stop:
8+# Default-Start: 3 5
9+# Default-Stop: 0 1 2 6
10+# Short-Description: Startup script for the Chef client
11+# Description: Client component of the Chef systems integration framework.
12+### END INIT INFO
13+
14+
15+CHEF_CLIENT=<%= @client_bin %>
16+test -x $CHEF_CLIENT || { echo "$CHEF_CLIENT not installed";
17+ if [ "$1" = "stop" ]; then exit 0;
18+ else exit 5; fi; }
19+
20+PIDFILE=<%= node["chef_client"]["run_path"] %>/client.pid
21+
22+# Read sysconfig
23+if [ -f "/etc/sysconfig/chef-client" ]; then
24+ . /etc/sysconfig/chef-client
25+fi
26+
27+CONFIG=${CONFIG-<%= node["chef_client"]["conf_dir"] %>/client.rb}
28+PIDFILE=${PIDFILE-<%= node["chef_client"]["run_dir"] %>/client.pid}
29+LOCKFILE=${LOCKFILE-/var/lock/subsys/chef-client}
30+LOGFILE=${LOGFILE-<%= node["chef_client"]["log_dir"] %>/client.log}
31+INTERVAL=${INTERVAL-<%= node["chef_client"]["interval"] %>}
32+SPLAY=${SPLAY-<%= node["chef_client"]["splay"] %>}
33+OPTIONS=${OPTIONS-}
34+
35+
36+# Source LSB init functions
37+# providing start_daemon, killproc, pidofproc,
38+# log_success_msg, log_failure_msg and log_warning_msg.
39+. /lib/lsb/init-functions
40+
41+# Shell functions sourced from /etc/rc.status:
42+# rc_check check and set local and overall rc status
43+# rc_status check and set local and overall rc status
44+# rc_status -v be verbose in local rc status and clear it afterwards
45+# rc_status -v -r ditto and clear both the local and overall rc status
46+# rc_status -s display "skipped" and exit with status 3
47+# rc_status -u display "unused" and exit with status 3
48+# rc_failed set local and overall rc status to failed
49+# rc_failed <num> set local and overall rc status to <num>
50+# rc_reset clear both the local and overall rc status
51+# rc_exit exit appropriate to overall rc status
52+# rc_active checks whether a service is activated by symlinks
53+. /etc/rc.status
54+
55+# Reset status of this service
56+rc_reset
57+
58+# Return values acc. to LSB for all commands but status:
59+# 0 - success
60+# 1 - generic or unspecified error
61+# 2 - invalid or excess argument(s)
62+# 3 - unimplemented feature (e.g. "reload")
63+# 4 - user had insufficient privileges
64+# 5 - program is not installed
65+# 6 - program is not configured
66+# 7 - program is not running
67+# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
68+#
69+# Note that starting an already running service, stopping
70+# or restarting a not-running service as well as the restart
71+# with force-reload (in case signaling is not supported) are
72+# considered a success.
73+
74+case "$1" in
75+ start)
76+ echo -n "Starting chef-client "
77+ ## Start daemon with startproc(8). If this fails
78+ ## the return value is set appropriately by startproc.
79+ /sbin/startproc -p $PIDFILE $CHEF_CLIENT -d -c "$CONFIG" -L "$LOGFILE" -P "$PIDFILE" -i "$INTERVAL" -s "$SPLAY" "$OPTIONS"
80+
81+ # Remember status and be verbose
82+ rc_status -v
83+ ;;
84+ stop)
85+ echo -n "Shutting down chef-client "
86+ ## Stop daemon with killproc(8) and if this fails
87+ ## killproc sets the return value according to LSB.
88+
89+ /sbin/killproc -p $PIDFILE -TERM $CHEF_CLIENT
90+
91+ # Remember status and be verbose
92+ rc_status -v
93+ ;;
94+ try-restart|condrestart)
95+ ## Do a restart only if the service was active before.
96+ ## Note: try-restart is now part of LSB (as of 1.9).
97+ ## RH has a similar command named condrestart.
98+ if test "$1" = "condrestart"; then
99+ echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
100+ fi
101+ $0 status
102+ if test $? = 0; then
103+ $0 restart
104+ else
105+ rc_reset # Not running is not a failure.
106+ fi
107+ # Remember status and be quiet
108+ rc_status
109+ ;;
110+ force-reload|reload|restart)
111+ ## Stop the service and regardless of whether it was
112+ ## running or not, start it again.
113+ $0 stop
114+ $0 start
115+
116+ # Remember status and be quiet
117+ rc_status
118+ ;;
119+ status)
120+ echo -n "Checking for service chef-client "
121+ ## Check status with checkproc(8), if process is running
122+ ## checkproc will return with exit status 0.
123+
124+ # Return value is slightly different for the status command:
125+ # 0 - service up and running
126+ # 1 - service dead, but /var/run/ pid file exists
127+ # 2 - service dead, but /var/lock/ lock file exists
128+ # 3 - service not running (unused)
129+ # 4 - service status unknown :-(
130+ # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
131+
132+ # NOTE: checkproc returns LSB compliant status values.
133+ /sbin/checkproc -p $PIDFILE $CHEF_CLIENT
134+ # NOTE: rc_status knows that we called this init script with
135+ # "status" option and adapts its messages accordingly.
136+ rc_status -v
137+ ;;
138+ *)
139+ echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
140+ exit 1
141+ ;;
142+esac
143+rc_exit
144+
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/suse/sysconfig/chef-client.erb
@@ -0,0 +1,15 @@
1+# Configuration file for the chef-client service
2+
3+CONFIG=<%= node["chef_client"]["conf_dir"] %>/client.rb
4+PIDFILE=<%= node["chef_client"]["run_path"] %>/client.pid
5+#LOCKFILE=/var/lock/subsys/chef-client
6+LOGFILE=<%= node["chef_client"]["log_dir"] %>/client.log
7+# Sleep interval between runs.
8+# This value is in seconds.
9+INTERVAL=<%= node["chef_client"]["interval"] %>
10+# Maximum amount of random delay before starting a run. Prevents every client
11+# from contacting the server at the exact same time.
12+# This value is in seconds.
13+SPLAY=<%= node["chef_client"]["splay"] %>
14+# Any additional chef-client options.
15+OPTIONS="<%= node["chef_client"]["daemon_options"].join(' ') %>"
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/sv-chef-client-log-run.erb
@@ -0,0 +1,2 @@
1+#!/bin/sh
2+exec svlogd -tt ./main
--- /dev/null
+++ b/cookbooks/chef-client/templates/default/sv-chef-client-run.erb
@@ -0,0 +1,4 @@
1+#!/bin/sh
2+PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin<% if node["languages"]["ruby"]["gems_dir"] %>:<%= node["languages"]["ruby"]["gems_dir"] %>/bin<% end -%>
3+exec 2>&1
4+exec /usr/bin/env chef-client -i <%= node["chef_client"]["interval"] %> -s <%= node["chef_client"]["splay"] %> <%= node["chef_client"]["daemon_options"].join(' ') %>
--- /dev/null
+++ b/cookbooks/chef-client/templates/windows/chef-client.xml.erb
@@ -0,0 +1,38 @@
1+<!--
2+The MIT License
3+
4+Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5+
6+Permission is hereby granted, free of charge, to any person obtaining a copy
7+of this software and associated documentation files (the "Software"), to deal
8+in the Software without restriction, including without limitation the rights
9+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+copies of the Software, and to permit persons to whom the Software is
11+furnished to do so, subject to the following conditions:
12+
13+The above copyright notice and this permission notice shall be included in
14+all copies or substantial portions of the Software.
15+
16+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+THE SOFTWARE.
23+-->
24+
25+<!--
26+ Windows service definition for Chef Client
27+ To uninstall, run "chef-client.exe stop" to stop the service, then "chef-client.exe uninstall" to uninstall the service.
28+ Both commands don't produce any output if the execution is successful.
29+-->
30+<service>
31+ <id>chef-client</id>
32+ <name>Chef-client Service for Windows</name>
33+ <description>This service runs chef-client. Configuration of this service is managed by the chef-client cookbook.</description>
34+ <executable><%= node["chef_client"]["ruby_bin"] %></executable>
35+ <arguments><%= node["chef_client"]["bin"] %> -L "<%= File.join(node["chef_client"]["log_dir"], "client.log") %>" -c "<%= File.join(node["chef_client"]["conf_dir"], "client.rb") %>" -i <%= node["chef_client"]["interval"] %> -s <%= node["chef_client"]["splay"] %> <%= node["chef_client"]["daemon_options"].join(' ') %></arguments>
36+ <logmode>rotate</logmode>
37+ <logpath><%= node["chef_client"]["log_dir"] %></logpath>
38+</service>
Afficher sur ancien navigateur de dépôt.