-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Emilien Kenler
committed
May 14, 2015
0 parents
commit da1455d
Showing
7 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Wizcorp | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Disk | ||
==== | ||
|
||
This role allows you to format extra disks and attach them to different mount points. | ||
|
||
You can use it to move the data of different services to another disk. | ||
|
||
Configuration | ||
------------- | ||
|
||
### Inventory | ||
|
||
Because the configuration for additional disks must be stored using the YAML | ||
syntax, you have to write it in a `group_vars` directory. | ||
|
||
```yaml | ||
# inventory/group_vars/GROUP_NAME | ||
disk_additional_disks: | ||
- disk: /dev/sdb | ||
fstype: ext4 | ||
mount_options: defaults | ||
mount: /data | ||
``` | ||
* `disk` is the device, you want to mount. | ||
* `fstype` allows you to choose the filesystem to use with the new disk. | ||
* `mount_options` allows you to specify custom mount options. | ||
* `mount` is the directory where the new disk should be mounted. | ||
|
||
The following filesystems are currently supported: | ||
- [ext2](http://en.wikipedia.org/wiki/Ext2) | ||
- [ext3](http://en.wikipedia.org/wiki/Ext3) | ||
- [ext4](http://en.wikipedia.org/wiki/Ext4) | ||
|
||
How it works | ||
------------ | ||
|
||
It uses `sfdisk` to partition the disk with a single primary partition spanning the entire disk. | ||
The specified filesystem will then be created with `mkfs`. | ||
Finally the new partition will be mounted to the specified mount path. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
galaxy_info: | ||
author: Emilien Kenler <[email protected]> | ||
description: This role allows setting up extra disks and their mount points | ||
company: Wizcorp K.K. | ||
license: MIT | ||
min_ansible_version: 1.8.1 | ||
platforms: | ||
- name: EL | ||
versions: | ||
- 6 | ||
- 7 | ||
- name: Debian | ||
versions: | ||
- wheezy | ||
- name: Ubuntu | ||
versions: | ||
- all | ||
categories: | ||
- system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- name: "apt-get update" | ||
shell: | | ||
apt-get update | ||
tags: | ||
- disk | ||
- pkgs | ||
|
||
- name: "Install util-linux" | ||
apt: > | ||
name=util-linux | ||
state=present | ||
tags: | ||
- disk | ||
- pkgs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
##################### | ||
# Ubuntu | ||
- include: ubuntu.yml | ||
when: ansible_distribution == 'Ubuntu' and disk_additional_disks | ||
|
||
##################### | ||
# Debian | ||
- include: debian.yml | ||
when: ansible_distribution == 'Debian' and disk_additional_disks | ||
|
||
- name: "Check if the specified filesystem is supported" | ||
fail: > | ||
msg="Unsupported filesystem '{{ item.fstype }}' for disk '{{ item.disk }}'" | ||
when: item.fstype not in disk_supported_fs_types | ||
with_items: disk_additional_disks | ||
tags: | ||
- disk | ||
|
||
- name: "Format additional disks" | ||
shell: | | ||
executable=/bin/bash | ||
if | ||
[ -e {{ item.disk }} ] | ||
then | ||
[ -b {{ item.disk }}1 ] || echo 0,,8e | sfdisk {{ item.disk }} | ||
[[ `blkid | grep {{ item.disk }}1 | grep {{ item.fstype }}` ]] || mkfs.{{ item.fstype }} {{ item.disk }}1 | ||
fi | ||
with_items: disk_additional_disks | ||
tags: | ||
- disk | ||
|
||
- name: "Ensure the /data directory exists" | ||
file: > | ||
path={{ item.mount }} | ||
owner=root | ||
group=root | ||
state=directory | ||
with_items: disk_additional_disks | ||
tags: | ||
- disk | ||
|
||
- name: "Mount additional disk" | ||
mount: > | ||
name={{ item.mount }} | ||
fstype={{ item.fstype }} | ||
opts={{ item.mount_options }} | ||
passno=0 | ||
src={{ item.disk }}1 | ||
state=mounted | ||
with_items: disk_additional_disks | ||
tags: | ||
- disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- name: "apt-get update" | ||
shell: | | ||
apt-get update | ||
tags: | ||
- disk | ||
- pkgs | ||
|
||
- name: "Install util-linux" | ||
apt: > | ||
name=util-linux | ||
state=present | ||
tags: | ||
- disk | ||
- pkgs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
disk_supported_fs_types: | ||
- ext2 | ||
- ext3 | ||
- ext4 |