Added experimental kvm-guest role
Can handle adding volumes with DRBD over LVM and provision new virtual machines using these volumes.
This commit is contained in:
parent
dc162ec67f
commit
05c509cd9a
|
@ -0,0 +1,19 @@
|
|||
- name: 'primary DRBD was changed'
|
||||
command: 'drbdadm adjust all'
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
|
||||
- name: 'secondary DRBD was changed'
|
||||
command: 'drbdadm adjust all'
|
||||
delegate_to: "{{ kvm-guest__secondary }}"
|
||||
|
||||
- name: 'new primary DRBD'
|
||||
command: ""drbdadm create-md '{{ kvm-guest__name }}'""
|
||||
delegate_to "{{ kvm-guest__primary }}"
|
||||
listen: 'primary DRBD was changed'
|
||||
when: kvm-guest__drbd_primary_ressource.stat.exists == False
|
||||
|
||||
- name: 'new secondary DRBD'
|
||||
command: ""drbdadm create-md '{{ kvm-guest__name }}'""
|
||||
delegate_to "{{ kvm-guest__secondary }}"
|
||||
listen: 'secondary DRBD was changed'
|
||||
when: kvm-guest__drbd_secondary_ressource.stat.exists == False
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
|
||||
- name: "create logical volumes for {{ kvm-guest__name }} on kvm cloud"
|
||||
block:
|
||||
- name: "create logical volumes on {{ kvm-guest__primary }}"
|
||||
lvol:
|
||||
vg: "{{ item.group }}"'
|
||||
lv: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
with_items: "{{ kvm-guest__volumes }}"
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
|
||||
- name: 'create logical volumes on {{ kvm-guest__secondary }}"'
|
||||
lvol:
|
||||
vg: "{{ item.group }}"'
|
||||
lv: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
with_items: "{{ kvm-guest__volumes }}"
|
||||
delegate_to: "{{ kvm-guest__secondary }}"
|
||||
|
||||
- name: "create DRBD ressources for {{ kvm-guest__name }} on kvm cloud"
|
||||
block:
|
||||
- name: "check if DRBD ressource definition on {{ kvm-guest__primary }} exists"
|
||||
stat:
|
||||
path: "/etc/drbd.d/{{ kvm-guest__name }}.res"
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
register: kvm-guest__drbd_primary_ressource
|
||||
|
||||
- name: "check if DRBD ressource definition on {{ kvm-guest__secondary }} exists"
|
||||
stat:
|
||||
path: "/etc/drbd.d/{{ kvm-guest__name }}.res"
|
||||
delegate_to: "{{ kvm-guest__secondary }}"
|
||||
register: kvm-guest__drbd_secondary_ressource
|
||||
|
||||
- name: "update DRBD ressource definition on {{ kvm-guest__primary }}"
|
||||
template:
|
||||
src: 'drbd_vm.res.j2'
|
||||
dest: "/etc/drbd.d/{{ kvm-guest__name }}.res"
|
||||
validate: 'drbdadm -d adjust all'
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
notifies: 'primary DRBD was changed'
|
||||
|
||||
- name: 'update DRBD ressource definition on {{ kvm-guest__secondary }}"'
|
||||
template:
|
||||
src: 'drbd_vm.res.j2'
|
||||
dest: "/etc/drbd.d/{{ kvm-guest__name }}.res"
|
||||
validate: 'drbdadm -d adjust all'
|
||||
delegate_to: "{{ kvm-guest__secondary }}"
|
||||
notifies: 'secondary DRBD was changed'
|
||||
|
||||
- name: 'synchronize DRBD ressources'
|
||||
command: "drbdadm -- --overwrite-data-of-peer primary {{ kvm-guest__name }}"
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
|
||||
- name: "Define {{ kvm-guest__name }}"
|
||||
virt:
|
||||
command: define
|
||||
xml: "{{ lookup('template', 'vm_template.xml.j2') }}"
|
||||
autostart: true
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
|
||||
- name: "create logical volumes for {{ kvm-guest__name }} on kvm cloud"
|
||||
block:
|
||||
- name: "create logical volumes on {{ kvm-guest__primary }}"
|
||||
lvol:
|
||||
vg: "{{ item.group }}"'
|
||||
lv: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
with_items: "{{ kvm-guest__volumes }}"
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
register: kvm-guest_primary_lvm
|
||||
|
||||
- name: 'create logical volumes on {{ kvm-guest__secondary }}"'
|
||||
lvol:
|
||||
vg: "{{ item.group }}"'
|
||||
lv: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
with_items: "{{ kvm-guest__volumes }}"
|
||||
delegate_to: "{{ kvm-guest__secondary }}"
|
||||
when: kvm-guest_primary_lvm
|
||||
|
||||
- name: "create DRBD ressources for {{ kvm-guest__name }} on kvm cloud"
|
||||
block:
|
||||
- name: "create DRBD ressource on {{ kvm-guest__primary }}"
|
||||
template:
|
||||
src: 'drbd_vm.res.j2'
|
||||
dest: "/etc/drbd.d/{{ kvm-guest__name }}.res"
|
||||
delegate_to: "{{ kvm-guest__primary }}"
|
||||
register: kvm-guest_primary_lvm
|
||||
|
||||
- name: 'create DRBD ressource on {{ kvm-guest__secondary }}"'
|
||||
template:
|
||||
src: 'drbd_vm.res.j2'
|
||||
dest: "/etc/drbd.d/{{ kvm-guest__name }}.res"
|
||||
delegate_to: "{{ kvm-guest__secondary }}"
|
||||
when: kvm-guest_primary_lvm
|
|
@ -0,0 +1,28 @@
|
|||
resource "{{ kvm-guest__name }}" {
|
||||
net {
|
||||
cram-hmac-alg "sha1";
|
||||
shared-secret "{{ kvm-guest__drbd_secret }}";
|
||||
# Si pas de lien dedié 10G, passer en protocol A
|
||||
# Et desactiver allow-two-primaries;
|
||||
protocol C;
|
||||
allow-two-primaries;
|
||||
# Tuning perf.
|
||||
#max-buffers 8000;
|
||||
#max-epoch-size 8000;
|
||||
#sndbuf-size 0;
|
||||
}
|
||||
{% for volume in kvm-guest__volumes %}
|
||||
volume {{ loop.index }} {
|
||||
device minor {{ volume.device }};
|
||||
disk /dev/{{ volume.group }}/{{ volume.name }};
|
||||
meta-disk internal;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
on {{ kvm-guest__primary }} {
|
||||
address {{ kvm-guest__primary_ip }}:{{ kvm-guest__port }};
|
||||
}
|
||||
on {{ kvm-guest__secondary }} {
|
||||
address {{ kvm-guest__secondary_ip }}:{{ kvm-guest__port }};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue