From 4e13bb102bc29d5f4f2370d0b090502fd7099a39 Mon Sep 17 00:00:00 2001 From: SirishaGuduru Date: Mon, 1 Aug 2016 14:25:27 +0530 Subject: [PATCH] Playbook to mount drives in swift object nodes Currently in any of the release of openstack-ansible there is no role to mount the drives in swift object server nodes. This can now be a part of openstack-ansible-ops as this is all operational stuff. If the user knows the type of the file system that is going to be used, we can mount the drives as well using the playbook without manual intervention. Doc is also modified according to the playbook. Modified the lines according to the comments given. Change-Id: I991ee4891253d2f99703c80e350df21c43db01e8 Closes-Bug: #1535536 --- .../playbooks/swift_storage_mount_drives.yml | 85 +++++++++++++++++++ doc/source/swift_storage_mount_drives.rst | 27 ++++++ 2 files changed, 112 insertions(+) create mode 100644 ansible_tools/playbooks/swift_storage_mount_drives.yml create mode 100644 doc/source/swift_storage_mount_drives.rst diff --git a/ansible_tools/playbooks/swift_storage_mount_drives.yml b/ansible_tools/playbooks/swift_storage_mount_drives.yml new file mode 100644 index 00000000..e5ba0097 --- /dev/null +++ b/ansible_tools/playbooks/swift_storage_mount_drives.yml @@ -0,0 +1,85 @@ +--- +# Copyright 2016, @WalmartLabs, Bangalore. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +#This role is to mount the drives in swift object node and is optional. +#This gets executed only when the flag 'mount_drives' in swift configuration +#file is set to true. + +- name: Mount drives in swift object servers + hosts: swift_hosts + user: root + vars: + device_path: 'opt' + filesystem_to_mount: 'xfs' + tasks: + - name: "Set swift_vars if undefined" + set_fact: + swift_vars: "{}" + when: swift_vars is not defined + + - name: "Create mount point directory" + file: + state: "directory" + path: "{{ swift_vars.mount_point | default(swift.mount_point) }}/{{ item.name }}" + with_items: swift_vars.drives + when: swift_vars.drives is defined + + - name: "Create mount point directory" + file: + state: "directory" + path: "{{ swift_vars.mount_point | default(swift.mount_point) }}/{{ item.name }}" + with_items: swift.drives + when: swift_vars.drives is not defined + + - name: "Format to {{ filesystem_to_mount }}" + filesystem: + fstype: "{{ filesystem_to_mount }}" + dev: "/{{ device_path }}/{{ item.name }}" + force: "yes" + with_items: swift_vars.drives + when: swift_vars.drives is defined + + - name: "Format to {{ filesystem_to_mount }}" + filesystem: + fstype: "{{ filesystem_to_mount }}" + dev: "/{{ device_path }}/{{ item.name }}" + force: "yes" + with_items: swift.drives + when: swift_vars.drives is not defined + + - name: "Mount the storage" + mount: + name: "{{ swift_vars.mount_point | default(swift.mount_point) }}/{{ item.name }}" + src: "/{{ device_path }}/{{ item.name }}" + fstype: "{{ filesystem_to_mount }}" + opts: "rw,noatime,nodiratime,nobarrier,inode64,delaylog,logbufs=8,logbsize=256k,allocsize=4M" + dump: 0 + passno: 0 + state: "mounted" + with_items: swift_vars.drives + when: swift_vars.drives is defined + + - name: "Mount the storage" + mount: + name: "{{ swift_vars.mount_point | default(swift.mount_point) }}/{{ item.name }}" + src: "/{{ device_path }}/{{ item.name }}" + fstype: "{{ filesystem_to_mount }}" + opts: "rw,noatime,nodiratime,nobarrier,inode64,delaylog,logbufs=8,logbsize=256k,allocsize=4M" + dump: 0 + passno: 0 + state: "mounted" + with_items: swift.drives + when: swift_vars.drives is not defined diff --git a/doc/source/swift_storage_mount_drives.rst b/doc/source/swift_storage_mount_drives.rst new file mode 100644 index 00000000..28a11ba9 --- /dev/null +++ b/doc/source/swift_storage_mount_drives.rst @@ -0,0 +1,27 @@ +=================================================================== +OpenStack-Ansible Swift Mount drives in storage nodes Documentation +=================================================================== + +Playbook under the folder + +ansible_tools/playbooks/swift_storage_mount_drives.yml + +This playbook mainly helps to mount the drives in swift object nodes, +if not prior mounted and formatted. + +The steps it performs are: + - Format the disks mentioned in swift configuration file + in openstack-ansible to the filesystem mentioned in the playbook + (editable by the end-user in playbook). + - Mount the drives to the the device-path(mentioned in the playbook + and is editable) like /dev/sdb or /opt/sdb or /openstack/sdb. + +This removes the manual effort of mounting and makes the swift users +life easier by mounting the devices. + +How to run the playbook +======================= + +ansible-playbook ansible_tools/playbooks/swift_storage_mount_drives.yml + +This will mount all the drives in the swift object nodes