From 8425b3c733a8e7f66168ca9fe09c3d448a503e2e Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 15 Mar 2017 09:44:27 +0000 Subject: [PATCH] Configure LVM and Docker direct-lvm storage on the controllers --- ansible/group_vars/all/controllers | 48 ++++++++++++++++++++++++++++++ ansible/group_vars/all/seed | 13 ++++++-- ansible/group_vars/controllers/lvm | 2 +- ansible/lvm.yml | 10 +++++++ etc/kayobe/controllers.yml | 35 ++++++++++++++++++++++ etc/kayobe/seed.yml | 10 ++++++- 6 files changed, 113 insertions(+), 5 deletions(-) diff --git a/ansible/group_vars/all/controllers b/ansible/group_vars/all/controllers index e93ed2533..eda317abb 100644 --- a/ansible/group_vars/all/controllers +++ b/ansible/group_vars/all/controllers @@ -5,3 +5,51 @@ # User with which to access the controllers via SSH during bootstrap, in order # to setup the Kayobe user account. controller_bootstrap_user: "{{ lookup('env', 'USER') }}" + +############################################################################### +# Controller node LVM configuration. + +# List of controller volume groups. See mrlesmithjr.manage-lvm role for +# format. +controller_lvm_groups: "{{ controller_lvm_groups_default + controller_lvm_groups_extra }}" + +# Default list of controller volume groups. See mrlesmithjr.manage-lvm role for +# format. +controller_lvm_groups_default: + - "{{ controller_lvm_group_data }}" + +# Additional list of controller volume groups. See mrlesmithjr.manage-lvm role +# for format. +controller_lvm_groups_extra: [] + +# Controller LVM volume group for data. See mrlesmithjr.manage-lvm role for +# format. +controller_lvm_group_data: + vgname: data + disks: "{{ controller_lvm_group_data_disks | join(',') }}" + create: True + lvnames: "{{ controller_lvm_group_data_lvs }}" + +# List of disks for use by controller LVM data volume group. Default to an +# invalid value to require configuration. +controller_lvm_group_data_disks: + - changeme + +# List of LVM logical volumes for the data volume group. +controller_lvm_group_data_lvs: + - "{{ controller_lvm_group_data_lv_docker_volumes }}" + +# Docker volumes LVM backing volume. +controller_lvm_group_data_lv_docker_volumes: + lvname: docker-volumes + size: "{{ controller_lvm_group_data_lv_docker_volumes_size }}" + create: True + filesystem: "{{ controller_lvm_group_data_lv_docker_volumes_fs }}" + mount: True + mntp: /var/lib/docker/volumes + +# Size of docker volumes LVM backing volume. +controller_lvm_group_data_lv_docker_volumes_size: 75%VG + +# Filesystem for docker volumes LVM backing volume. ext4 allows for shrinking. +controller_lvm_group_data_lv_docker_volumes_fs: ext4 diff --git a/ansible/group_vars/all/seed b/ansible/group_vars/all/seed index cec19f8f3..2530538cd 100644 --- a/ansible/group_vars/all/seed +++ b/ansible/group_vars/all/seed @@ -1,12 +1,19 @@ --- ############################################################################### -# Seed node configuration. +# Seed node LVM configuration. -# List of seed VM LVM volume groups. See mrlesmithjr.manage-lvm role for +# List of seed volume groups. See mrlesmithjr.manage-lvm role for format. +seed_lvm_groups: "{{ seed_lvm_groups_default + seed_lvm_groups_extra }}" + +# Default list of seed volume groups. See mrlesmithjr.manage-lvm role for # format. -seed_lvm_groups: +seed_lvm_groups_default: - "{{ seed_lvm_group_data }}" +# Additional list of seed volume groups. See mrlesmithjr.manage-lvm role for +# format. +seed_lvm_groups_extra: [] + # Seed LVM volume group for data. See mrlesmithjr.manage-lvm role for format. seed_lvm_group_data: vgname: data diff --git a/ansible/group_vars/controllers/lvm b/ansible/group_vars/controllers/lvm index 345f13793..f8ac5fba7 100644 --- a/ansible/group_vars/controllers/lvm +++ b/ansible/group_vars/controllers/lvm @@ -3,4 +3,4 @@ # Controller node LVM configuration. # List of LVM volume groups. -lvm_groups: [] +lvm_groups: "{{ controller_lvm_groups }}" diff --git a/ansible/lvm.yml b/ansible/lvm.yml index 7d1d3f0d8..7bd3f716a 100644 --- a/ansible/lvm.yml +++ b/ansible/lvm.yml @@ -1,6 +1,16 @@ --- - name: Ensure LVM configuration is applied hosts: seed:controllers + pre_tasks: + - name: Fail if the LVM physical disks have not been configured + fail: + msg: > + The physical disk list has not been configured for volume + {{ item.vgname }}. Ensure that each volume group in 'lvm_groups' + has a valid 'disks' list. + with_items: "{{ lvm_groups | default([]) }}" + when: + - "{{ not item.disks | default([]) or 'changeme' in item.disks | default([]) }}" roles: - role: mrlesmithjr.manage-lvm manage_lvm: True diff --git a/etc/kayobe/controllers.yml b/etc/kayobe/controllers.yml index 16bc199e0..41641b40a 100644 --- a/etc/kayobe/controllers.yml +++ b/etc/kayobe/controllers.yml @@ -15,6 +15,41 @@ # List of extra networks to which controller nodes are attached. #controller_extra_network_interfaces: +############################################################################### +# Controller node LVM configuration. + +# List of controller volume groups. See mrlesmithjr.manage-lvm role for +# format. +#controller_lvm_groups: + +# Default list of controller volume groups. See mrlesmithjr.manage-lvm role for +# format. +#controller_lvm_groups_default: + +# Additional list of controller volume groups. See mrlesmithjr.manage-lvm role +# for format. +#controller_lvm_groups_extra: + +# Controller LVM volume group for data. See mrlesmithjr.manage-lvm role for +# format. +#controller_lvm_group_data: + +# List of disks for use by controller LVM data volume group. Default to an +# invalid value to require configuration. +#controller_lvm_group_data_disks: + +# List of LVM logical volumes for the data volume group. +#controller_lvm_group_data_lvs: + +# Docker volumes LVM backing volume. +#controller_lvm_group_data_lv_docker_volumes: + +# Size of docker volumes LVM backing volume. +#controller_lvm_group_data_lv_docker_volumes_size: + +# Filesystem for docker volumes LVM backing volume. ext4 allows for shrinking. +#controller_lvm_group_data_lv_docker_volumes_fs: + ############################################################################### # Dummy variable to allow Ansible to accept this file. workaround_ansible_issue_8743: yes diff --git a/etc/kayobe/seed.yml b/etc/kayobe/seed.yml index 4d7081bba..82b623a18 100644 --- a/etc/kayobe/seed.yml +++ b/etc/kayobe/seed.yml @@ -13,10 +13,18 @@ ############################################################################### # LVM configuration. -# List of seed VM LVM volume groups. See mrlesmithjr.manage-lvm role for +# List of seed volume groups. See mrlesmithjr.manage-lvm role for # format. #seed_lvm_groups: +# Default list of seed volume groups. See mrlesmithjr.manage-lvm role for +# format. +#seed_lvm_groups_default: + +# Additional list of seed volume groups. See mrlesmithjr.manage-lvm role +# for format. +#seed_lvm_groups_extra: + # Seed LVM volume group for data. See mrlesmithjr.manage-lvm role for format. #seed_lvm_group_data: