- name: Install sanoid apt: name: sanoid - name: Create sanoid directory file: path: /etc/sanoid state: directory mode: 0755 - name: Configure sanoid blockinfile: path: /etc/sanoid/sanoid.conf create: yes insertbefore: "BOF" marker: "# {mark} ANSIBLE MANAGED BLOCK SYSTEM #" block: "{{ lookup('file', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-system.conf') }}" - name: Configure sanoid templates blockinfile: path: /etc/sanoid/sanoid.conf insertafter: "EOF" marker: "# {mark} ANSIBLE MANAGED BLOCK TEMPLATES #" block: "{{ lookup('file', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-templates.conf') }}" - name: Configure sanoid for services blockinfile: path: /etc/sanoid/sanoid.conf insertbefore: "# BEGIN ANSIBLE MANAGED BLOCK TEMPLATES #" marker: "# {mark} ANSIBLE MANAGED BLOCK SERVICE {{ service_name }} #" block: "{{ lookup('template', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-service.conf') }}" with_items: "{{ host_services }}" loop_control: loop_var: service_name - name: Copy service for {{ ansible_hostname }} data replication template: src: ./filesystem/{{ ansible_hostname }}/etc/systemd/system/syncoid-volume-data.service.j2 dest: /etc/systemd/system/syncoid-volume-data.service mode: 0644 register: systemd_syncoid_volume_data_service_file - name: SystemD daemon reload systemd: daemon_reload: true when: systemd_syncoid_volume_data_service_file is changed - name: Enable syncoid service systemd: name: syncoid-volume-data.service enabled: yes - name: Enable sanoid service systemd: name: sanoid.timer enabled: yes state: started