Browse Source

Add playbook for ganeti

Emmanuel Bouthenot 9 years ago
parent
commit
8ac0f4ef64

+ 2 - 0
roles/hypervisor/defaults/main.yml

@@ -6,4 +6,6 @@ with_xen: False
 # memory amount in MB
 xendom0_mem: 1024
 
+with_ganeti: False
+
 # vim: ft=yaml

+ 2 - 0
roles/hypervisor/handlers/ganeti.yml

@@ -0,0 +1,2 @@
+- name: 'Rebuild initramfs'
+  command: update-initramfs -u -k all

+ 2 - 1
roles/hypervisor/handlers/main.yml

@@ -1 +1,2 @@
-- include: xen.yml
+- include: 'xen.yml'
+- include: 'ganeti.yml'

+ 63 - 0
roles/hypervisor/tasks/ganeti.yml

@@ -0,0 +1,63 @@
+- name: 'Install Ganeti related packages'
+  apt:
+    pkg: '{{ item }}'
+    install_recommends: 'no'
+    state: 'installed'
+    update_cache: 'yes'
+  with_items:
+    - 'ganeti'
+    - 'ganeti-instance-debootstrap'
+    - 'drbd-utils'
+  when: with_ganeti
+
+- name: 'Install ganeti instances templates for debootstrap'
+  template:
+    src: 'ganeti/instance-debootstrap/{{ item }}.conf.j2'
+    dest: '/etc/ganeti/instance-debootstrap/variants/{{ item }}.conf'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  with_items:
+    - 'jessie'
+  when: with_ganeti
+
+- name: 'Enable ganeti instances templates for debootstrap'
+  lineinfile:
+    dest: '/etc/ganeti/instance-debootstrap/variants.list'
+    regexp: '^{{ item }}$'
+    line: '{{ item }}'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  with_items:
+    - 'jessie'
+  when: with_ganeti
+
+- name: 'Exclude DRBD devices from lvm devices while using ganeti'
+  blockinfile:
+    dest: '/etc/lvm/lvm.conf'
+    marker: '    # ======= {mark} Exclude DRBD devices while using ganeti (managed by ansible) ======'
+    content: '    filter = ["r|/dev/drbd[0-9]+|"]'
+    insertbefore: '^\s*# Exclude the cdrom drive'
+  when: with_ganeti
+
+- name: 'Add options for kernel modules while using ganeti'
+  template:
+    src: 'ganeti/kernel/modprobe.conf.j2'
+    dest: '/etc/modprobe.d/ganeti.conf'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  notify:
+    - 'Rebuild initramfs'
+  when: with_ganeti
+
+- name: 'Add kernel modules to load while using ganeti'
+  template:
+    src: 'ganeti/kernel/modules.conf.j2'
+    dest: '/etc/modules-load.d/ganeti.conf'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  when: with_ganeti
+

+ 2 - 1
roles/hypervisor/tasks/main.yml

@@ -1 +1,2 @@
-- include: xen.yml
+- include: 'xen.yml'
+- include: 'ganeti.yml'

+ 85 - 0
roles/hypervisor/templates/ganeti/instance-debootstrap/jessie.conf.j2

@@ -0,0 +1,85 @@
+{% if ansible_prolog -%}
+{% from 'templates/ansible/prolog.j2' import prolog with context %}
+{{ prolog() }}
+{% endif -%}
+#
+# Ganeti deboostrap instance for Debian Jessie 8
+#
+
+# PROXY: if non-null, use this as an http(s)-proxy in order to speed
+# up non-cached installs or provide internet access if not directly
+# possible; not that if not set, debootstrap might still use a
+# system-wide proxy setting if it is exported in the ganeti-noded
+# daemon environment (but the node daemon environment is cleaned up
+# and not exported starting with Ganeti 2.5)
+# PROXY="http://proxy.example.com:3128/"
+
+# MIRROR: do not customize MIRROR if you want to be able to install
+# both debian and ubuntu, since they have different defaults; or
+# customize it before each install
+MIRROR="http://httpredir.debian.org/debian"
+
+# ARCH: define ARCH only if you want a different architecture than the
+# current one; the known use case is to install a 32-bit instance on a
+# 64-bit node; choose either "i386" or "amd64":
+ARCH="amd64"
+
+# SUITE: change suite to any of the ones supported by deboostrap; this
+# could be unstable, etch, etc.:
+SUITE="jessie"
+
+# EXTRA_PKGS: depending on the suite and architecture you are using, different
+# extra packages are needed for different hypervisors. For example:
+#
+# Xen, for squeeze i386:
+# EXTRA_PKGS="linux-image-xen-686,libc6-xen"
+# Xen, for wheezy i386:
+# EXTRA_PKGS="libc6-xen"
+# Xen, for squeeze amd64:
+# EXTRA_PKGS="linux-image-xen-amd64"
+# KVM, for squeeze/wheezy i386:
+# EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-686"
+# KVM, for squeeze/wheezy amd64:
+# EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-amd64"
+EXTRA_PKGS="linux-image-amd64,python-apt,lsb-release,openssh-server"
+
+# COMPONENTS: if defined, overrides the default debootstrap components
+# ("main"); when not defined, it will not passed to debootstrap
+# Debian example:
+# COMPONENTS="main,contrib,non-free"
+# Ubuntu example:
+# COMPONENTS="main,universe"
+# Default:
+COMPONENTS="main"
+
+# CUSTOMIZE_DIR: a directory containing scripts to customize the installation.
+# The scripts are executed using run-parts
+# By default /etc/ganeti/instance-debootstrap/hooks
+# CUSTOMIZE_DIR="/etc/ganeti/instance-debootstrap/hooks"
+
+# GENERATE_CACHE: if set to yes (the default), create new cache files;
+# any other value will disable the generation of cache files (but they
+# will still be used if they exist)
+GENERATE_CACHE="yes"
+
+# CLEAN_CACHE: should be set to the number of days after which to
+# clean the cache; the default is 14 (two weeks); to disable cache
+# cleaning, set it to an empty value ("")
+CLEAN_CACHE="7"
+
+# PARTITION_STYLE: whether and how the target device should be partitioned.
+# Allowed values:
+# 'none': just format the device, but don't partition it
+# 'msdos': install an msdos partition table on the device, with a single
+#          partition on it
+# (more styles may be added in the future)
+# The default is "msdos" from ganeti 2.0 onwards, but none if installing under
+# Ganeti 1.2 (os api version 5)
+# PARTITION_STYLE="none"
+
+# PARTITION_ALIGNMENT: the alignment of the partitions in sectors
+# (512B); this defaults to 1MiB to give grub enough space for
+# embedding and for better alignment with modern media (HDDs and
+# SSDs), feel free to increase it if your media has even bigger
+# allocation blocks
+# PARTITION_ALIGNMENT=2048

+ 10 - 0
roles/hypervisor/templates/ganeti/kernel/modprobe.conf.j2

@@ -0,0 +1,10 @@
+{% if ansible_prolog -%}
+{% from 'templates/ansible/prolog.j2' import prolog with context %}
+{{ prolog() }}
+{% endif -%}
+
+#
+# Options kernel modules while using ganeti
+#
+
+options drbd minor_count=255 usermode_helper=/bin/true

+ 11 - 0
roles/hypervisor/templates/ganeti/kernel/modules.conf.j2

@@ -0,0 +1,11 @@
+{% if ansible_prolog -%}
+{% from 'templates/ansible/prolog.j2' import prolog with context %}
+{{ prolog() }}
+{% endif -%}
+
+#
+# Kernel modules to load while using ganeti
+#
+
+drbd
+