- name: setup drbd gather_facts: no hosts: "{{target}}" become: "{{become_var}}" tasks: - name: define nodes set_fact: nodes: "{{ groups[cluster] }}" - debug: var=nodes - name: drbd overal config ansible.builtin.copy: src: drbd.conf dest: /etc/drbd.conf # todo - keep nodes defined from ansible or switch to dnc.conf? # note - this is a manual sync script that is being used for initial setup # ideally not necessary once DNC is up - name: sync drbd resources script ansible.builtin.copy: content: | #!/bin/bash # CONFIGURED BY ANSIBLE nodes="{{ nodes | join(' ') }}" # do not sync /data/, that's shared storage already for node in $nodes; do [[ $node = $HOSTNAME ]] && continue rsync -av --delete /etc/drbd.d/ $node:/etc/drbd.d/ # do not sync /data_local/guests/ rsync -av --delete /data_local/kernels/ $node:/data_local/kernels/ rsync -av --delete /data_local/templates/ $node:/data_local/templates/ done; unset node dest: /root/sync mode: "0755" - name: enable storage and drbd at boot-time ansible.builtin.copy: content: | #!/bin/bash # CONFIGURED BY ANSIBLE echo rc.local PATH is $PATH {% if storage == 'zfs' %} echo -n loading zfs ... modprobe zfs && echo done echo -n loading smith pool ... zpool import smith -N && echo done echo found zvols: find /dev/zvol/ -mindepth 2 | grep '\-part' {% endif %} # self-verbose #drbdadm up -v all /etc/rc.d/rc.drbd start dest: /etc/rc.d/rc.local mode: "0755" - name: shutdown drbd resources properly ansible.builtin.copy: content: | #!/bin/bash # CONFIGURED BY ANSIBLE echo rc.local_shutdown PATH is $PATH # self-verbose #drbdadm down -v all /etc/rc.d/rc.drbd stop dest: /etc/rc.d/rc.local_shutdown mode: "0755"