Ansible/Jinja2 template for generatlng part of a configuration file for zrepl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if ansible_local.system.fact.zrepl_send_target is defined %} | |
{% set t = ansible_local.system.fact.zrepl_send_target %} | |
{% for e in zfs_filesystems|dict2items|selectattr('value.backup')|map(attribute='value.encrypted')|unique %} | |
- name: {{ t ~ ('-encrypted' if e else '-plain') }} | |
type: push | |
connect: | |
type: tcp | |
address: "{{ t ~ ':' ~ (sink_port_encrypted if e else sink_port_plain) }}" | |
send: | |
encrypted: {{ e|lower }} | |
snapshotting: | |
type: manual | |
filesystems: | |
{% for f in zfs_filesystems|dict2items %} | |
{% if f.value.encrypted == e %} | |
"{{ f.key ~ '<' }}": {{ f.value.backup|lower }} | |
{% endif %} | |
{% endfor %} | |
{% if zrepl_receive is defined %} | |
{% for r in zrepl_receive %} | |
{% if r["encrypted"] == e %} | |
{% for h in groups[ansible_hostname + "_zrepl_clients"] %} | |
{# don't send filesystems back to a client which sent them #} | |
{% if canonical_hostname[h]|default("") != canonical_hostname[t] %} | |
{% set v = hostvars[h] %} | |
{% for f in v["zfs_filesystems"]|dict2items %} | |
{% if f.value.backup and f.value.encrypted == r["encrypted"] %} | |
"{{ r['dest'] ~ '/' ~ v['ansible_hostname'] ~ '/' ~ f.key ~ '<' }}": true | |
{% endif %} | |
{% endfor %} | |
{% endif %} | |
{% endfor %} | |
{% endif %} | |
{% endfor %} | |
{% endif %} | |
pruning: | |
keep_sender: | |
- type: regex | |
regex: ".*" | |
keep_receiver: | |
- type: regex | |
regex: "^zrepl_.*" | |
negate: true | |
- type: grid | |
regex: "^zrepl_.*" | |
grid: 7x24h | 4x168h | 11x672h | |
{% endfor %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment