12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- {%- macro rsyncd_conf(values, tpl) %}
- port = {{ values.network.rsync_port.port_number }}
- use chroot = yes
- pid file = /tmp/rsyncd.pid
- max connections = {{ values.rsyncd.max_connections }}
- log file = /dev/stdout
- {%- for aux in values.rsyncd.aux_params %}
- {%- if aux.param in values.consts.reserved_params %}
- {%- do tpl.funcs.fail("Parameter [%s] is reserved and cannot be used."|format(aux.param)) -%}
- {%- endif %}
- {{ "%s = %s"|format(aux.param, aux.value) }}
- {%- endfor %}
- {%- set mod_names = namespace(x=[]) -%}
- {%- for mod in values.rsyncd.rsync_modules if mod.enabled %}
- {%- if mod.name in mod_names.x -%}
- {%- do tpl.funcs.fail("Module name [%s] is added more than once. Duplicates: [%s]"|format(mod.name, mod_names.x | join(", "))) -%}
- {%- endif -%}
- {%- do mod_names.x.append(mod.name) %}
- {{ "[%s]"|format(mod.name) }}
- path = {{ "%s/%s"|format(values.consts.module_base_path, mod.name) }}
- max connections = {{ mod.max_connections }}
- uid = {{ mod.uid }}
- gid = {{ mod.gid }}
- {%- if mod.comment %}
- comment = {{ mod.comment }}
- {%- endif %}
- write only = {{ "true" if mod.access_mode == "WO" else "false" }}
- read only = {{ "true" if mod.access_mode == "RO" else "false" }}
- {%- if mod.hosts_allow %}
- hosts allow = {{ mod.hosts_allow | join(" ") }}
- {%- endif %}
- {%- if mod.hosts_deny %}
- hosts deny = {{ mod.hosts_deny | join(" ") }}
- {%- endif %}
- {%- for aux in mod.aux_params %}
- {%- if aux.param in values.consts.reserved_params %}
- {%- do tpl.funcs.fail("Parameter [%s] is reserved and cannot be used."|format(aux.param)) -%}
- {%- endif %}
- {{ "%s = %s"|format(aux.param, aux.value) }}
- {%- endfor %}
- {%- else %}
- {% do tpl.funcs.fail("At least one module must be configured and enabled") %}
- {%- endfor %}
- {%- endmacro %}
|