from-scratch 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Berksfile +2 -1
- data/Berksfile.lock +20 -1
- data/cookbooks/bluepill/CHANGELOG.md +93 -0
- data/cookbooks/bluepill/README.md +91 -0
- data/cookbooks/bluepill/attributes/default.rb +44 -0
- data/cookbooks/bluepill/metadata.json +1 -0
- data/cookbooks/bluepill/providers/service.rb +172 -0
- data/cookbooks/bluepill/recipes/default.rb +48 -0
- data/cookbooks/bluepill/recipes/rsyslog.rb +28 -0
- data/cookbooks/bluepill/resources/service.rb +27 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.fedora.erb +34 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.freebsd.erb +32 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.lsb.erb +37 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.rhel.erb +34 -0
- data/cookbooks/bluepill/templates/default/bluepill_rsyslog.conf.erb +1 -0
- data/cookbooks/nginx/CHANGELOG.md +435 -0
- data/cookbooks/nginx/README.md +521 -0
- data/cookbooks/nginx/attributes/auth_request.rb +23 -0
- data/cookbooks/nginx/attributes/default.rb +131 -0
- data/cookbooks/nginx/attributes/devel.rb +24 -0
- data/cookbooks/nginx/attributes/echo.rb +24 -0
- data/cookbooks/nginx/attributes/geoip.rb +31 -0
- data/cookbooks/nginx/attributes/headers_more.rb +24 -0
- data/cookbooks/nginx/attributes/lua.rb +28 -0
- data/cookbooks/nginx/attributes/naxsi.rb +24 -0
- data/cookbooks/nginx/attributes/openssl_source.rb +23 -0
- data/cookbooks/nginx/attributes/pagespeed.rb +9 -0
- data/cookbooks/nginx/attributes/passenger.rb +58 -0
- data/cookbooks/nginx/attributes/rate_limiting.rb +23 -0
- data/cookbooks/nginx/attributes/repo.rb +35 -0
- data/cookbooks/nginx/attributes/set_misc.rb +8 -0
- data/cookbooks/nginx/attributes/socketproxy.rb +13 -0
- data/cookbooks/nginx/attributes/source.rb +42 -0
- data/cookbooks/nginx/attributes/status.rb +22 -0
- data/cookbooks/nginx/attributes/syslog.rb +24 -0
- data/cookbooks/nginx/attributes/upload_progress.rb +26 -0
- data/cookbooks/nginx/definitions/nginx_site.rb +50 -0
- data/cookbooks/nginx/files/default/mime.types +78 -0
- data/cookbooks/nginx/files/default/naxsi_core.rules +82 -0
- data/cookbooks/nginx/libraries/matchers.rb +20 -0
- data/cookbooks/nginx/metadata.json +351 -0
- data/cookbooks/nginx/recipes/authorized_ips.rb +32 -0
- data/cookbooks/nginx/recipes/commons.rb +24 -0
- data/cookbooks/nginx/recipes/commons_conf.rb +42 -0
- data/cookbooks/nginx/recipes/commons_dir.rb +57 -0
- data/cookbooks/nginx/recipes/commons_script.rb +29 -0
- data/cookbooks/nginx/recipes/default.rb +31 -0
- data/cookbooks/nginx/recipes/headers_more_module.rb +50 -0
- data/cookbooks/nginx/recipes/http_auth_request_module.rb +52 -0
- data/cookbooks/nginx/recipes/http_echo_module.rb +46 -0
- data/cookbooks/nginx/recipes/http_geoip_module.rb +113 -0
- data/cookbooks/nginx/recipes/http_gzip_static_module.rb +30 -0
- data/cookbooks/nginx/recipes/http_mp4_module.rb +2 -0
- data/cookbooks/nginx/recipes/http_perl_module.rb +23 -0
- data/cookbooks/nginx/recipes/http_realip_module.rb +38 -0
- data/cookbooks/nginx/recipes/http_spdy_module.rb +23 -0
- data/cookbooks/nginx/recipes/http_ssl_module.rb +23 -0
- data/cookbooks/nginx/recipes/http_stub_status_module.rb +36 -0
- data/cookbooks/nginx/recipes/ipv6.rb +23 -0
- data/cookbooks/nginx/recipes/lua.rb +47 -0
- data/cookbooks/nginx/recipes/naxsi_module.rb +52 -0
- data/cookbooks/nginx/recipes/ngx_devel_module.rb +44 -0
- data/cookbooks/nginx/recipes/ngx_lua_module.rb +47 -0
- data/cookbooks/nginx/recipes/ohai_plugin.rb +35 -0
- data/cookbooks/nginx/recipes/openssl_source.rb +45 -0
- data/cookbooks/nginx/recipes/package.rb +52 -0
- data/cookbooks/nginx/recipes/pagespeed_module.rb +62 -0
- data/cookbooks/nginx/recipes/passenger.rb +56 -0
- data/cookbooks/nginx/recipes/repo.rb +41 -0
- data/cookbooks/nginx/recipes/repo_passenger.rb +39 -0
- data/cookbooks/nginx/recipes/set_misc.rb +30 -0
- data/cookbooks/nginx/recipes/socketproxy.rb +26 -0
- data/cookbooks/nginx/recipes/source.rb +205 -0
- data/cookbooks/nginx/recipes/syslog_module.rb +69 -0
- data/cookbooks/nginx/recipes/upload_progress_module.rb +53 -0
- data/cookbooks/nginx/templates/debian/nginx.init.erb +97 -0
- data/cookbooks/nginx/templates/default/default-site.erb +11 -0
- data/cookbooks/nginx/templates/default/modules/authorized_ip.erb +6 -0
- data/cookbooks/nginx/templates/default/modules/http_geoip.conf.erb +4 -0
- data/cookbooks/nginx/templates/default/modules/http_gzip_static.conf.erb +1 -0
- data/cookbooks/nginx/templates/default/modules/http_realip.conf.erb +7 -0
- data/cookbooks/nginx/templates/default/modules/nginx_status.erb +14 -0
- data/cookbooks/nginx/templates/default/modules/passenger.conf.erb +13 -0
- data/cookbooks/nginx/templates/default/modules/socketproxy.conf.erb +89 -0
- data/cookbooks/nginx/templates/default/modules/upload_progress.erb +4 -0
- data/cookbooks/nginx/templates/default/nginx-upstart.conf.erb +39 -0
- data/cookbooks/nginx/templates/default/nginx.conf.erb +103 -0
- data/cookbooks/nginx/templates/default/nginx.init.erb +111 -0
- data/cookbooks/nginx/templates/default/nginx.pill.erb +15 -0
- data/cookbooks/nginx/templates/default/nginx.sysconfig.erb +1 -0
- data/cookbooks/nginx/templates/default/nxdissite.erb +29 -0
- data/cookbooks/nginx/templates/default/nxensite.erb +38 -0
- data/cookbooks/nginx/templates/default/plugins/nginx.rb.erb +66 -0
- data/cookbooks/nginx/templates/default/sv-nginx-log-run.erb +2 -0
- data/cookbooks/nginx/templates/default/sv-nginx-run.erb +4 -0
- data/cookbooks/nginx/templates/gentoo/nginx.init.erb +87 -0
- data/cookbooks/nginx/templates/suse/nginx.init.erb +115 -0
- data/cookbooks/nginx/templates/ubuntu/nginx.init.erb +97 -0
- data/cookbooks/ohai/CHANGELOG.md +69 -0
- data/cookbooks/ohai/README.md +89 -0
- data/cookbooks/ohai/attributes/default.rb +31 -0
- data/cookbooks/ohai/files/default/plugins/README +1 -0
- data/cookbooks/ohai/libraries/matchers.rb +14 -0
- data/cookbooks/ohai/metadata.json +1 -0
- data/cookbooks/ohai/providers/hint.rb +38 -0
- data/cookbooks/ohai/recipes/default.rb +52 -0
- data/cookbooks/ohai/resources/hint.rb +5 -0
- data/cookbooks/packagecloud/CHANGELOG.md +12 -0
- data/cookbooks/packagecloud/README.md +80 -0
- data/cookbooks/packagecloud/attributes/default.rb +8 -0
- data/cookbooks/packagecloud/libraries/helper.rb +43 -0
- data/cookbooks/packagecloud/libraries/matcher.rb +7 -0
- data/cookbooks/packagecloud/metadata.json +1 -0
- data/cookbooks/packagecloud/providers/repo.rb +212 -0
- data/cookbooks/packagecloud/resources/repo.rb +10 -0
- data/cookbooks/packagecloud/templates/.kitchen/logs/kitchen.log +29 -0
- data/cookbooks/packagecloud/templates/default/apt.erb +2 -0
- data/cookbooks/packagecloud/templates/default/yum.erb +15 -0
- data/cookbooks/rsyslog/CHANGELOG.md +193 -0
- data/cookbooks/rsyslog/README.md +276 -0
- data/cookbooks/rsyslog/attributes/default.rb +131 -0
- data/cookbooks/rsyslog/libraries/helpers.rb +25 -0
- data/cookbooks/rsyslog/metadata.json +1 -0
- data/cookbooks/rsyslog/providers/file_input.rb +44 -0
- data/cookbooks/rsyslog/recipes/client.rb +87 -0
- data/cookbooks/rsyslog/recipes/default.rb +89 -0
- data/cookbooks/rsyslog/recipes/server.rb +44 -0
- data/cookbooks/rsyslog/resources/file_input.rb +28 -0
- data/cookbooks/rsyslog/templates/default/35-server-per-host.conf.erb +62 -0
- data/cookbooks/rsyslog/templates/default/49-relp.conf.erb +10 -0
- data/cookbooks/rsyslog/templates/default/49-remote.conf.erb +30 -0
- data/cookbooks/rsyslog/templates/default/50-default.conf.erb +6 -0
- data/cookbooks/rsyslog/templates/default/file-input.conf.erb +15 -0
- data/cookbooks/rsyslog/templates/default/omnios-manifest.xml.erb +30 -0
- data/cookbooks/rsyslog/templates/default/rsyslog.conf.erb +117 -0
- data/cookbooks/rsyslog/templates/smartos/50-default.conf.erb +18 -0
- data/cookbooks/runit/.kitchen.cloud.yml +103 -0
- data/cookbooks/runit/.kitchen.yml +38 -0
- data/cookbooks/runit/.rspec +3 -0
- data/cookbooks/runit/.rubocop.yml +45 -0
- data/cookbooks/runit/Berksfile.disabled +11 -0
- data/cookbooks/runit/CHANGELOG.md +226 -0
- data/cookbooks/runit/CONTRIBUTING.md +266 -0
- data/cookbooks/runit/Cheffile +11 -0
- data/cookbooks/runit/Gemfile +17 -0
- data/cookbooks/runit/LICENSE +201 -0
- data/cookbooks/runit/README.md +435 -0
- data/cookbooks/runit/Rakefile +23 -0
- data/cookbooks/runit/TESTING.md +26 -0
- data/cookbooks/runit/attributes/default.rb +62 -0
- data/cookbooks/runit/files/default/runit.seed +1 -0
- data/cookbooks/runit/files/default/runsvdir +0 -0
- data/cookbooks/runit/files/ubuntu-6.10/runsvdir +6 -0
- data/cookbooks/runit/files/ubuntu-7.04/runsvdir +7 -0
- data/cookbooks/runit/files/ubuntu-7.10/runsvdir +7 -0
- data/cookbooks/runit/files/ubuntu-8.04/runsvdir +7 -0
- data/cookbooks/runit/libraries/default.rb +0 -0
- data/cookbooks/runit/libraries/helpers.rb +190 -0
- data/cookbooks/runit/libraries/matchers.rb +69 -0
- data/cookbooks/runit/libraries/provider_runit_service.rb +326 -0
- data/cookbooks/runit/libraries/resource_runit_service.rb +267 -0
- data/cookbooks/runit/metadata.json +50 -0
- data/cookbooks/runit/recipes/default.rb +91 -0
- data/cookbooks/runit/templates/debian/init.d.erb +66 -0
- data/cookbooks/runit/templates/default/log-config.erb +24 -0
- data/cookbooks/runit/templates/gentoo/runit-start.sh.erb +32 -0
- data/cookbooks/scratchify/Berksfile +2 -1
- data/cookbooks/scratchify/Berksfile.lock +20 -1
- data/cookbooks/scratchify/lib/from-scratch.rb +1 -4
- data/cookbooks/scratchify/lib/from-scratch/version.rb +1 -1
- data/cookbooks/scratchify/metadata.json +5 -2
- data/cookbooks/scratchify/recipes/default.rb +15 -1
- data/cookbooks/scratchify/recipes/nginx_site.rb +4 -0
- data/cookbooks/scratchify/recipes/pre_rvm.rb +5 -0
- data/cookbooks/scratchify/templates/nginx.erb +31 -0
- data/cookbooks/scratchify/templates/node.json.erb +21 -6
- data/cookbooks/yum-epel/CHANGELOG.md +84 -0
- data/cookbooks/yum-epel/README.md +172 -0
- data/cookbooks/yum-epel/attributes/default.rb +1 -0
- data/cookbooks/yum-epel/attributes/epel-debuginfo.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-source.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-testing-source.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-testing.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel.rb +28 -0
- data/cookbooks/yum-epel/metadata.json +1 -0
- data/cookbooks/yum-epel/recipes/default.rb +61 -0
- data/cookbooks/yum/CHANGELOG.md +294 -0
- data/cookbooks/yum/README.md +285 -0
- data/cookbooks/yum/attributes/main.rb +100 -0
- data/cookbooks/yum/libraries/matchers.rb +27 -0
- data/cookbooks/yum/metadata.json +1 -0
- data/cookbooks/yum/providers/globalconfig.rb +41 -0
- data/cookbooks/yum/providers/repository.rb +106 -0
- data/cookbooks/yum/recipes/default.rb +26 -0
- data/cookbooks/yum/resources/globalconfig.rb +109 -0
- data/cookbooks/yum/resources/repository.rb +69 -0
- data/cookbooks/yum/templates/default/main.erb +276 -0
- data/cookbooks/yum/templates/default/repo.erb +125 -0
- data/lib/from-scratch.rb +1 -0
- data/lib/from-scratch/version.rb +1 -1
- data/metadata.rb +5 -1
- data/recipes/default.rb +15 -1
- data/recipes/nginx_site.rb +4 -0
- data/recipes/pre_rvm.rb +5 -0
- data/templates/nginx.erb +31 -0
- data/templates/node.json.erb +21 -6
- metadata +194 -1
@@ -0,0 +1,435 @@
|
|
1
|
+
runit Cookbook
|
2
|
+
==============
|
3
|
+
Installs runit and provides the `runit_service` service resource for managing processes (services) under runit.
|
4
|
+
|
5
|
+
This cookbook does not use runit to replace system init, nor are ther plans to do so.
|
6
|
+
|
7
|
+
For more information about runit:
|
8
|
+
|
9
|
+
- http://smarden.org/runit/
|
10
|
+
|
11
|
+
#### A note regarding versions 1.7.0 and 1.7.2
|
12
|
+
|
13
|
+
With the benefit of hindsight we can say that the changes contained version 1.7.0 merited a major version number change, and that version 1.7.2 contains some still unresolved regressions compared to 1.6.0. Please be sure to test this new version for compatibility with your systems before upgrading to version 1.7.
|
14
|
+
|
15
|
+
See [issue #144](https://github.com/hw-cookbooks/runit/issues/144) for some notes on how these versions behaved unexpectedly in one user's environment.
|
16
|
+
|
17
|
+
Requirements
|
18
|
+
------------
|
19
|
+
### Platforms
|
20
|
+
- Debian/Ubuntu
|
21
|
+
- Gentoo
|
22
|
+
- RHEL
|
23
|
+
|
24
|
+
### Cookbooks
|
25
|
+
- packagecloud (for RHEL)
|
26
|
+
|
27
|
+
Attributes
|
28
|
+
----------
|
29
|
+
See `attributes/default.rb` for defaults generated per platform.
|
30
|
+
|
31
|
+
- `node['runit']['sv_bin']` - Full path to the `sv` binary.
|
32
|
+
- `node['runit']['chpst_bin']` - Full path to the `chpst` binary.
|
33
|
+
- `node['runit']['service_dir']` - Full path to the default "services" directory where enabled services are linked.
|
34
|
+
- `node['runit']['sv_dir']` - Full path to the directory where service lives, which gets linked to `service_dir`.
|
35
|
+
- `node['runit']['lsb_init_dir']` - Full path to the directory where the LSB-compliant init script interface will be created.
|
36
|
+
- `node['runit']['start']` - Command to start the runsvdir service
|
37
|
+
- `node['runit']['stop]` - Command to stop the runsvdir service
|
38
|
+
- `node['runit']['reload']` - Command to reload the runsvdir service
|
39
|
+
|
40
|
+
### Optional Attributes for RHEL systems
|
41
|
+
|
42
|
+
- `node['runit']['prefer_local_yum']` - If `true`, assumes that a `runit` package is available on an already configured local yum repository. By default, the recipe installs the `runit` package from a Package Cloud repository (see below). This is set to the value of `node['runit']['use_package_from_yum']` for backwards compatibility, but otherwise defaults to `false`.
|
43
|
+
|
44
|
+
Recipes
|
45
|
+
-------
|
46
|
+
### default
|
47
|
+
The default recipe installs runit and starts `runsvdir` to supervise the services in runit's service directory (e.g., `/etc/service`).
|
48
|
+
|
49
|
+
On RHEL-family systems, it will install the runit RPM using [Ian Meyer's Package Cloud repository](https://packagecloud.io/imeyer/runit) for runit. This replaces the previous functionality where the RPM was build using his [runit RPM SPEC](https://github.com/imeyer/runit-rpm). However, if the attribute `node['runit']['prefer_local_yum']` is set to `true`, the packagecloud repository creation will be skipped and it is assumed that a `runit` package is available on an otherwise configured (outside this cookbook) local repository.
|
50
|
+
|
51
|
+
On Debian family systems, the runit packages are maintained by the runit author, Gerrit Pape, and the recipe will use that for installation.
|
52
|
+
|
53
|
+
On Gentoo, the runit ebuild package is installed.
|
54
|
+
|
55
|
+
Resource/Provider
|
56
|
+
-----------------
|
57
|
+
This cookbook has a resource, `runit_service`, for managing services under runit. This service subclasses the Chef `service` resource.
|
58
|
+
|
59
|
+
**This resource replaces the runit_service definition. See the CHANGELOG.md file in this cookbook for breaking change information and any actions you may need to take to update cookbooks using runit_service.**
|
60
|
+
|
61
|
+
### Actions
|
62
|
+
- **enable** - enables the service, creating the required run scripts and symlinks. This is the default action.
|
63
|
+
- **start** - starts the service with `sv start`
|
64
|
+
- **stop** - stops the service with `sv stop`
|
65
|
+
- **disable** - stops the service with `sv down` and removes the service symlink
|
66
|
+
- **create** - create the service directory, but don't enable the service with symlink
|
67
|
+
- **restart** - restarts the service with `sv restart`
|
68
|
+
- **reload** - reloads the service with `sv force-reload`
|
69
|
+
- **once** - starts the service with `sv once`.
|
70
|
+
- **hup** - sends the `HUP` signal to the service with `sv hup`
|
71
|
+
- **cont** - sends the `CONT` signal to the service
|
72
|
+
- **term** - sends the `TERM` signal to the service
|
73
|
+
- **kill** - sends the `KILL` signal to the service
|
74
|
+
- **up** - starts the service with `sv up`
|
75
|
+
- **down** - downs the service with `sv down`
|
76
|
+
- **usr1** - sends the `USR1` signal to the service with `sv 1`
|
77
|
+
- **usr2** - sends the `USR2` signal to the service with `sv 2`
|
78
|
+
|
79
|
+
Service management actions are taken with runit's "`sv`" program.
|
80
|
+
|
81
|
+
Read the `sv(8)` [man page](http://smarden.org/runit/sv.8.html) for more information on the `sv` program.
|
82
|
+
|
83
|
+
### Parameter Attributes
|
84
|
+
|
85
|
+
The first three parameters, `sv_dir`, `service_dir`, and `sv_bin` will attempt to use the corresponding node attributes, and fall back to hardcoded default values that match the settings used on Debian platform systems.
|
86
|
+
|
87
|
+
Many of these parameters are only used in the `:enable` action.
|
88
|
+
|
89
|
+
- **sv_dir** - The base "service directory" for the services managed by
|
90
|
+
the resource. By default, this will attempt to use the
|
91
|
+
`node['runit']['sv_dir']` attribute, and falls back to `/etc/sv`.
|
92
|
+
- **service_dir** - The directory where services are symlinked to be
|
93
|
+
supervised by `runsvdir`. By default, this will attempt to use the
|
94
|
+
`node['runit']['service_dir']` attribute, and falls back to
|
95
|
+
`/etc/service`.
|
96
|
+
- **lsb_init_dir** - The directory where an LSB-compliant init script
|
97
|
+
interface will be created. By default, this will attempt to use the
|
98
|
+
`node['runit']['lsb_init_dir']` attribute, and falls back to
|
99
|
+
`/etc/init.d`.
|
100
|
+
- **sv_bin** - The path to the `sv` program binary. This will attempt
|
101
|
+
to use the `node['runit']['sv_bin']` attribute, and falls back to
|
102
|
+
`/usr/bin/sv`.
|
103
|
+
- **service_name** - *Name attribute*. The name of the service. This
|
104
|
+
will be used in the directory of the managed service in the
|
105
|
+
`sv_dir` and `service_dir`.
|
106
|
+
- **sv_timeout** - Override the default `sv` timeout of 7 seconds.
|
107
|
+
- **sv_verbose** - Whether to enable `sv` verbose mode. Default is
|
108
|
+
`false`.
|
109
|
+
- **sv_templates** - If true, the `:enable` action will create the
|
110
|
+
service directory with the appropriate templates. Default is
|
111
|
+
`true`. Set this to `false` if the service has a package that
|
112
|
+
provides its own service directory. See __Usage__ examples.
|
113
|
+
- **options** - Options passed as variables to templates, for
|
114
|
+
compatibility with legacy runit service definition. Default is an
|
115
|
+
empty hash.
|
116
|
+
- **env** - A hash of environment variables with their values as content
|
117
|
+
used in the service's `env` directory. Default is an empty hash. When
|
118
|
+
this hash is non-empty, the contents of the runit service's `env`
|
119
|
+
directory will be managed by Chef in order to conform to the declared
|
120
|
+
state.
|
121
|
+
- **log** - Whether to start the service's logger with svlogd, requires
|
122
|
+
a template `sv-service_name-log-run.erb` to configure the log's run
|
123
|
+
script. Default is true.
|
124
|
+
- **default_logger** - Whether a default `log/run` script should be set
|
125
|
+
up. If true, the default content of the run script will use
|
126
|
+
`svlogd` to write logs to `/var/log/service_name`. Default is false.
|
127
|
+
- **log_dir** - The directory where the `svlogd` log service will run.
|
128
|
+
Used when `default_logger` is `true`. Default is `/var/log/service_name`
|
129
|
+
- **log_size** - The maximum size a log file can grow to before it is
|
130
|
+
automatically rotated. See svlogd(8) for the default value.
|
131
|
+
- **log_num** - The maximum number of log files that will be retained
|
132
|
+
after rotation. See svlogd(8) for the default value.
|
133
|
+
- **log_min** - The minimum number of log files that will be retained
|
134
|
+
after rotation (if svlogd cannot create a new file and the minimum
|
135
|
+
has not been reached, it will block). Default is no minimum.
|
136
|
+
- **log_timeout** - The maximum age a log file can get to before it is
|
137
|
+
automatically rotated, whether it has reached `log_size` or not.
|
138
|
+
Default is no timeout.
|
139
|
+
- **log_processor** - A string containing a path to a program that
|
140
|
+
rotated log files will be fed through. See the **PROCESSOR** section
|
141
|
+
of svlogd(8) for details. Default is no processor.
|
142
|
+
- **log_socket** - An string containing an IP:port pair identifying a UDP
|
143
|
+
socket that log lines will be copied to. Default is none.
|
144
|
+
- **log_prefix** - A string that will be prepended to each line as it
|
145
|
+
is logged. Default is no prefix.
|
146
|
+
- **log_config_append** - A string containing optional additional lines to add
|
147
|
+
to the log service configuration. See svlogd(8) for more details.
|
148
|
+
- **cookbook** - A cookbook where templates are located instead of
|
149
|
+
where the resource is used. Applies for all the templates in the
|
150
|
+
`enable` action.
|
151
|
+
- **check** - whether the service has a check script, requires a
|
152
|
+
template `sv-service_name-check.erb`
|
153
|
+
- **finish** - whether the service has a finish script, requires a
|
154
|
+
template `sv-service_name-finish.erb`
|
155
|
+
- **control** - An array of signals to customize control of the service,
|
156
|
+
see [runsv man page](http://smarden.org/runit/runsv.8.html) on how
|
157
|
+
to use this. This requires that each template be created with the
|
158
|
+
name `sv-service_name-signal.erb`.
|
159
|
+
- **owner** - user that should own the templates created to enable the
|
160
|
+
service
|
161
|
+
- **group** - group that should own the templates created to enable the
|
162
|
+
service
|
163
|
+
- **run_template_name** - alternate filename of the run run script to
|
164
|
+
use replacing `service_name`.
|
165
|
+
- **log_template_name** - alternate filename of the log run script to
|
166
|
+
use replacing `service_name`.
|
167
|
+
- **check_script_template_name** - alternate filename of the check
|
168
|
+
script to use, replacing `service_name`.
|
169
|
+
- **finish_script_template_name** - alternate filename of the finish
|
170
|
+
script to use, replacing `service_name`.
|
171
|
+
- **control_template_names** - a hash of control signals (see *control*
|
172
|
+
above) and their alternate template name(s) replacing
|
173
|
+
`service_name`.
|
174
|
+
- **status_command** - The command used to check the status of the
|
175
|
+
service to see if it is enabled/running (if it's running, it's
|
176
|
+
enabled). This hardcodes the location of the sv program to
|
177
|
+
`/usr/bin/sv` due to the aforementioned cookbook load order.
|
178
|
+
- **restart_on_update** - Whether the service should be restarted when
|
179
|
+
the run script is updated. Defaults to `true`. Set to `false` if
|
180
|
+
the service shouldn't be restarted when the run script is updated.
|
181
|
+
- **start_down** - Set the default state of the runit service to 'down' by creating
|
182
|
+
`<sv_dir>/down` file
|
183
|
+
- **delete_downfile** - Delete previously created `<sv_dir>/down` file
|
184
|
+
|
185
|
+
Unlike previous versions of the cookbook using the `runit_service` definition, the `runit_service` resource can be notified. See __Usage__ examples below.
|
186
|
+
|
187
|
+
|
188
|
+
Usage
|
189
|
+
-----
|
190
|
+
To get runit installed on supported platforms, use `recipe[runit]`. Once it is installed, use the `runit_service` resource to set up services to be managed by runit.
|
191
|
+
|
192
|
+
In order to use the `runit_service` resource in your cookbook(s), each service managed will also need to have `sv-service_name-run.erb` and `sv-service_name-log-run.erb` templates created. If the `log` parameter is false, the log run script isn't created. If the `log` parameter is true, and `default_logger` is also true, the log run
|
193
|
+
script will be created with the default content:
|
194
|
+
|
195
|
+
```bash
|
196
|
+
#!/bin/sh
|
197
|
+
exec svlogd -tt /var/log/service_name
|
198
|
+
```
|
199
|
+
|
200
|
+
### Examples
|
201
|
+
These are example use cases of the `runit_service` resource described above. There are others in the `runit_test` cookbook that is included in the [git repository](https://github.com/hw-cookbooks/runit).
|
202
|
+
|
203
|
+
**Default Example**
|
204
|
+
|
205
|
+
This example uses all the defaults in the `:enable` action to set up the service.
|
206
|
+
|
207
|
+
We'll set up `chef-client` to run as a service under runit, such as is done in the `chef-client` cookbook. This example will be more simple than in that cookbook. First, create the required run template, `chef-client/templates/default/sv-chef-client-run.erb`.
|
208
|
+
|
209
|
+
```bash
|
210
|
+
#!/bin/sh
|
211
|
+
exec 2>&1
|
212
|
+
exec /usr/bin/env chef-client -i 1800 -s 30
|
213
|
+
```
|
214
|
+
|
215
|
+
Then create the required log/run template, `chef-client/templates/default/sv-chef-client-log-run.erb`.
|
216
|
+
|
217
|
+
```bash
|
218
|
+
#!/bin/sh
|
219
|
+
exec svlogd -tt ./main
|
220
|
+
```
|
221
|
+
|
222
|
+
__Note__ This will cause output of the running process to go to `/etc/sv/chef-client/log/main/current`. Some people may not like this, see the following example. This is preserved for compatibility reasons.
|
223
|
+
|
224
|
+
Finally, set up the service in the recipe with:
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
runit_service "chef-client"
|
228
|
+
```
|
229
|
+
|
230
|
+
**Default Logger Example**
|
231
|
+
|
232
|
+
To use a default logger with svlogd which will log to `/var/log/chef-client/current`, instead, use the `default_logger` option.
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
runit_service "chef-client" do
|
236
|
+
default_logger true
|
237
|
+
end
|
238
|
+
```
|
239
|
+
|
240
|
+
**No Log Service**
|
241
|
+
|
242
|
+
If there isn't an appendant log service, set `log` to false, and the log/run script won't be created.
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
runit_service "no-svlog" do
|
246
|
+
log false
|
247
|
+
end
|
248
|
+
```
|
249
|
+
|
250
|
+
**Check Script**
|
251
|
+
|
252
|
+
To create a service that has a check script in its service directory, set the `check` parameter to `true`, and create a `sv-checker-check.erb` template.
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
runit_service "checker" do
|
256
|
+
check true
|
257
|
+
end
|
258
|
+
```
|
259
|
+
|
260
|
+
This will create `/etc/sv/checker/check`.
|
261
|
+
|
262
|
+
**Finish Script**
|
263
|
+
|
264
|
+
To create a service that has a finish script in its service directory, set the `finish` parameter to `true`, and create a `sv-finisher-finish.erb` template.
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
runit_service "finisher" do
|
268
|
+
finish true
|
269
|
+
end
|
270
|
+
```
|
271
|
+
|
272
|
+
This will create `/etc/sv/finisher/finish`.
|
273
|
+
|
274
|
+
**Alternate service directory**
|
275
|
+
|
276
|
+
If the service directory for the managed service isn't the `sv_dir` (`/etc/sv`), then specify it:
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
runit_service "custom_service" do
|
280
|
+
sv_dir "/etc/custom_service/runit"
|
281
|
+
end
|
282
|
+
```
|
283
|
+
|
284
|
+
**No Service Directory**
|
285
|
+
|
286
|
+
If the service to manage has a package that provides its service directory, such as `git-daemon` on Debian systems, set `sv_templates` to false.
|
287
|
+
|
288
|
+
```ruby
|
289
|
+
package "git-daemon-run"
|
290
|
+
|
291
|
+
runit_service "git-daemon" do
|
292
|
+
sv_templates false
|
293
|
+
end
|
294
|
+
```
|
295
|
+
|
296
|
+
This will create the service symlink in `/etc/service`, but it will not manage any templates in the service directory.
|
297
|
+
|
298
|
+
**User Controlled Services**
|
299
|
+
|
300
|
+
To set up services controlled by a non-privileged user, we follow the recommended configuration in the [runit documentation](http://smarden.org/runit/faq.html#user) (Is it possible to allow a user other than root to control a service?).
|
301
|
+
|
302
|
+
Suppose the user's name is floyd, and floyd wants to run floyds-app. Assuming that the floyd user and group are already managed with Chef, create a `runsvdir-floyd` runit_service.
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
runit_service "runsvdir-floyd"
|
306
|
+
```
|
307
|
+
|
308
|
+
Create the `sv-runsvdir-floyd-log-run.erb` template, or add `log false`. Also create the `sv-runsvdir-floyd-run.erb` with the following content:
|
309
|
+
|
310
|
+
```bash
|
311
|
+
#!/bin/sh
|
312
|
+
exec 2>&1
|
313
|
+
exec chpst -ufloyd runsvdir /home/floyd/service
|
314
|
+
```
|
315
|
+
|
316
|
+
Next, create the `runit_service` resource for floyd's app:
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
runit_service "floyds-app" do
|
320
|
+
sv_dir "/home/floyd/sv"
|
321
|
+
service_dir "/home/floyd/service"
|
322
|
+
owner "floyd"
|
323
|
+
group "floyd"
|
324
|
+
end
|
325
|
+
```
|
326
|
+
|
327
|
+
And now floyd can manage the service with sv:
|
328
|
+
|
329
|
+
```text
|
330
|
+
$ id
|
331
|
+
uid=1000(floyd) gid=1001(floyd) groups=1001(floyd)
|
332
|
+
$ sv stop /home/floyd/service/floyds-app/
|
333
|
+
ok: down: /home/floyd/service/floyds-app/: 0s, normally up
|
334
|
+
$ sv start /home/floyd/service/floyds-app/
|
335
|
+
ok: run: /home/floyd/service/floyds-app/: (pid 5287) 0s
|
336
|
+
$ sv status /home/floyd/service/floyds-app/
|
337
|
+
run: /home/floyd/service/floyds-app/: (pid 5287) 13s; run: log: (pid 4691) 726s
|
338
|
+
```
|
339
|
+
|
340
|
+
**Options**
|
341
|
+
|
342
|
+
Next, let's set up memcached under runit with some additional options using the `options` parameter. First, the `memcached/templates/default/sv-memcached-run.erb` template:
|
343
|
+
|
344
|
+
```bash
|
345
|
+
#!/bin/sh
|
346
|
+
exec 2>&1
|
347
|
+
exec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %>
|
348
|
+
```
|
349
|
+
|
350
|
+
Note that the script uses `chpst` (which comes with runit) to set the user option, then starts memcached on the specified memory and port (see below).
|
351
|
+
|
352
|
+
The log/run template, `memcached/templates/default/sv-memcached-log-run.erb`:
|
353
|
+
|
354
|
+
```bash
|
355
|
+
#!/bin/sh
|
356
|
+
exec svlogd -tt ./main
|
357
|
+
```
|
358
|
+
|
359
|
+
Finally, the `runit_service` in our recipe:
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
runit_service "memcached" do
|
363
|
+
options({
|
364
|
+
:memory => node[:memcached][:memory],
|
365
|
+
:port => node[:memcached][:port],
|
366
|
+
:user => node[:memcached][:user]
|
367
|
+
}.merge(params))
|
368
|
+
end
|
369
|
+
```
|
370
|
+
|
371
|
+
This is where the user, port and memory options used in the run template are used.
|
372
|
+
|
373
|
+
**Notifying Runit Services**
|
374
|
+
|
375
|
+
In previous versions of this cookbook where the definition was used, it created a `service` resource that could be notified. With the `runit_service` resource, recipes need to use the full resource name.
|
376
|
+
|
377
|
+
For example:
|
378
|
+
|
379
|
+
```ruby
|
380
|
+
runit_service "my-service"
|
381
|
+
|
382
|
+
template "/etc/my-service.conf" do
|
383
|
+
notifies :restart, "runit_service[my-service]"
|
384
|
+
end
|
385
|
+
```
|
386
|
+
|
387
|
+
Because the resource implements actions for various commands that `sv` can send to the service, any of those actions could be used for notification. For example, `chef-client` supports triggering a Chef run with a USR1 signal.
|
388
|
+
|
389
|
+
```ruby
|
390
|
+
template "/tmp/chef-notifier" do
|
391
|
+
notifies :usr1, "runit_service[chef-client]"
|
392
|
+
end
|
393
|
+
```
|
394
|
+
|
395
|
+
For older implementations of services that used `runit_service` as a definition, but may support alternate service styles, use a conditional, such as based on an attribute:
|
396
|
+
|
397
|
+
```ruby
|
398
|
+
service_to_notify = case node['nginx']['init_style']
|
399
|
+
when "runit"
|
400
|
+
"runit_service[nginx]"
|
401
|
+
else
|
402
|
+
"service[nginx]"
|
403
|
+
end
|
404
|
+
|
405
|
+
template "/etc/nginx/nginx.conf" do
|
406
|
+
notifies :restart, service_to_notify
|
407
|
+
end
|
408
|
+
```
|
409
|
+
|
410
|
+
**More Examples**
|
411
|
+
|
412
|
+
For more examples, see the `runit_test` cookbook's `service` recipe in the [git repository](https://github.com/hw-cookbooks/runit).
|
413
|
+
|
414
|
+
|
415
|
+
License & Authors
|
416
|
+
-----------------
|
417
|
+
- Author:: Adam Jacob <adam@chef.io>
|
418
|
+
- Author:: Joshua Timberman <joshua@chef.io>
|
419
|
+
- Author:: Sean OMeara <sean@chef.io>
|
420
|
+
|
421
|
+
```text
|
422
|
+
Copyright:: 2008-2016, Chef Software, Inc
|
423
|
+
|
424
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
425
|
+
you may not use this file except in compliance with the License.
|
426
|
+
You may obtain a copy of the License at
|
427
|
+
|
428
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
429
|
+
|
430
|
+
Unless required by applicable law or agreed to in writing, software
|
431
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
432
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
433
|
+
See the License for the specific language governing permissions and
|
434
|
+
limitations under the License.
|
435
|
+
```
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup
|
4
|
+
|
5
|
+
require 'rake'
|
6
|
+
require 'foodcritic'
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
|
9
|
+
task default: [:spec]
|
10
|
+
|
11
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
12
|
+
t.pattern = './test/unit{,/*/**}/*_spec.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
FoodCritic::Rake::LintTask.new do |t|
|
16
|
+
t.options = { fail_tags: ['correctness'] }
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'emeril/rake'
|
21
|
+
rescue LoadError
|
22
|
+
puts '>>>>> Emerial gem not loaded, omitting taskes' unless ENV['CI']
|
23
|
+
end
|