rsyncd.conf 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. {%- macro rsyncd_conf(values, tpl) %}
  2. port = {{ values.network.rsync_port.port_number }}
  3. use chroot = yes
  4. pid file = /tmp/rsyncd.pid
  5. max connections = {{ values.rsyncd.max_connections }}
  6. log file = /dev/stdout
  7. {%- for aux in values.rsyncd.aux_params %}
  8. {%- if aux.param in values.consts.reserved_params %}
  9. {%- do tpl.funcs.fail("Parameter [%s] is reserved and cannot be used."|format(aux.param)) -%}
  10. {%- endif %}
  11. {{ "%s = %s"|format(aux.param, aux.value) }}
  12. {%- endfor %}
  13. {%- set mod_names = namespace(x=[]) -%}
  14. {%- for mod in values.rsyncd.rsync_modules if mod.enabled %}
  15. {%- if mod.name in mod_names.x -%}
  16. {%- do tpl.funcs.fail("Module name [%s] is added more than once. Duplicates: [%s]"|format(mod.name, mod_names.x | join(", "))) -%}
  17. {%- endif -%}
  18. {%- do mod_names.x.append(mod.name) %}
  19. {{ "[%s]"|format(mod.name) }}
  20. path = {{ "%s/%s"|format(values.consts.module_base_path, mod.name) }}
  21. max connections = {{ mod.max_connections }}
  22. uid = {{ mod.uid }}
  23. gid = {{ mod.gid }}
  24. {%- if mod.comment %}
  25. comment = {{ mod.comment }}
  26. {%- endif %}
  27. write only = {{ "true" if mod.access_mode == "WO" else "false" }}
  28. read only = {{ "true" if mod.access_mode == "RO" else "false" }}
  29. {%- if mod.hosts_allow %}
  30. hosts allow = {{ mod.hosts_allow | join(" ") }}
  31. {%- endif %}
  32. {%- if mod.hosts_deny %}
  33. hosts deny = {{ mod.hosts_deny | join(" ") }}
  34. {%- endif %}
  35. {%- for aux in mod.aux_params %}
  36. {%- if aux.param in values.consts.reserved_params %}
  37. {%- do tpl.funcs.fail("Parameter [%s] is reserved and cannot be used."|format(aux.param)) -%}
  38. {%- endif %}
  39. {{ "%s = %s"|format(aux.param, aux.value) }}
  40. {%- endfor %}
  41. {%- else %}
  42. {% do tpl.funcs.fail("At least one module must be configured and enabled") %}
  43. {%- endfor %}
  44. {%- endmacro %}