Skip to content

Commit 31febf9

Browse files
committed
Clone defunct rayrod2030/filesystem_cookbook
https://github.com/crowdtap/crowdtap/pull/7168 Unfortunately, [`rayrod2030/filesystem_cookbook`][missing] no longer exists. According to Google's cached indexing, `rayrod2030/filesystem_cookbook` was originally forked from [`atrull/filesystem_cookbook`][cookbook]. This commit clones the missing cookbook from a cached check out on a production machine. [missing]: https://github.com/rayrod2030/filesystem_cookbook [cookbook]: https://github.com/atrull/filesystem_cookbook
0 parents  commit 31febf9

File tree

16 files changed

+980
-0
lines changed

16 files changed

+980
-0
lines changed

Berksfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "http://api.berkshelf.com"
2+
3+
metadata

Berksfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DEPENDENCIES
2+
filesystem
3+
path: .
4+
metadata: true
5+
6+
GRAPH
7+
filesystem (0.9.0)
8+
lvm (~> 1.1.0)
9+
lvm (1.1.0)

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2013 Alex Trull
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
Description
2+
===========
3+
4+
This cookbook exists to generically define and create block device filesystems with the minimum of inputs.
5+
6+
This cookbook supports four main types of block devices:
7+
8+
* normal `device` - drives, ssds, volumes presented by HBAs etc
9+
* device ID `uuid` - mostly found on drives / known block IDs.
10+
* LVM Volume Groups `vg` - found on systems using LVM.
11+
* file-backed `file` - created dynamically and looped back - will not come up on reboot, but we will try to remount existing `file` storage in chef.
12+
13+
We will try to create filesystems in two ways: through keys found in node data under 'filesystems' or by being called directly with the `filesystem` default provider. See the example recipe.
14+
15+
You can also use your own key for a list of filesystems, see the example recipe for an example of this option.
16+
17+
Tools have been listed in the following attribute key : filesystem_tools. This allows for extending the support to other/new filesystems.
18+
19+
Requirements
20+
============
21+
22+
* lvm cookbook when creating logical volumes
23+
* package #{fstype}progs to support your chosen fstype. We provide some defaults, too.
24+
25+
Main Attributes
26+
===============
27+
28+
##### `filesystems`
29+
Hash of filesytems to setup - this is called filesystems because filesystem is already created/managed by ohai (i.e. no s on the end).
30+
##### `node[:filesystems]` keys:
31+
Each filesytem's key is the FS `label`: This explains each key in a filesystems entry. The label must not exceed 12 characters.
32+
33+
We also let you use your own top-level key if you want - see the default recipe and example recipe.
34+
35+
Filesystem Backing Location keys
36+
================================
37+
38+
##### `device`
39+
Path to the device to create the filesystem upon.
40+
##### `uuid`
41+
UUID of the device to create the filesystem upon.
42+
##### `file`
43+
Path to the file-backed storage to be used for a loopback device. `device` must also be present to specify the loopback. If the `file` is not present it will be created, as long as a size is given.
44+
##### `vg`
45+
Name of the LVM volume group use as backing store for a logical volume. If not present it will be created, as long as a size is given.
46+
47+
Each filesystem should be given one of these attributes for it to have a location to be created at.
48+
49+
If none of these are present then we try to find a device at the label itself.
50+
51+
Filesystem Creation Options
52+
===========================
53+
54+
##### `fstype` [ocfs2|ext3|ext4|etc] (default: ext3)
55+
The type of filesystem to be created.
56+
##### `mkfs_options` unique for each filesystem.
57+
Options to pass to mkfs at creation time.
58+
59+
Filesystem Backing Options
60+
==========================
61+
62+
##### `size` 10000 (`file`) or 10%VG|10g (`vg`)
63+
The size, only used for filesystems backed by `vg` and `file` storage. If vg then a number suffixied by the scale [g|m|t|p], if a file then just a number [megabytes].
64+
##### `sparse` Boolean (default: true)
65+
Sparse file creation, used by the `file` storage, by default we use this for speed, but you may not want that.
66+
##### `stripes` optional.
67+
The stripes, only used for filesystems backed by `vg` aka LVM storage.
68+
##### `mirrors` optional.
69+
The mirrors, only used for filesystems backed by `vg` aka LVM storage.
70+
71+
Filesystem Mounting Options
72+
===========================
73+
74+
##### `mount` /path/to/mount
75+
Path to mount the filesystem. (If present we will mount the filesystem - this is rather important)
76+
##### `options` rw,noatime,defaults (default: defaults)
77+
Options to mount with and add to the fstab.
78+
##### `dump` 0|1|2 (default: 0)
79+
Dump entry for fstab
80+
##### `pass` 0|1|2 (default: 0)
81+
Pass entry for fstab
82+
##### `user` name
83+
Owner of the mountpoint, otherwise we use the chef default. We will not try to create users. You should use the users cookbook for that.
84+
##### `group` name
85+
Group of the mountpoint, otherwise we use the chef default. We will not try to create groups. You should write a cookbook to make them nicely.
86+
##### `mode` 775
87+
Mode of the mountpoint, otherwise we use the chef default.
88+
89+
Package and Recipe Options
90+
==========================
91+
92+
##### `package` Package name to install, if specified.
93+
Used to support the filesystem
94+
##### `recipe` Recipe to run, if specified - for future use, not currently supported from the lwrp.
95+
Used to support the filesystem
96+
97+
Atypical Behaviour Modifiers
98+
============================
99+
100+
##### `force` Boolean (default: false)
101+
Set to true we unsafely create filesystems even if they already exist. If there is data it will be lost. Should not use this unless you are quite confident.
102+
##### `nomkfs` Boolean (default: false)
103+
Set to true to disable creation of the filesystem.
104+
##### `nomount` Boolean (default: false)
105+
Set to true to disable mounting of the filesystem.
106+
##### `noenable` Boolean (default: false)
107+
Set to true to disable adding to fstab.
108+
109+
Usage
110+
=====
111+
112+
Keyed filesystem creation:
113+
114+
````JSON
115+
{
116+
"filesystems": {
117+
"testfs1": {
118+
"device": "/dev/sdb",
119+
"mount": "/db",
120+
"fstype": "xfs",
121+
"optons": "noatime,nobarrier",
122+
"mkfs_options": "-d sunit=128,swidth=2048"
123+
},
124+
"applv1": {
125+
"mount": "/logical1",
126+
"fstype": "ext4",
127+
"vg": "standardvg",
128+
"size": "20G"
129+
},
130+
"cluster_01": {
131+
"fstype": "ocfs2",
132+
"package": "ocfs2-tools",
133+
"device": "/dev/mpath/ocfs01",
134+
"mount": "/mnt/test"
135+
},
136+
"filebacked": {
137+
"file": "/mnt/filesystem-on-a-filesystem.file",
138+
"device": "/dev/loop7",
139+
"mount": "/mnt/filesystem-on-a-filesystem",
140+
"size": "20000"
141+
}
142+
}
143+
}
144+
````
145+
146+
Direct LWRP'd creation:
147+
148+
````RUBY
149+
filesystem "label" do
150+
fstype "ext3"
151+
device "/dev/sdb1"
152+
mount "/mnt/littlelabel"
153+
action [:create, :enable, :mount]
154+
end
155+
````
156+
157+
Links
158+
=====
159+
160+
Development is at https://github.com/atrullmdsol/filesystem_cookbook
161+
Opscode community page is at http://community.opscode.com/cookbooks/filesystem
162+
163+
Authors
164+
=======
165+
166+
* Alex Trull <cookbooks.atrullmdsol@trull.org>
167+
* Jesse Nelson <spheromak@gmail.com> source of the original cookbook.

