Disk partitioning management

1,023 views
Skip to first unread message

Martin Nitram

unread,
May 22, 2015, 4:57:33 PM5/22/15
to salt-...@googlegroups.com
Hi list!

I've looking around for a simple way to administer disks with salt.
As we are using AWS, I've created an instance with a provisioned volume, and I was wondering if there is some way to make use of it.

All I found googling around was this two questions (here at the salt-users group):


The second one is exactly what I'm looking for.

Figured out how to do some volume management with salt.states.lvm (http://docs.saltstack.com/en/latest/ref/states/all/salt.states.lvm.html), but as for the partitioning part, all I see are cmd.run & unless options.

Is there a better or salt native way to manage them? How do you do it?

Thanks!

Martin


 

Colton Myers

unread,
May 28, 2015, 4:14:24 PM5/28/15
to salt-...@googlegroups.com
There's also the parted module for managing partitions: http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.parted.html#module-salt.modules.parted

--
Colton Myers
Platform Engineer, SaltStack
@basepi on Twitter/Github/IRC

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin

unread,
May 30, 2015, 12:07:32 AM5/30/15
to salt-...@googlegroups.com
Hi Colton,

I saw that module, but - let me know if I'm wrong - you can't use it in a sls, right?



--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/tV2I_4raZV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.

Florian Ermisch

unread,
May 30, 2015, 10:00:19 AM5/30/15
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Martin,

you're right, it's an execution module, not a state module.
But after a quick glance over the module's docs I would say there's everything one needs to build a state module on top of the existing exec mod.

Regards,Florian
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQFTBAEBCAA9BQJVacJqNhxGbG9yaWFuIEVybWlzY2ggPGZsb3JpYW4uZXJtaXNj
aEBhbHVtbmkudHUtYmVybGluLmRlPgAKCRAu8tzCHoBI/S5OB/4wqjtQMQUsQ4/S
4jKhQyJ0S4vxxHeAVG3KoV2Qdpp/FkwW0lLJV+sfn05u++cArNXVxBIYbyCXL7hD
oZRdqmthk5aOdUh59q5FiqzZYg1QGWokDm/0Sp/uePlevHLoYTdVkYc9T3a+HozB
QYkJX27MAO+1Xs7qGjHIv9WphSgtksrafG61I+eSfCVvx4ScfBPjMpVbQ9gUJAxt
qmsIxroNmxkr5LEfA0l9btBq1BNnvpS5Vg74s6wnuLjTvrXjmNIfoZOdtmpaX4PL
68jJmShG/SvHB3e9wN2BftM36tg8Adjrr6un+cZ0KeRmcjIgjpq5Dwwj7WJGCDX/
z4SY7E2H
=CgXy
-----END PGP SIGNATURE-----

Martin

unread,
May 31, 2015, 8:03:07 PM5/31/15
to salt-...@googlegroups.com
Hi all,

After some time googling and reading, finally got a good enough method for partition, or at least to add another disk (which is my scenario).
Here is what I've done so far:


/dev/sdg:
  lvm.pv_present

test_vg:
  lvm.vg_present:
    - devices: /dev/sdg
    - require:
      - lvm: /dev/sdg

test_data:
  lvm.lv_present:
    - vgname: test_vg
    - size: 4G     ## This is bad! :( . No '-l +100%FREE' allowed
    - require:
      - lvm: test_vg

/dev/dm-0:    #### This made the trick
  blockdev.formatted:
    - fs_type: ext4
    - require:
      - lvm: test_data

/var/lib/mytest:
  mount.mounted:
    - device: /dev/dm-0
    - fstype: ext4
    - mkmnt: True
    - persist: True
    - user: foo
    - opts:
      - defaults
    - require:
      - blockdev: /dev/dm-0

  file.directory:
    - user: foo
    - group: foo
    - dir_mode: 755



It would be really nice if there were an option to use '-l +100%FREE' instead of a fixed size in lvm, but I can live without it.


Martin

bkcsfi sfi

unread,
Jul 7, 2016, 8:06:51 PM7/7/16
to Salt-users
Regarding 100%FREE, with salt 2016.3.1 and Ubuntu 16.04 minion, I modified your above example as shown below.

Specifying  extents: 100%FREE worked

Note that lvm_data_disk is a minion grain whose value is /dev/sdb

# lvm_disk/init.sls
{% set device = grains['lvm_data_disk'] %}
{{ device }}:
   lvm.pv_present
data_vg:
   lvm.vg_present:
     - devices: {{ device }}
     - require:
       - lvm: {{ device }}
data:
   lvm.lv_present:
     - vgname: data_vg
     - extents: 100%FREE 
     - require:
       - lvm: data_vg
/dev/data_vg/data: #### This made the trick

   blockdev.formatted:
     - fs_type: ext4
     - require:
       - lvm: data
/data:
   mount.mounted:
     - device: /dev/data_vg/data

     - fstype: ext4
     - mkmnt: True
     - persist: True
     - user: root

     - opts:
       - defaults
     - require:
       - blockdev: /dev/data_vg/data
   file.directory:
     - user: root
     - group: root
     - dir_mode: 755


 
Reply all
Reply to author
Forward
0 new messages