Merge lp:~gnuoy/charms/trusty/swift-storage/add-nrpe-checks-fix-rsyncd-conf into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by Liam Young
Status: Merged
Merged at revision: 55
Proposed branch: lp:~gnuoy/charms/trusty/swift-storage/add-nrpe-checks-fix-rsyncd-conf
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 451 lines (+160/-69)
10 files modified
hooks/charmhelpers/contrib/charmsupport/nrpe.py (+94/-5)
hooks/charmhelpers/contrib/charmsupport/rsync.py (+0/-32)
hooks/charmhelpers/contrib/charmsupport/volumes.py (+5/-2)
hooks/charmhelpers/contrib/openstack/context.py (+1/-0)
hooks/charmhelpers/contrib/openstack/neutron.py (+8/-2)
hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg (+2/-0)
hooks/charmhelpers/contrib/openstack/utils.py (+6/-0)
hooks/charmhelpers/fetch/__init__.py (+8/-1)
hooks/swift_storage_hooks.py (+12/-27)
hooks/swift_storage_utils.py (+24/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/swift-storage/add-nrpe-checks-fix-rsyncd-conf
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+246161@code.launchpad.net

Description of the change

Add nrpe support. Based on branch from bradm with a few tweaks

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #670 swift-storage-next for gnuoy mp246161
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/670/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #699 swift-storage-next for gnuoy mp246161
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/699/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #855 swift-storage-next for gnuoy mp246161
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/855/

Revision history for this message
Liam Young (gnuoy) wrote :

<jamespage> gnuoy, as they are re-syncs + tweaks to the nrpe stuff in the charms, I'm happy to give a conditional +1 across the board based on osci checking things out OK
<gnuoy> jamespage, I'll take that! thanks
...
<gnuoy> jamespage, osci is still working through. But on the subject of those mps, does your +1 stand for branches with no amulet tests?
<jamespage> gnuoy, yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/charmhelpers/contrib/charmsupport/nrpe.py'
--- hooks/charmhelpers/contrib/charmsupport/nrpe.py 2014-10-30 05:52:15 +0000
+++ hooks/charmhelpers/contrib/charmsupport/nrpe.py 2015-01-12 14:03:13 +0000
@@ -18,6 +18,7 @@
18 log,18 log,
19 relation_ids,19 relation_ids,
20 relation_set,20 relation_set,
21 relations_of_type,
21)22)
2223
23from charmhelpers.core.host import service24from charmhelpers.core.host import service
@@ -54,6 +55,12 @@
54# juju-myservice-055# juju-myservice-0
55# If you're running multiple environments with the same services in them56# If you're running multiple environments with the same services in them
56# this allows you to differentiate between them.57# this allows you to differentiate between them.
58# nagios_servicegroups:
59# default: ""
60# type: string
61# description: |
62# A comma-separated list of nagios servicegroups.
63# If left empty, the nagios_context will be used as the servicegroup
57#64#
58# 3. Add custom checks (Nagios plugins) to files/nrpe-external-master65# 3. Add custom checks (Nagios plugins) to files/nrpe-external-master
59#66#
@@ -138,7 +145,7 @@
138 log('Check command not found: {}'.format(parts[0]))145 log('Check command not found: {}'.format(parts[0]))
139 return ''146 return ''
140147
141 def write(self, nagios_context, hostname):148 def write(self, nagios_context, hostname, nagios_servicegroups=None):
142 nrpe_check_file = '/etc/nagios/nrpe.d/{}.cfg'.format(149 nrpe_check_file = '/etc/nagios/nrpe.d/{}.cfg'.format(
143 self.command)150 self.command)
144 with open(nrpe_check_file, 'w') as nrpe_check_config:151 with open(nrpe_check_file, 'w') as nrpe_check_config:
@@ -150,16 +157,21 @@
150 log('Not writing service config as {} is not accessible'.format(157 log('Not writing service config as {} is not accessible'.format(
151 NRPE.nagios_exportdir))158 NRPE.nagios_exportdir))
152 else:159 else:
153 self.write_service_config(nagios_context, hostname)160 self.write_service_config(nagios_context, hostname,
161 nagios_servicegroups)
154162
155 def write_service_config(self, nagios_context, hostname):163 def write_service_config(self, nagios_context, hostname,
164 nagios_servicegroups=None):
156 for f in os.listdir(NRPE.nagios_exportdir):165 for f in os.listdir(NRPE.nagios_exportdir):
157 if re.search('.*{}.cfg'.format(self.command), f):166 if re.search('.*{}.cfg'.format(self.command), f):
158 os.remove(os.path.join(NRPE.nagios_exportdir, f))167 os.remove(os.path.join(NRPE.nagios_exportdir, f))
159168
169 if not nagios_servicegroups:
170 nagios_servicegroups = nagios_context
171
160 templ_vars = {172 templ_vars = {
161 'nagios_hostname': hostname,173 'nagios_hostname': hostname,
162 'nagios_servicegroup': nagios_context,174 'nagios_servicegroup': nagios_servicegroups,
163 'description': self.description,175 'description': self.description,
164 'shortname': self.shortname,176 'shortname': self.shortname,
165 'command': self.command,177 'command': self.command,
@@ -183,6 +195,10 @@
183 super(NRPE, self).__init__()195 super(NRPE, self).__init__()
184 self.config = config()196 self.config = config()
185 self.nagios_context = self.config['nagios_context']197 self.nagios_context = self.config['nagios_context']
198 if 'nagios_servicegroups' in self.config:
199 self.nagios_servicegroups = self.config['nagios_servicegroups']
200 else:
201 self.nagios_servicegroups = 'juju'
186 self.unit_name = local_unit().replace('/', '-')202 self.unit_name = local_unit().replace('/', '-')
187 if hostname:203 if hostname:
188 self.hostname = hostname204 self.hostname = hostname
@@ -208,7 +224,8 @@
208 nrpe_monitors = {}224 nrpe_monitors = {}
209 monitors = {"monitors": {"remote": {"nrpe": nrpe_monitors}}}225 monitors = {"monitors": {"remote": {"nrpe": nrpe_monitors}}}
210 for nrpecheck in self.checks:226 for nrpecheck in self.checks:
211 nrpecheck.write(self.nagios_context, self.hostname)227 nrpecheck.write(self.nagios_context, self.hostname,
228 self.nagios_servicegroups)
212 nrpe_monitors[nrpecheck.shortname] = {229 nrpe_monitors[nrpecheck.shortname] = {
213 "command": nrpecheck.command,230 "command": nrpecheck.command,
214 }231 }
@@ -217,3 +234,75 @@
217234
218 for rid in relation_ids("local-monitors"):235 for rid in relation_ids("local-monitors"):
219 relation_set(relation_id=rid, monitors=yaml.dump(monitors))236 relation_set(relation_id=rid, monitors=yaml.dump(monitors))
237
238
239def get_nagios_hostcontext(relation_name='nrpe-external-master'):
240 """
241 Query relation with nrpe subordinate, return the nagios_host_context
242
243 :param str relation_name: Name of relation nrpe sub joined to
244 """
245 for rel in relations_of_type(relation_name):
246 if 'nagios_hostname' in rel:
247 return rel['nagios_host_context']
248
249
250def get_nagios_hostname(relation_name='nrpe-external-master'):
251 """
252 Query relation with nrpe subordinate, return the nagios_hostname
253
254 :param str relation_name: Name of relation nrpe sub joined to
255 """
256 for rel in relations_of_type(relation_name):
257 if 'nagios_hostname' in rel:
258 return rel['nagios_hostname']
259
260
261def get_nagios_unit_name(relation_name='nrpe-external-master'):
262 """
263 Return the nagios unit name prepended with host_context if needed
264
265 :param str relation_name: Name of relation nrpe sub joined to
266 """
267 host_context = get_nagios_hostcontext(relation_name)
268 if host_context:
269 unit = "%s:%s" % (host_context, local_unit())
270 else:
271 unit = local_unit()
272 return unit
273
274
275def add_init_service_checks(nrpe, services, unit_name):
276 """
277 Add checks for each service in list
278
279 :param NRPE nrpe: NRPE object to add check to
280 :param list services: List of services to check
281 :param str unit_name: Unit name to use in check description
282 """
283 for svc in services:
284 upstart_init = '/etc/init/%s.conf' % svc
285 sysv_init = '/etc/init.d/%s' % svc
286 if os.path.exists(upstart_init):
287 nrpe.add_check(
288 shortname=svc,
289 description='process check {%s}' % unit_name,
290 check_cmd='check_upstart_job %s' % svc
291 )
292 elif os.path.exists(sysv_init):
293 cronpath = '/etc/cron.d/nagios-service-check-%s' % svc
294 cron_file = ('*/5 * * * * root '
295 '/usr/local/lib/nagios/plugins/check_exit_status.pl '
296 '-s /etc/init.d/%s status > '
297 '/var/lib/nagios/service-check-%s.txt\n' % (svc,
298 svc)
299 )
300 f = open(cronpath, 'w')
301 f.write(cron_file)
302 f.close()
303 nrpe.add_check(
304 shortname=svc,
305 description='process check {%s}' % unit_name,
306 check_cmd='check_status_file.py -f '
307 '/var/lib/nagios/service-check-%s.txt' % svc,
308 )
220309
=== removed file 'hooks/charmhelpers/contrib/charmsupport/rsync.py'
--- hooks/charmhelpers/contrib/charmsupport/rsync.py 2014-11-06 07:38:43 +0000
+++ hooks/charmhelpers/contrib/charmsupport/rsync.py 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1"""
2Support for rsyncd.conf and using fragments dropped inside /etc/rsync-juju.d
3"""
4import os
5
6from charmhelpers.core.host import (
7 mkdir,
8)
9
10def setup_rsync():
11 '''
12 Ensure all directories required for rsync exist with correct permissions.
13 '''
14 root_dirs = [
15 '/etc/rsync-juju.d',
16 ]
17 [mkdir(d, owner='root', group='root') for d in root_dirs
18 if not os.path.isdir(d)]
19
20 rsyncd_base = """uid = nobody
21gid = nogroup
22pid file = /var/run/rsyncd.pid
23syslog facility = daemon
24socket options = SO_KEEPALIVE
25
26&include /etc/rsync-juju.d
27"""
28
29 f = open('/etc/rsyncd.conf','w')
30 f.write(rsyncd_base)
31 f.close()
32
330
=== modified file 'hooks/charmhelpers/contrib/charmsupport/volumes.py'
--- hooks/charmhelpers/contrib/charmsupport/volumes.py 2014-10-30 05:52:15 +0000
+++ hooks/charmhelpers/contrib/charmsupport/volumes.py 2015-01-12 14:03:13 +0000
@@ -2,7 +2,8 @@
2Functions for managing volumes in juju units. One volume is supported per unit.2Functions for managing volumes in juju units. One volume is supported per unit.
3Subordinates may have their own storage, provided it is on its own partition.3Subordinates may have their own storage, provided it is on its own partition.
44
5Configuration stanzas:5Configuration stanzas::
6
6 volume-ephemeral:7 volume-ephemeral:
7 type: boolean8 type: boolean
8 default: true9 default: true
@@ -20,7 +21,8 @@
20 is 'true' and no volume-map value is set. Use 'juju set' to set a21 is 'true' and no volume-map value is set. Use 'juju set' to set a
21 value and 'juju resolved' to complete configuration.22 value and 'juju resolved' to complete configuration.
2223
23Usage:24Usage::
25
24 from charmsupport.volumes import configure_volume, VolumeConfigurationError26 from charmsupport.volumes import configure_volume, VolumeConfigurationError
25 from charmsupport.hookenv import log, ERROR27 from charmsupport.hookenv import log, ERROR
26 def post_mount_hook():28 def post_mount_hook():
@@ -34,6 +36,7 @@
34 after_change=post_mount_hook)36 after_change=post_mount_hook)
35 except VolumeConfigurationError:37 except VolumeConfigurationError:
36 log('Storage could not be configured', ERROR)38 log('Storage could not be configured', ERROR)
39
37'''40'''
3841
39# XXX: Known limitations42# XXX: Known limitations
4043
=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
--- hooks/charmhelpers/contrib/openstack/context.py 2014-12-15 09:35:34 +0000
+++ hooks/charmhelpers/contrib/openstack/context.py 2015-01-12 14:03:13 +0000
@@ -491,6 +491,7 @@
491 ctxt['haproxy_client_timeout'] = config('haproxy-client-timeout')491 ctxt['haproxy_client_timeout'] = config('haproxy-client-timeout')
492492
493 if config('prefer-ipv6'):493 if config('prefer-ipv6'):
494 ctxt['ipv6'] = True
494 ctxt['local_host'] = 'ip6-localhost'495 ctxt['local_host'] = 'ip6-localhost'
495 ctxt['haproxy_host'] = '::'496 ctxt['haproxy_host'] = '::'
496 ctxt['stat_port'] = ':::8888'497 ctxt['stat_port'] = ':::8888'
497498
=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
--- hooks/charmhelpers/contrib/openstack/neutron.py 2014-12-10 20:28:59 +0000
+++ hooks/charmhelpers/contrib/openstack/neutron.py 2015-01-12 14:03:13 +0000
@@ -152,9 +152,15 @@
152 database=config('neutron-database'),152 database=config('neutron-database'),
153 relation_prefix='neutron',153 relation_prefix='neutron',
154 ssl_dir=NEUTRON_CONF_DIR)],154 ssl_dir=NEUTRON_CONF_DIR)],
155 'services': ['calico-compute', 'bird', 'neutron-dhcp-agent'],155 'services': ['calico-felix',
156 'bird',
157 'neutron-dhcp-agent',
158 'nova-api-metadata'],
156 'packages': [[headers_package()] + determine_dkms_package(),159 'packages': [[headers_package()] + determine_dkms_package(),
157 ['calico-compute', 'bird', 'neutron-dhcp-agent']],160 ['calico-compute',
161 'bird',
162 'neutron-dhcp-agent',
163 'nova-api-metadata']],
158 'server_packages': ['neutron-server', 'calico-control'],164 'server_packages': ['neutron-server', 'calico-control'],
159 'server_services': ['neutron-server']165 'server_services': ['neutron-server']
160 }166 }
161167
=== modified file 'hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg'
--- hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2014-12-10 20:28:59 +0000
+++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2015-01-12 14:03:13 +0000
@@ -38,7 +38,9 @@
38{% for service, ports in service_ports.items() -%}38{% for service, ports in service_ports.items() -%}
39frontend tcp-in_{{ service }}39frontend tcp-in_{{ service }}
40 bind *:{{ ports[0] }}40 bind *:{{ ports[0] }}
41 {% if ipv6 -%}
41 bind :::{{ ports[0] }}42 bind :::{{ ports[0] }}
43 {% endif -%}
42 {% for frontend in frontends -%}44 {% for frontend in frontends -%}
43 acl net_{{ frontend }} dst {{ frontends[frontend]['network'] }}45 acl net_{{ frontend }} dst {{ frontends[frontend]['network'] }}
44 use_backend {{ service }}_{{ frontend }} if net_{{ frontend }}46 use_backend {{ service }}_{{ frontend }} if net_{{ frontend }}
4547
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2014-12-10 20:28:59 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2015-01-12 14:03:13 +0000
@@ -53,6 +53,7 @@
53 ('saucy', 'havana'),53 ('saucy', 'havana'),
54 ('trusty', 'icehouse'),54 ('trusty', 'icehouse'),
55 ('utopic', 'juno'),55 ('utopic', 'juno'),
56 ('vivid', 'kilo'),
56])57])
5758
5859
@@ -64,6 +65,7 @@
64 ('2013.2', 'havana'),65 ('2013.2', 'havana'),
65 ('2014.1', 'icehouse'),66 ('2014.1', 'icehouse'),
66 ('2014.2', 'juno'),67 ('2014.2', 'juno'),
68 ('2015.1', 'kilo'),
67])69])
6870
69# The ugly duckling71# The ugly duckling
@@ -84,6 +86,7 @@
84 ('2.0.0', 'juno'),86 ('2.0.0', 'juno'),
85 ('2.1.0', 'juno'),87 ('2.1.0', 'juno'),
86 ('2.2.0', 'juno'),88 ('2.2.0', 'juno'),
89 ('2.2.1', 'kilo'),
87])90])
8891
89DEFAULT_LOOPBACK_SIZE = '5G'92DEFAULT_LOOPBACK_SIZE = '5G'
@@ -289,6 +292,9 @@
289 'juno': 'trusty-updates/juno',292 'juno': 'trusty-updates/juno',
290 'juno/updates': 'trusty-updates/juno',293 'juno/updates': 'trusty-updates/juno',
291 'juno/proposed': 'trusty-proposed/juno',294 'juno/proposed': 'trusty-proposed/juno',
295 'kilo': 'trusty-updates/kilo',
296 'kilo/updates': 'trusty-updates/kilo',
297 'kilo/proposed': 'trusty-proposed/kilo',
292 }298 }
293299
294 try:300 try:
295301
=== modified file 'hooks/charmhelpers/fetch/__init__.py'
--- hooks/charmhelpers/fetch/__init__.py 2014-12-10 20:28:59 +0000
+++ hooks/charmhelpers/fetch/__init__.py 2015-01-12 14:03:13 +0000
@@ -64,9 +64,16 @@
64 'trusty-juno/updates': 'trusty-updates/juno',64 'trusty-juno/updates': 'trusty-updates/juno',
65 'trusty-updates/juno': 'trusty-updates/juno',65 'trusty-updates/juno': 'trusty-updates/juno',
66 'juno/proposed': 'trusty-proposed/juno',66 'juno/proposed': 'trusty-proposed/juno',
67 'juno/proposed': 'trusty-proposed/juno',
68 'trusty-juno/proposed': 'trusty-proposed/juno',67 'trusty-juno/proposed': 'trusty-proposed/juno',
69 'trusty-proposed/juno': 'trusty-proposed/juno',68 'trusty-proposed/juno': 'trusty-proposed/juno',
69 # Kilo
70 'kilo': 'trusty-updates/kilo',
71 'trusty-kilo': 'trusty-updates/kilo',
72 'trusty-kilo/updates': 'trusty-updates/kilo',
73 'trusty-updates/kilo': 'trusty-updates/kilo',
74 'kilo/proposed': 'trusty-proposed/kilo',
75 'trusty-kilo/proposed': 'trusty-proposed/kilo',
76 'trusty-proposed/kilo': 'trusty-proposed/kilo',
70}77}
7178
72# The order of this list is very important. Handlers should be listed in from79# The order of this list is very important. Handlers should be listed in from
7380
=== modified file 'hooks/swift_storage_hooks.py'
--- hooks/swift_storage_hooks.py 2015-01-09 10:07:27 +0000
+++ hooks/swift_storage_hooks.py 2015-01-12 14:03:13 +0000
@@ -14,7 +14,8 @@
14 register_configs,14 register_configs,
15 save_script_rc,15 save_script_rc,
16 setup_storage,16 setup_storage,
17 assert_charm_supports_ipv617 assert_charm_supports_ipv6,
18 setup_rsync,
18)19)
1920
20from charmhelpers.core.hookenv import (21from charmhelpers.core.hookenv import (
@@ -24,7 +25,6 @@
24 relation_get,25 relation_get,
25 relation_set,26 relation_set,
26 relations_of_type,27 relations_of_type,
27 local_unit,
28)28)
2929
30from charmhelpers.fetch import (30from charmhelpers.fetch import (
@@ -42,9 +42,7 @@
42from charmhelpers.contrib.network.ip import (42from charmhelpers.contrib.network.ip import (
43 get_ipv6_addr43 get_ipv6_addr
44)44)
45from charmhelpers.contrib.charmsupport.nrpe import NRPE45from charmhelpers.contrib.charmsupport import nrpe
46
47from charmhelpers.contrib.charmsupport.rsync import setup_rsync
4846
49from distutils.dir_util import mkpath47from distutils.dir_util import mkpath
5048
@@ -120,6 +118,8 @@
120@hooks.hook('nrpe-external-master-relation-joined')118@hooks.hook('nrpe-external-master-relation-joined')
121@hooks.hook('nrpe-external-master-relation-changed')119@hooks.hook('nrpe-external-master-relation-changed')
122def update_nrpe_config():120def update_nrpe_config():
121 # python-dbus is used by check_upstart_job
122 apt_install('python-dbus')
123 log('Refreshing nrpe checks')123 log('Refreshing nrpe checks')
124 if not os.path.exists(NAGIOS_PLUGINS):124 if not os.path.exists(NAGIOS_PLUGINS):
125 mkpath(NAGIOS_PLUGINS)125 mkpath(NAGIOS_PLUGINS)
@@ -132,37 +132,22 @@
132 rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'sudo',132 rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'sudo',
133 'swift-storage'),133 'swift-storage'),
134 os.path.join(SUDOERS_D, 'swift-storage'))134 os.path.join(SUDOERS_D, 'swift-storage'))
135
135 # Find out if nrpe set nagios_hostname136 # Find out if nrpe set nagios_hostname
136 hostname = None137 hostname = nrpe.get_nagios_hostname()
137 host_context = None138 current_unit = nrpe.get_nagios_unit_name()
138 for rel in relations_of_type('nrpe-external-master'):139 nrpe_setup = nrpe.NRPE(hostname=hostname)
139 if 'nagios_hostname' in rel:
140 hostname = rel['nagios_hostname']
141 host_context = rel['nagios_host_context']
142 break
143 nrpe = NRPE(hostname=hostname)
144
145 if host_context:
146 current_unit = "%s:%s" % (host_context, local_unit())
147 else:
148 current_unit = local_unit()
149140
150 # check the rings and replication141 # check the rings and replication
151 nrpe.add_check(142 nrpe_setup.add_check(
152 shortname='swift_storage',143 shortname='swift_storage',
153 description='Check swift storage ring hashes and replication'144 description='Check swift storage ring hashes and replication'
154 ' {%s}' % current_unit,145 ' {%s}' % current_unit,
155 check_cmd='check_swift_storage.py {}'.format(146 check_cmd='check_swift_storage.py {}'.format(
156 config('nagios-check-params'))147 config('nagios-check-params'))
157 )148 )
158 # check services are running149 nrpe.add_init_service_checks(nrpe_setup, SWIFT_SVCS, current_unit)
159 for service in SWIFT_SVCS:150 nrpe_setup.write()
160 nrpe.add_check(
161 shortname=service,
162 description='service {%s}' % current_unit,
163 check_cmd='check_swift_service %s' % service,
164 )
165 nrpe.write()
166151
167152
168def main():153def main():
169154
=== modified file 'hooks/swift_storage_utils.py'
--- hooks/swift_storage_utils.py 2015-01-09 10:07:27 +0000
+++ hooks/swift_storage_utils.py 2015-01-12 14:03:13 +0000
@@ -293,3 +293,27 @@
293 rsyncd_conf += fragment.read()293 rsyncd_conf += fragment.read()
294 with open('/etc/rsyncd.conf', 'w') as f:294 with open('/etc/rsyncd.conf', 'w') as f:
295 f.write(rsyncd_conf)295 f.write(rsyncd_conf)
296
297
298def setup_rsync():
299 '''
300 Ensure all directories required for rsync exist with correct permissions.
301 '''
302 root_dirs = [
303 '/etc/rsync-juju.d',
304 ]
305 [mkdir(d, owner='root', group='root') for d in root_dirs
306 if not os.path.isdir(d)]
307
308 rsyncd_base = """uid = nobody
309gid = nogroup
310pid file = /var/run/rsyncd.pid
311syslog facility = daemon
312socket options = SO_KEEPALIVE
313
314&include /etc/rsync-juju.d
315"""
316
317 f = open('/etc/rsyncd.conf', 'w')
318 f.write(rsyncd_base)
319 f.close()

Subscribers

People subscribed via source and target branches