attributes/default.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Cookbook Name:: filesystem
3+
# Attributes:: default
4+
#
5+
# Copyright 2013 Alex Trull
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
# This is used to create the filesystems themselves, see examples in the README.
21+
default[:filesystems] = Hash.new
22+
23+
# These are used to provide sensible default recipes and packages for installing tools for supporting filesystems.
24+
# The format is [:filesystem_tools][:fstype][:package|recipe] = "package1,package2"
25+
default[:filesystem_tools][:ext2][:package] = "e2fsprogs"
26+
default[:filesystem_tools][:ext3][:package] = "e2fsprogs"
27+
default[:filesystem_tools][:ext4][:package] = "e2fsprogs"
28+
default[:filesystem_tools][:xfs][:package] = "xfsprogs"
29+
default[:filesystem_tools][:btrfs][:package] = "btrfs-tools"

libraries/fs.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'pathname'
2+
require 'chef/mixin/shell_out'
3+
4+
module FilesystemMod
5+
include Chef::Mixin::ShellOut
6+
7+
MOUNT_EX_FAIL = 32 unless const_defined?(:MOUNT_EX_FAIL)
8+
9+
# Check to determine if the device is mounted.
10+
def is_mounted?(device)
11+
system("grep -q '#{device}' /proc/mounts")
12+
end
13+
14+
# Check to determine if the mount is frozen.
15+
def is_frozen?(mount)
16+
fields = File.readlines('/proc/mounts').map {|line| line.split}.detect {|fields| fields[1] == mount}
17+
raise "#{mount} not mounted" unless fields
18+
remount = shell_out('mount', '-o', "remount,#{fields[3]}", mount)
19+
if remount.exitstatus == MOUNT_EX_FAIL
20+
true
21+
else
22+
remount.error!
23+
false
24+
end
25+
end
26+
end

