From 8454af55dd8f8259897af9b2ddd67fb9b2dae9e3 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 20 Nov 2016 12:57:57 +0000 Subject: [PATCH] Assigns device for gluster brick volume automatically in terraform --- contrib/terraform/openstack/kubespray.tf | 1 - contrib/terraform/terraform.py | 9 +++++++++ roles/glusterfs/tasks/main.yml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/terraform/openstack/kubespray.tf b/contrib/terraform/openstack/kubespray.tf index 783f68a83..a895fe6f8 100644 --- a/contrib/terraform/openstack/kubespray.tf +++ b/contrib/terraform/openstack/kubespray.tf @@ -153,7 +153,6 @@ resource "openstack_compute_instance_v2" "glusterfs_node_no_floating_ip" { } volume { volume_id = "${element(openstack_blockstorage_volume_v2.glusterfs_volume.*.id, count.index)}" - device = "/dev/vdb" } provisioner "local-exec" { command = "sed s/USER/${var.ssh_user}/ contrib/terraform/openstack/ansible_bastion_template.txt | sed s/BASTION_ADDRESS/${element(openstack_networking_floatingip_v2.k8s_master.*.address, 0)}/ > contrib/terraform/openstack/group_vars/gfs-cluster.yml" diff --git a/contrib/terraform/terraform.py b/contrib/terraform/terraform.py index e8434c883..2ef5cda95 100755 --- a/contrib/terraform/terraform.py +++ b/contrib/terraform/terraform.py @@ -347,6 +347,15 @@ def openstack_host(resource, module_name): if 'metadata.ssh_user' in raw_attrs: attrs['ansible_ssh_user'] = raw_attrs['metadata.ssh_user'] + if 'volume.#' in raw_attrs.keys() and int(raw_attrs['volume.#']) > 0: + device_index = 1 + for key, value in raw_attrs.items(): + match = re.search("^volume.*.device$", key) + if match: + attrs['disk_volume_device_'+str(device_index)] = value + device_index += 1 + + # attrs specific to Mantl attrs.update({ 'consul_dc': _clean_dc(attrs['metadata'].get('dc', module_name)), diff --git a/roles/glusterfs/tasks/main.yml b/roles/glusterfs/tasks/main.yml index dae215814..346b01398 100644 --- a/roles/glusterfs/tasks/main.yml +++ b/roles/glusterfs/tasks/main.yml @@ -18,7 +18,7 @@ # Mount external volumes - name: mounting new xfs filesystem - mount: "name={{ gluster_volume_node_mount_dir }} src=/dev/vdb fstype=xfs state=mounted" + mount: "name={{ gluster_volume_node_mount_dir }} src={{ disk_volume_device_1 }} fstype=xfs state=mounted" # Setup/install tasks. - include: setup-RedHat.yml