summaryrefslogtreecommitdiffstats
path: root/manifests/brick.pp
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2012-07-27 19:32:06 -0400
committerJames Shubin <james@shubin.ca>2012-07-27 19:32:06 -0400
commit00c004343a0d40ec3c12ab0285dac6eb45533732 (patch)
treeabe8e07e242b2991a4ce1be75d4b37222bd46a04 /manifests/brick.pp
parent954431b60f54040007f044a078a6ce66cac11242 (diff)
downloadpuppet-gluster-00c004343a0d40ec3c12ab0285dac6eb45533732.tar.gz
puppet-gluster-00c004343a0d40ec3c12ab0285dac6eb45533732.tar.xz
puppet-gluster-00c004343a0d40ec3c12ab0285dac6eb45533732.zip
Sadly, I could not read my own code, so I had to revert back to tabs. Sorry bodepd!
Diffstat (limited to 'manifests/brick.pp')
-rw-r--r--manifests/brick.pp315
1 files changed, 158 insertions, 157 deletions
diff --git a/manifests/brick.pp b/manifests/brick.pp
index 71cf450..82dae7d 100644
--- a/manifests/brick.pp
+++ b/manifests/brick.pp
@@ -16,163 +16,164 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
define gluster::brick(
- $dev, # /dev/sdc, /dev/disk/by-id/scsi-36003048007e14f0014ca2743150a5471
- $fsuuid, # set a uuid for this fs
- $labeltype = '', # gpt
- $fstype = '', # xfs
- $xfs_inode64 = false,
- $xfs_nobarrier = false,
- $ro = false, # use for emergencies only- you want your fs rw
- $force = false, # if true, this will overwrite any xfs fs it sees, useful for rebuilding gluster and wiping data. NOTE: there are other safeties in place to stop this.
- $areyousure = false # do you allow puppet to do dangerous things ?
+ $dev, # /dev/sdc, /dev/disk/by-id/scsi-36003048007e14f0014ca2743150a5471
+ $fsuuid, # set a uuid for this fs
+ $labeltype = '', # gpt
+ $fstype = '', # xfs
+ $xfs_inode64 = false,
+ $xfs_nobarrier = false,
+ $ro = false, # use for emergencies only- you want your fs rw
+ $force = false, # if true, this will overwrite any xfs fs it sees, useful for rebuilding gluster and wiping data. NOTE: there are other safeties in place to stop this.
+ $areyousure = false # do you allow puppet to do dangerous things ?
) {
- # eg: annex1.example.com:/storage1a
- $split = split($name, ':') # do some $name parsing
- $host = $split[0] # host fqdn
- $mount = $split[1] # brick mount
-
- if ! ( "${host}:${mount}" == "${name}" ) {
- fail('The brick $name must match a $host-$mount pattern.')
- }
-
- Gluster::Host[$host] -> Gluster::Brick[$name] # brick requires host
-
- $ro_bool = $ro ? { # this has been added as a convenience
- true => 'ro',
- default => 'rw',
- }
-
- $valid_labeltype = $labeltype ? {
- #'msdos' => 'msdos', # TODO
- default => 'gpt',
- }
-
- $valid_fstype = $fstype ? {
- 'ext4' => 'ext4', # TODO
- default => 'xfs',
- }
-
- $force_flag = $force ? {
- true => 'f',
- default => '',
- }
-
- # XFS mount options:
- # http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/xfs.txt;hb=HEAD
- if ( $valid_fstype == 'xfs' ) {
- # exec requires
- include gluster::brick::xfs
- $exec_requires = [Package['xfsprogs']]
-
- # mkfs w/ uuid command
- # NOTE: the -f forces creation when it sees an old xfs part
- # TODO: xfs_admin doesn't have a --quiet flag. silence it...
- $exec_mkfs = "/sbin/mkfs.${valid_fstype} -q${force_flag} `/bin/readlink -e ${dev}`1 && /usr/sbin/xfs_admin -U '${fsuuid}' `/bin/readlink -e ${dev}`1"
-
- # By default, XFS allocates inodes to reflect their on-disk
- # location. However, because some 32-bit userspace applications
- # are not compatible with inode numbers greater than 232, XFS
- # will allocate all inodes in disk locations which result in
- # 32-bit inode numbers. This can lead to decreased performance
- # on very large filesystems (i.e. larger than 2 terabytes),
- # because inodes are skewed to the beginning of the block
- # device, while data is skewed towards the end.
- # To address this, use the inode64 mount option. This option
- # configures XFS to allocate inodes and data across the entire
- # file system, which can improve performance.
- $option01 = $xfs_inode64 ? {
- true => 'inode64',
- default => '',
- }
-
- # By default, XFS uses write barriers to ensure file system
- # integrity even when power is lost to a device with write
- # caches enabled. For devices without write caches, or with
- # battery-backed write caches, disable barriers using the
- # nobarrier option.
- $option02 = $xfs_nobarrier ? {
- true => 'nobarrier',
- default => '',
- }
-
- $options_list = ["${option01}", "${option02}"]
-
- } elsif ( $valid_fstype == 'ext4' ) {
- # exec requires
- include gluster::brick::ext4
- $exec_requires = [Package['e2fsprogs']]
-
- # mkfs w/ uuid command
- $exec_mkfs = "/sbin/mkfs.${valid_fstype} -U '${fsuuid}' `/bin/readlink -e ${dev}`1"
-
- # mount options
- $options_list = [] # TODO
- }
-
- # put all the options in an array, remove the empty ones, and join with
- # commas (this removes ',,' double comma uglyness)
- # adding 'defaults' here ensures no ',' (leading comma) in mount command
- $mount_options = inline_template('<%= (["defaults"]+options_list).delete_if {|x| x.empty? }.join(",") %>')
-
- $exec_noop = $areyousure ? {
- true => false,
- default => true,
- }
-
- # if we're on itself
- if ( "${fqdn}" == "${host}" ) {
-
- # first get the device ready
-
- # the scary parted command to run...
- $exec_mklabel = "/sbin/parted -s -m -a optimal ${dev} mklabel ${valid_labeltype}"
- $exec_mkpart = "/sbin/parted -s -m -a optimal ${dev} mkpart primary 0% 100%"
- $scary_exec = "${exec_mklabel} && ${exec_mkpart} && ${exec_mkfs}" # the command
- if $exec_noop {
- notify { 'noop mode:':
- message => "${scary_exec}",
- }
- }
-
- exec { "${scary_exec}":
- logoutput => on_failure,
- unless => [ # if one element is true, this *doesn't* run
- "/usr/bin/test -e `/bin/readlink -e ${dev}`1", # does partition 1 exist ?
- "/usr/bin/test -e /dev/disk/by-uuid/${fsuuid}",
- "/bin/false", # TODO: add more criteria
- ],
- require => $exec_requires,
- timeout => 3600, # set to something very long
- noop => $exec_noop,
- alias => "gluster-brick-make-${name}",
- }
-
- # make an empty directory for the mount point
- file { "${mount}":
- ensure => directory, # make sure this is a directory
- recurse => false, # don't recurse into directory
- purge => false, # don't purge unmanaged files
- force => false, # don't purge subdirs and links
- require => Exec["gluster-brick-make-${name}"],
- }
-
- mount { "${mount}":
- atboot => true,
- ensure => mounted,
- device => "UUID=${fsuuid}",
- fstype => "${valid_fstype}",
- # noatime,nodiratime to save gluster from silly updates
- options => "${mount_options},${ro_bool},noatime,nodiratime,noexec", # TODO: is nodev? nosuid? noexec? a good idea?
- dump => '0', # fs_freq: 0 to skip file system dumps
- # NOTE: technically this should be '2', to `fsck.xfs`
- # after the rootfs ('1'), but fsck.xfs actually does
- # 'nothing, successfully', so it's irrelevant, because
- # xfs uses xfs_check and friends only when suspect.
- pass => '2', # fs_passno: 0 to skip fsck on boot
- require => [
- File["${mount}"],
- ],
- }
- }
+ # eg: annex1.example.com:/storage1a
+ $split = split($name, ':') # do some $name parsing
+ $host = $split[0] # host fqdn
+ $mount = $split[1] # brick mount
+
+ if ! ( "${host}:${mount}" == "${name}" ) {
+ fail('The brick $name must match a $host-$mount pattern.')
+ }
+
+ Gluster::Host[$host] -> Gluster::Brick[$name] # brick requires host
+
+ $ro_bool = $ro ? { # this has been added as a convenience
+ true => 'ro',
+ default => 'rw',
+ }
+
+ $valid_labeltype = $labeltype ? {
+ #'msdos' => 'msdos', # TODO
+ default => 'gpt',
+ }
+
+ $valid_fstype = $fstype ? {
+ 'ext4' => 'ext4', # TODO
+ default => 'xfs',
+ }
+
+ $force_flag = $force ? {
+ true => 'f',
+ default => '',
+ }
+
+ # XFS mount options:
+ # http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/xfs.txt;hb=HEAD
+ if ( $valid_fstype == 'xfs' ) {
+ # exec requires
+ include gluster::brick::xfs
+ $exec_requires = [Package['xfsprogs']]
+
+ # mkfs w/ uuid command
+ # NOTE: the -f forces creation when it sees an old xfs part
+ # TODO: xfs_admin doesn't have a --quiet flag. silence it...
+ $exec_mkfs = "/sbin/mkfs.${valid_fstype} -q${force_flag} `/bin/readlink -e ${dev}`1 && /usr/sbin/xfs_admin -U '${fsuuid}' `/bin/readlink -e ${dev}`1"
+
+ # By default, XFS allocates inodes to reflect their on-disk
+ # location. However, because some 32-bit userspace applications
+ # are not compatible with inode numbers greater than 232, XFS
+ # will allocate all inodes in disk locations which result in
+ # 32-bit inode numbers. This can lead to decreased performance
+ # on very large filesystems (i.e. larger than 2 terabytes),
+ # because inodes are skewed to the beginning of the block
+ # device, while data is skewed towards the end.
+ # To address this, use the inode64 mount option. This option
+ # configures XFS to allocate inodes and data across the entire
+ # file system, which can improve performance.
+ $option01 = $xfs_inode64 ? {
+ true => 'inode64',
+ default => '',
+ }
+
+ # By default, XFS uses write barriers to ensure file system
+ # integrity even when power is lost to a device with write
+ # caches enabled. For devices without write caches, or with
+ # battery-backed write caches, disable barriers using the
+ # nobarrier option.
+ $option02 = $xfs_nobarrier ? {
+ true => 'nobarrier',
+ default => '',
+ }
+
+ $options_list = ["${option01}", "${option02}"]
+
+ } elsif ( $valid_fstype == 'ext4' ) {
+ # exec requires
+ include gluster::brick::ext4
+ $exec_requires = [Package['e2fsprogs']]
+
+ # mkfs w/ uuid command
+ $exec_mkfs = "/sbin/mkfs.${valid_fstype} -U '${fsuuid}' `/bin/readlink -e ${dev}`1"
+
+ # mount options
+ $options_list = [] # TODO
+ }
+
+ # put all the options in an array, remove the empty ones, and join with
+ # commas (this removes ',,' double comma uglyness)
+ # adding 'defaults' here ensures no ',' (leading comma) in mount command
+ $mount_options = inline_template('<%= (["defaults"]+options_list).delete_if {|x| x.empty? }.join(",") %>')
+
+ $exec_noop = $areyousure ? {
+ true => false,
+ default => true,
+ }
+
+ # if we're on itself
+ if ( "${fqdn}" == "${host}" ) {
+
+ # first get the device ready
+
+ # the scary parted command to run...
+ $exec_mklabel = "/sbin/parted -s -m -a optimal ${dev} mklabel ${valid_labeltype}"
+ $exec_mkpart = "/sbin/parted -s -m -a optimal ${dev} mkpart primary 0% 100%"
+ $scary_exec = "${exec_mklabel} && ${exec_mkpart} && ${exec_mkfs}" # the command
+ if $exec_noop {
+ notify { 'noop mode:':
+ message => "${scary_exec}",
+ }
+ }
+
+ exec { "${scary_exec}":
+ logoutput => on_failure,
+ unless => [ # if one element is true, this *doesn't* run
+ "/usr/bin/test -e `/bin/readlink -e ${dev}`1", # does partition 1 exist ?
+ "/usr/bin/test -e /dev/disk/by-uuid/${fsuuid}",
+ "/bin/false", # TODO: add more criteria
+ ],
+ require => $exec_requires,
+ timeout => 3600, # set to something very long
+ noop => $exec_noop,
+ alias => "gluster-brick-make-${name}",
+ }
+
+ # make an empty directory for the mount point
+ file { "${mount}":
+ ensure => directory, # make sure this is a directory
+ recurse => false, # don't recurse into directory
+ purge => false, # don't purge unmanaged files
+ force => false, # don't purge subdirs and links
+ require => Exec["gluster-brick-make-${name}"],
+ }
+
+ mount { "${mount}":
+ atboot => true,
+ ensure => mounted,
+ device => "UUID=${fsuuid}",
+ fstype => "${valid_fstype}",
+ # noatime,nodiratime to save gluster from silly updates
+ options => "${mount_options},${ro_bool},noatime,nodiratime,noexec", # TODO: is nodev? nosuid? noexec? a good idea?
+ dump => '0', # fs_freq: 0 to skip file system dumps
+ # NOTE: technically this should be '2', to `fsck.xfs`
+ # after the rootfs ('1'), but fsck.xfs actually does
+ # 'nothing, successfully', so it's irrelevant, because
+ # xfs uses xfs_check and friends only when suspect.
+ pass => '2', # fs_passno: 0 to skip fsck on boot
+ require => [
+ File["${mount}"],
+ ],
+ }
+ }
}
+# vim: ts=8