libraries/matchers.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if defined?(ChefSpec)
2+
def create_filesystem(resource_name)
3+
ChefSpec::Matchers::ResourceMatcher.new('filesystem', :create, resource_name)
4+
end
5+
6+
def enable_filesystem(resource_name)
7+
ChefSpec::Matchers::ResourceMatcher.new('filesystem', :enable, resource_name)
8+
end
9+
10+
def mount_filesystem(resource_name)
11+
ChefSpec::Matchers::ResourceMatcher.new('filesystem', :mount, resource_name)
12+
end
13+
14+
def freeze_filesystem(resource_name)
15+
ChefSpec::Matchers::ResourceMatcher.new('filesystem', :freeze, resource_name)
16+
end
17+
18+
def unfreeze_filesystem(resource_name)
19+
ChefSpec::Matchers::ResourceMatcher.new('filesystem', :unfreeze, resource_name)
20+
end
21+
end

metadata.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "filesystem",
3+
"description": "Installs/Configures various filesystems",
4+
"long_description": "Description\n===========\n\nThis cookbook exists to generically define and create block device filesystems with the minimum of inputs.\n\nThis cookbook supports four main types of block devices:\n\n* normal `device` - drives, ssds, volumes presented by HBAs etc\n* device ID `uuid` - mostly found on drives / known block IDs.\n* LVM Volume Groups `vg` - found on systems using LVM.\n* file-backed `file` - created dynamically and looped back - will not come up on reboot, but we will try to remount existing `file` storage in chef.\n\nWe will try to create filesystems in two ways: through keys found in node data under 'filesystems' or by being called directly with the `filesystem` default provider. See the example recipe.\n\nYou can also use your own key for a list of filesystems, see the example recipe for an example of this option.\n\nTools have been listed in the following attribute key : filesystem_tools. This allows for extending the support to other/new filesystems.\n\nRequirements\n============\n\n* lvm cookbook when creating logical volumes\n* package #{fstype}progs to support your chosen fstype. We provide some defaults, too.\n\nMain Attributes\n===============\n\n##### `filesystems` \nHash of filesytems to setup - this is called filesystems because filesystem is already created/managed by ohai (i.e. no s on the end).\n##### `node[:filesystems]` keys:\nEach filesytem's key is the FS `label`: This explains each key in a filesystems entry. The label must not exceed 12 characters.\n\nWe also let you use your own top-level key if you want - see the default recipe and example recipe.\n\nFilesystem Backing Location keys\n================================\n\n##### `device`\nPath to the device to create the filesystem upon.\n##### `uuid`\nUUID of the device to create the filesystem upon.\n##### `file`\nPath to the file-backed storage to be used for a loopback device. `device` must also be present to specify the loopback. If the `file` is not present it will be created, as long as a size is given.\n##### `vg`\nName of the LVM volume group use as backing store for a logical volume. If not present it will be created, as long as a size is given.\n\nEach filesystem should be given one of these attributes for it to have a location to be created at. \n\nIf none of these are present then we try to find a device at the label itself.\n\nFilesystem Creation Options\n===========================\n\n##### `fstype` [ocfs2|ext3|ext4|etc] (default: ext3)\nThe type of filesystem to be created.\n##### `mkfs_options` unique for each filesystem.\nOptions to pass to mkfs at creation time.\n\nFilesystem Backing Options\n==========================\n\n##### `size` 10000 (`file`) or 10%VG|10g (`vg`)\nThe size, only used for filesystems backed by `vg` and `file` storage. If vg then a number suffixied by the scale [g|m|t|p], if a file then just a number [megabytes].\n##### `sparse` Boolean (default: true)\nSparse file creation, used by the `file` storage, by default we use this for speed, but you may not want that.\n##### `stripes` optional.\nThe stripes, only used for filesystems backed by `vg` aka LVM storage.\n##### `mirrors` optional.\nThe mirrors, only used for filesystems backed by `vg` aka LVM storage. \n\nFilesystem Mounting Options\n===========================\n\n##### `mount` /path/to/mount\nPath to mount the filesystem. (If present we will mount the filesystem - this is rather important)\n##### `options` rw,noatime,defaults (default: defaults)\nOptions to mount with and add to the fstab.\n##### `dump` 0|1|2 (default: 0)\nDump entry for fstab\n##### `pass` 0|1|2 (default: 0)\nPass entry for fstab\n##### `user` name\nOwner of the mountpoint, otherwise we use the chef default. We will not try to create users. You should use the users cookbook for that.\n##### `group` name\nGroup of the mountpoint, otherwise we use the chef default. We will not try to create groups. You should write a cookbook to make them nicely.\n##### `mode` 775\nMode of the mountpoint, otherwise we use the chef default.\n\nPackage and Recipe Options\n==========================\n\n##### `package` Package name to install, if specified.\nUsed to support the filesystem\n##### `recipe` Recipe to run, if specified - for future use, not currently supported from the lwrp.\nUsed to support the filesystem\n\nAtypical Behaviour Modifiers\n============================\n\n##### `force` Boolean (default: false)\nSet to true we unsafely create filesystems even if they already exist. If there is data it will be lost. Should not use this unless you are quite confident.\n##### `nomkfs` Boolean (default: false)\nSet to true to disable creation of the filesystem.\n##### `nomount` Boolean (default: false)\nSet to true to disable mounting of the filesystem.\n##### `noenable` Boolean (default: false)\nSet to true to disable adding to fstab.\n\nUsage\n=====\n\nKeyed filesystem creation:\n\n````JSON\n{\n \"filesystems\": { \n \"testfs1\": {\n \"device\": \"/dev/sdb\",\n \"mount\": \"/db\",\n \"fstype\": \"xfs\",\n \"optons\": \"noatime,nobarrier\",\n \"mkfs_options\": \"-d sunit=128,swidth=2048\"\n },\n \"applv1\": {\n \"mount\": \"/logical1\",\n \"fstype\": \"ext4\",\n \"vg\": \"standardvg\",\n \"size\": \"20G\"\n },\n \"cluster_01\": {\n \"fstype\": \"ocfs2\",\n \"package\": \"ocfs2-tools\",\n \"device\": \"/dev/mpath/ocfs01\",\n \"mount\": \"/mnt/test\"\n },\n \"filebacked\": {\n \"file\": \"/mnt/filesystem-on-a-filesystem.file\",\n \"device\": \"/dev/loop7\",\n \"mount\": \"/mnt/filesystem-on-a-filesystem\",\n \"size\": \"20000\"\n }\n }\n}\n````\n\nDirect LWRP'd creation:\n\n````RUBY\nfilesystem \"label\" do\n fstype \"ext3\"\n device \"/dev/sdb1\"\n mount \"/mnt/littlelabel\"\n action [:create, :enable, :mount]\nend\n````\n\nLinks\n=====\n\nDevelopment is at https://github.com/atrullmdsol/filesystem_cookbook\nOpscode community page is at http://community.opscode.com/cookbooks/filesystem\n\nAuthors\n=======\n\n* Alex Trull <cookbooks.atrullmdsol@trull.org>\n* Jesse Nelson <spheromak@gmail.com> source of the original cookbook.\n",
5+
"maintainer": "Alex Trull",
6+
"maintainer_email": "cookbooks.atrullmdsol@trull.org",
7+
"license": "Apache 2.0",
8+
"platforms": {
9+
"redhat": ">= 0.0.0",
10+
"centos": ">= 0.0.0",
11+
"xenserver": ">= 0.0.0",
12+
"ubuntu": ">= 0.0.0",
13+
"debian": ">= 0.0.0",
14+
"scientific": ">= 0.0.0",
15+
"amazon": ">= 0.0.0"
16+
},
17+
"dependencies": {
18+
"lvm": "~> 1.1.0"
19+
},
20+
"recommendations": {
21+
},
22+
"suggestions": {
23+
},
24+
"conflicting": {
25+
},
26+
"providing": {
27+
},
28+
"replacing": {
29+
},
30+
"attributes": {
31+
"filesystems": {
32+
"description": "Filesystems to be created and/or mounted",
33+
"type": "hash",
34+
"required": "recommended",
35+
"choice": [
36+
37+
],
38+
"calculated": false,
39+
"recipes": [
40+
41+
]
42+
}
43+
},
44+
"groupings": {
45+
},
46+
"recipes": {
47+
},
48+
"version": "0.9.1",
49+
"source_url": "",
50+
"issues_url": ""
51+
}

0 commit comments

Comments
 (0)