Ask Your Question
0

Managing partitions

asked 2016-12-20 07:21:15 -0600

puser gravatar image

I am creating a module to create and manage filesystems. I have everything working from physical volumes to mounting the filesystem. I am utilizing a puppetforge module called LVM.

This module works great except for the fact that it does not manage the partition table at all. If you do a pvcreate with this module (or as a standalone command) you can create a physical volume without partitioning a disk. This does work however if you do an fdisk -l you will see that there are no partitions on that disk (because none were created). I would like to somehow manage partitions so that it provides more clarity on what that disk is being used for.

Is there a puppet module/command/function that I can use to help manage partitions? I created an exec that will do it but it feels "dirty" and I feel like there are cleaner solutions.

thanks,

My disk partitioner for reference:

#Where ${disk} is sdb1, sdc1, etc.

disks.each |$disk| {
  exec { "part_${disk}":
    command => "/usr/sbin/parted -a optimal -- /dev/${disk} unit compact mkpart primary \"1\" \"-1\" ; /bin/sleep 1",
    unless  => "/sbin/fdisk -l | grep /dev/${disk}",
  }
}
edit retag flag offensive close merge delete

Comments

Why do u need to globally partition disks? In the end you'd come up with a separate module just partitioning disks (abstract), that heavily uses exec resources. That's not dirty style. Howevr, I seriously doubt u wanna manage that w/ PP. You're better off with a separate sh script, manually invoked.

Kai Burghardt gravatar imageKai Burghardt ( 2016-12-20 09:05:44 -0600 )edit

It is for an automated build process. I would like puppet to manage the disks from partition to mounting.

puser gravatar imagepuser ( 2016-12-20 09:22:06 -0600 )edit

I think the 'correct' way to manage low level things like that would be a native type/provider. to validate state and manage your commands. ( https://www.youtube.com/watch?v=Jr8H0wSUMBY&list=PLV86BgbREluVjwwt-9UL8u2Uy8xnzpIqa&index=19 )

DarylW gravatar imageDarylW ( 2016-12-20 09:58:15 -0600 )edit

We do something similar, where we look for disks without partitons, create a (in our case single) partition, create the filesystem on that partition, and then use the mount resource to create the mount point. it IS mostly execs for single line checks that work of the existence of the partition

DarylW gravatar imageDarylW ( 2016-12-20 09:59:45 -0600 )edit

Ours is used for taking blank EBS volumes and correctly creating the required filesystems in a dynamic environment during initial instance creation time, we don't manage' change across the file system later

DarylW gravatar imageDarylW ( 2016-12-20 10:00:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-12-20 10:02:58 -0600

DarylW gravatar image

updated 2016-12-20 11:29:16 -0600

I think the 'correct' way to manage low level things like that would be a native type/provider. to validate state and manage your commands.

You would use all of the requisite commands to figure out the 'state' of the system, and compare the 'is' to the 'should be'.

There are a few other good resources out there talking about types and providers..

---------------- EDIT ---------------- Wow, I just looked into the module, for some reason I misread it and thought you were managing it yourself.

I believe it's partitions are lvm partitions, so you would need to audit them with the correct specific lvm based tools, not fdisk.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-12-20 07:21:15 -0600

Seen: 423 times

Last updated: Dec 20 '16